ARTICLE AD BOX
I am observing an inconsistent behavior regarding line endings when porting an embedded project from SAMD51 to STM32 using the Arduino framework.
On the SAMD51, Serial.println() behaves as expected (single \r\n). However, on the STM32 (using the STM32Duino core), I am seeing "double" carriage returns/line feeds under specific conditions.
The Symptoms:
When printing hex buffers or numeric values: Serial.println(0x01fff); → Output: 01fff\r\n (Correct)
When printing string constants or error codes: Serial.println("ERROR QUEUE EMPTY"); → Output: ERROR QUEUE EMPTY\r\n\r\n (Unexpected extra CRLF)
My Environment:
Environment: PlatformIO (both)
Core: STM32Duino
Hardware: STM32F446RE (NUCLEO)
Comparison: Same code works flawlessly on SAMD51 (Adafruit Core).
What I've investigated:
I checked if my string constants already contain \n, but cutting down the last entries cuts down everything before the first \r\n and conditional logic (depending on the ending) doesn't work neither.
I suspect a difference in how Print::println() is implemented or how the underlying UART HAL handles the transmit buffer in the STM32 core.
I've looked for Serial.write() overrides that might be auto-converting \n to \r\n while println also adds its own.
Question:
Does the STM32 Arduino core have a known "auto-CRLF" feature in its HardwareSerial implementation that might conflict with the standard Arduino.h logic? How can I ensure a consistent single \r\n across both architectures?
