If you can, it is best to use the bare metal profile.
Regarding printf redirect to UART2, the only way I could get this to work was to change the “PinNames.h” file directly where I changed
// USB bridge connected UART pins
CONSOLE_TX = P3_1,
CONSOLE_RX = P3_0,
What I cannot figure out is that based on this link: Hitchhiker's Guide to Printf in Mbed 6
You should be able to override the console using
FileHandle *mbed_override_console(int fd)
{
static BufferedSerial console(USBTX, USBRX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
return &console;
}
But this did not work.
Then I tried to add in a config statement within mbed_app.json for “stdio_uart_tx” and “stdio_uart_rx” as targets.json informs us that:
"stdio_uart_tx": {
"help": "default TX STDIO pins is defined in PinNames.h file, but it can be overridden"
},
"stdio_uart_rx": {
"help": "default RX STDIO pins is defined in PinNames.h file, but it can be overridden"
},
But this too did not work.