How to define tx or rx buffer size for every uart?

I konw I can add it in build flags as follow


but I want to custom for evey, how to change it?

The STM32Duino core does not allow you to do that, the define is used in every HardwareSerial object, see Arduino_Core_STM32/HardwareSerial.h at main · stm32duino/Arduino_Core_STM32 · GitHub.

You would have to fork the core + modify the constructor to accept a buffer + length for each serial and then instantiate the sub-serials with new buffers of lengths which are individually configurable via a macro.

Or use a templated class + macros to fill in the template parameter. Many possibilities exist.