I am trying to create my own board based on a STM32F4 processor. This board has no need for a UART over USB. So in my PinNames.h there is no definition for USBTX and USBRX. But now mbed-os won’t compile anymore! Regardless of mbed-os version (5.14, 5.15, 6.2.0), at least the files ‘mbed_pinmap_default.cpp’ and ‘greentea_serial.cpp’ require these definitions.
Is there a motivation for USBTX and USBRX to be mandatory? Or is there a sensible way to work around this issue?
You can try adding
device_has_remove": [ "USBDEVICE" ],
on your board’s custom_target.json
, or failing that, just reroute unneeded mandatory pins to NC
(0xFFFFFFFF
on many, but not all, targets).
Greentea uses USBTX and USBRX to create a serial port regardless of USBDEVICE. It only checks for DEVICE_SERIAL.
Besides, it doesn’t seem right to have to ‘remove’ all USB devices just because I don’t support UART over USB on my board. More so because the same GreenteaSerial class which uses the USBTX and USBRX definitions for the transmit and receive pin, uses the STDIO_UART_RTS and STDIO_UART_CTS defines for flow control!
So I did settle on adding "USBTX=NC"
and "USBRX=NC"
in the "macro_add"
portion of my custom_target.json
. But it remains weird to have to explicitly mention that there is no serial over USB.