3 years, 3 months ago.

USBSerial Support

Is the USBSerial library formally supported in mbed OS v5.8 or not? If not, when will it be?

I tried to use this library for a project using a custom STM32F207VG target about 1 year ago, and found that the feature was unsupported.

Last week, I found docs for the feature in the Mbed OS v5.1 docs (https://docs.mbed.com/docs/mbed-os-api-reference/en/5.1/APIs/interfaces/USBDevice/USBSerial/), but can't find the same feature described in the v5.8 docs.

Looking over the code, I still see USBSerial.h in features/unsupported on master (https://github.com/ARMmbed/mbed-os/tree/master/features/unsupported/USBDevice/USBSerial).

Indeed, when I try to compile the basic hello world program from the v5.1 docs by including the file from the unsupported sources, compile fails:

$ mbed compile --source . --source mbed-os/features/unsupported/USBDevice
Building project t2_devkit_stm (GEN_F207VG, GCC_ARM)
Scan: .
Scan: USBDevice
Scan: env
Scan: mbed
Scan: FEATURE_LWIP
Compile [ 97.4%]: main.cpp
[Warning] MbedCRC.h@34,32: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
Compile [ 97.6%]: USBKeyboard.cpp
[Warning] MbedCRC.h@34,32: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
Compile [ 97.8%]: USBHID.cpp
[Warning] MbedCRC.h@34,32: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
Compile [ 98.0%]: USBMIDI.cpp
[Warning] MbedCRC.h@34,32: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
Compile [ 98.2%]: USBMouse.cpp
[Warning] MbedCRC.h@34,32: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
Compile [ 98.5%]: USBHAL_STM32F4.cpp
Compile [ 98.7%]: USBMouseKeyboard.cpp
[Warning] MbedCRC.h@34,32: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
Compile [ 98.9%]: USBAudio.cpp
[Warning] MbedCRC.h@34,32: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
Compile [ 99.1%]: USBDevice.cpp
[Warning] MbedCRC.h@34,32: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
Compile [ 99.3%]: USBHAL_STM32.cpp
[Error] USBHAL_STM32.h@49,2: #error "Target not supported !"

Is this feature supported or not?

If not, when is it expected (this has been a blocker to switching over a lot of use at my company to mbed from a proprietary RTOS)?

Where can I conclusively see what targets this "unsupported" feature supports?

2 Answers

3 years, 3 months ago.

Hi Thomas,

The USBSerial API is no longer supported by the current version of Mbed OS (5.8). If you look in Mbed OS's repo in the /features/unsupported/ folder, you can see a .mbedignore file that removes this entire directory from compilation.

I would take a look at the currently supported API Serial: https://os.mbed.com/docs/v5.8/reference/serial.html

Mbed OS also has a RawSerial API that allows you to use UART functionality without the use of Stream's print and scan functions the way the Serial API does: https://os.mbed.com/docs/v5.8/reference/rawserial.html

Please let me know if you have any questions!

- Jenny, team Mbed

If this solved your question, please make sure to click the "Thanks" link below!

3 years, 3 months ago.

I just tested USBSerial object from /unsupported/USBDevice on my STM32L476VG target using the compiled mbed-os library with success in the online compiler. What are the limits of it? Where does it break down? Does it work perfectly in all cases? I couldn't tell you. I have used versions of this USBSerial driver for a while, and the big issue that I see is that it does not always connect the first time when you try to open the COM port. Sometimes have to open and close the COM port several times to start seeing data. The type of machine (win, linux, mac) or type of port (usb2, usb3) also makes a difference with connectivity. On the PC side software you can open and close it rapidly until it works, so I've actually stopped even noticing this issue.

The key to make it work I think is to copy that folder and make it a top level folder in your project and then delete everything from that folder that is not needed for your target. If you are not using Audio or HID or Mouse, just delete those folders. Then delete files and folders for any targets you are not using.

Have you tried the project Wizards for that Target? There are USB examples - sort of implies ST thinks those examples are working okay.