USBSerial build error on mbed-os-6.5.0

Hi everybody,
I am trying to make usb serial application on stm32f103(blue pill) using mbed-os 6.5.0.
I am using mbed-cli for compile code. I am taking error message like this

[Fatal Error] main.cpp@6,10: USBSerial.h: No such file or directory
[ERROR] ./main.cpp:6:10: fatal error: USBSerial.h: No such file or directory
#include “USBSerial.h”

Here my compile command:

mbed compile -m NUCLEO_F103RB -t GCC_ARM --profile mbed-os/tools/profiles/release.json

My code:

#include “mbed.h”
#include “USBSerial.h”

int main()
{
// Initialise the digital pin LED1 as an output
DigitalOut led(PC_13);
USBSerial usbSerial(false, 0x1f00, 0x2012, 0x0001);

while(1) {
led = !led;
ThisThread::sleep_for(500ms);
usbSerial.printf(“hello mbed-os6.5 \r\n”);
}

}

My mbed_app.json:

{
“requires”: [“bare-metal”],
“config”: {
“usb_speed”: {
“help”: “USE_USB_OTG_FS or USE_USB_OTG_HS or USE_USB_HS_IN_FS”,
“value”: “USE_USB_OTG_FS”
}
},

"target_overrides":{
    "NUCLEO_F103RB": {
        "target.clock_source": "USE_PLL_HSE_XTAL",
        "target.clock_source_usb": "1",
        "target.device_has_add": ["USBDEVICE"]
    }
}

}

Hi everybody.
I added some parameters in requires list. Now i can build successfully. Here parameters:

“requires”: [“bare-metal”,“drivers-usb”, “events”],

And usbserial connection working very well.

2 Likes