STM32 Nucleo, mbed 6 and printf

Hi,

I’m starting using PlatformIO environment with STM32 Nucleo board (NUCLEO-F411RE) and mbed 6. Mbed docs claims printf() should be available (https://os.mbed.com/docs/mbed-os/v6.3/debug-test/debugging-using-printf-statements.html ). In prior versions it was Serial class and serial.printf() method that can be used. Starting from mbed 6 there is no Serial class, but UnbufferedSerial/BufferedSerial which does not have printf() function. I know there is write(), but I would like to make use of convenience of printf’s formatting options.
I added printf() invocation to my main, it seems it is called properly, but I don’t see any output (checked Terminal, Debug Console and Output tabs).

Are there any configuration steps required to enable printf() on mbed 6 with output in PlatformIO? Is the output of printf() going to show in Debug Console tab?

Many thanks,
Adrian

If the board and mbed-os is setup correctly, calling printf() will output to the default STDIO UART interface, which should be connected to the STLink chip on the Nucleo which also acts as a UART-USB bridge and shows up as a COMx (windows) or /dev/ttyACMx (unix-like) device on the computer.

Have you made sure to check the serial monitor with a properly configured platformio.ini (most importantly monitor_speed to match the outputted baud rate)?

1 Like

Hi Maximilian Gerhardt,

Thank you for your response. I wasn’t aware of “Serial monitor” button in toolbar. I connected the board, clicked Serial monitor, it automatically selected proper port and now I see printf output. It works even without setting monitor_speed.

Many thanks!
Adrian