Arm Mbed and Pelion Device Management support forum

How to write a mbed_app.json file for adding feature USBDEVICE

mbed-os5.15.0, Nucleo-F446RE, USBDevice, On-line compiler, json

I made a USB Serial(USBDevice) program on mbed-os5.15.0.

#include "mbed.h"
#include "USBSerial.h"

Serial pc(USBTX, USBRX, 115200);
USBSerial usb_serial;

int main(void){
    uint32_t num = 0;
    while(true) {
        usb_serial.printf("I am a USB virtual serial port: %d\r\n", num++);
        pc.printf("I am a ST-Link virtual serial port: %d\r\n", num + 10000);

I ran the program on Nucleo-F446RE board then error was appear as follows.

-- MbedOS Error Info --
This board does not have a hardware USB driver

BTW I ran the program on Nucleo-F446ZE (not R but Z) board and the program is fine as expect.
After that I wrote mbed_app.json for adding USBDEVICE feature for F446RE.

    "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": {
        "*": {
            "target.components_add": ["SD"],
            "target.components_add": ["USBDEVICE"]

This json file does Not have an compile error but same run time error message was appeared.
Please give me an advice how to write json file to enable USBDEVICE feature.

In addtion, I imported mbed-os5.15.0 souce files into my online environment and modified target.json file as follows.

    "NUCLEO_F446RE": {
        "inherits": ["FAMILY_STM32"],
        "supported_form_factors": ["ARDUINO", "MORPHO"],
        "core": "Cortex-M4F",
        "extra_labels_add": ["STM32F4", "STM32F446xE", "STM32F446RE"],
        "config": {
            "clock_source": {
                "help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
                "value": "USE_PLL_HSE_EXTC|USE_PLL_HSI",
                "macro_name": "CLOCK_SOURCE"
            "usb_speed": {
                "help": "USE_USB_OTG_FS or USE_USB_OTG_HS or USE_USB_HS_IN_FS",
                "value": "USE_USB_OTG_FS"
        "detect_code": ["0777"],
        "device_has_add": [
        "release_versions": ["2", "5"],
        "device_name": "STM32F446RE",
        "bootloader_supported": true

It works fine.

hi @kenji_tokyo
Please note that USBDEVICE is a device, not a comopnent.
Please try changing "target.components_add": ["USBDEVICE"] to "target.device_has_add": ["USBDEVICE"]
Mbed Support

Hi Ron,
Thank you for your support.
I modified the json file accordingly your advice and worked well on Nucleo-F446RE board + USB handmade circuit.
Thanks again,