This board does not have a hardware USB driver... But it does!

@JohnnyK First of all thanks for your response.

I have read the article and have done the following:

  1. Created a mbed_app.json file in the root of the project with the following content:

{
“config”: {
“usb_speed”: {
“help”: "USE_USB_FS ",
“value”: “USE_USB_FS”
}
},
“target_overrides”: {
“*”: {
“target.device_has_add”: [“USBDEVICE”]
}
}
}

Compile output:


Compile [ 98.7%]: USBPhy_STM32.cpp
[Error] USBPhy_STM32.cpp@46,31: no member named ‘DIEPTXF0_HNPTXFSIZ’ in ‘USB_TypeDef’
[Error] USBPhy_STM32.cpp@48,32: no member named ‘DIEPTXF’ in ‘USB_TypeDef’
[Error] USBPhy_STM32.cpp@56,5: unknown type name ‘USB_OTG_GlobalTypeDef’
[Error] USBPhy_STM32.cpp@59,28: use of undeclared identifier ‘USBx_DEVICE’
[Error] USBPhy_STM32.cpp@59,48: use of undeclared identifier ‘USB_OTG_DSTS_FNSOF’
[Error] USBPhy_STM32.cpp@171,21: use of undeclared identifier ‘USB_IRQn’
[Error] USBPhy_STM32.cpp@257,5: use of undeclared identifier ‘HAL_PCDEx_SetRxFiFo’; did you mean ‘HAL_PCDEx_GetTxFiFo’?
[Error] USBPhy_STM32.cpp@263,9: use of undeclared identifier ‘HAL_PCDEx_SetTxFiFo’
[Error] USBPhy_STM32.cpp@271,20: use of undeclared identifier ‘USB_IRQn’
[Error] USBPhy_STM32.cpp@272,22: use of undeclared identifier ‘USB_IRQn’
[Error] USBPhy_STM32.cpp@273,20: use of undeclared identifier ‘USB_IRQn’
[Error] USBPhy_STM32.cpp@281,21: use of undeclared identifier ‘USB_IRQn’
[Error] USBPhy_STM32.cpp@492,26: use of undeclared identifier ‘USB_IRQn’
[Error] USBPhy_STM32.cpp@493,20: use of undeclared identifier ‘USB_IRQn’
[Error] USBPhy_STM32.cpp@498,21: use of undeclared identifier ‘USB_IRQn’
[ERROR] .\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:46:31: error: no member named ‘DIEPTXF0_HNPTXFSIZ’ in ‘USB_TypeDef’
len = hpcd->Instance->DIEPTXF0_HNPTXFSIZ >> 16;

.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:48:32: error: no member named 'DIEPTXF' in 'USB_TypeDef'
len =  hpcd->Instance->DIEPTXF[fifo - 1] >> 16;
~~~~~~~~~~~~~~  ^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:56:5: error: unknown type name 'USB_OTG_GlobalTypeDef'
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:59:28: error: use of undeclared identifier 'USBx_DEVICE'
priv->events->sof((USBx_DEVICE->DSTS & USB_OTG_DSTS_FNSOF) >> 8);
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:59:48: error: use of undeclared identifier 'USB_OTG_DSTS_FNSOF'
priv->events->sof((USBx_DEVICE->DSTS & USB_OTG_DSTS_FNSOF) >> 8);
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:171:21: error: use of undeclared identifier 'USB_IRQn'
NVIC_DisableIRQ(USBHAL_IRQn);
^
./mbed-os/targets/TARGET_STM/USBPhyHw.h:42:22: note: expanded from macro 'USBHAL_IRQn'
#define USBHAL_IRQn  USB_IRQn
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:257:5: error: use of undeclared identifier 'HAL_PCDEx_SetRxFiFo'; did you mean 'HAL_PCDEx_GetTxFiFo'?
HAL_PCDEx_SetRxFiFo(&hpcd, (fifo_size / 4));
^~~~~~~~~~~~~~~~~~~
HAL_PCDEx_GetTxFiFo
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:42:10: note: 'HAL_PCDEx_GetTxFiFo' declared here
uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:263:9: error: use of undeclared identifier 'HAL_PCDEx_SetTxFiFo'
HAL_PCDEx_SetTxFiFo(&hpcd, i, fifo_size / 4);
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:271:20: error: use of undeclared identifier 'USB_IRQn'
NVIC_SetVector(USBHAL_IRQn, (uint32_t)&_usbisr);
^
./mbed-os/targets/TARGET_STM/USBPhyHw.h:42:22: note: expanded from macro 'USBHAL_IRQn'
#define USBHAL_IRQn  USB_IRQn
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:272:22: error: use of undeclared identifier 'USB_IRQn'
NVIC_SetPriority(USBHAL_IRQn, 1);
^
./mbed-os/targets/TARGET_STM/USBPhyHw.h:42:22: note: expanded from macro 'USBHAL_IRQn'
#define USBHAL_IRQn  USB_IRQn
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:273:20: error: use of undeclared identifier 'USB_IRQn'
NVIC_EnableIRQ(USBHAL_IRQn);
^
./mbed-os/targets/TARGET_STM/USBPhyHw.h:42:22: note: expanded from macro 'USBHAL_IRQn'
#define USBHAL_IRQn  USB_IRQn
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:281:21: error: use of undeclared identifier 'USB_IRQn'
NVIC_DisableIRQ(USBHAL_IRQn);
^
./mbed-os/targets/TARGET_STM/USBPhyHw.h:42:22: note: expanded from macro 'USBHAL_IRQn'
#define USBHAL_IRQn  USB_IRQn
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:492:26: error: use of undeclared identifier 'USB_IRQn'
NVIC_ClearPendingIRQ(USBHAL_IRQn);
^
./mbed-os/targets/TARGET_STM/USBPhyHw.h:42:22: note: expanded from macro 'USBHAL_IRQn'
#define USBHAL_IRQn  USB_IRQn
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:493:20: error: use of undeclared identifier 'USB_IRQn'
NVIC_EnableIRQ(USBHAL_IRQn);
^
./mbed-os/targets/TARGET_STM/USBPhyHw.h:42:22: note: expanded from macro 'USBHAL_IRQn'
#define USBHAL_IRQn  USB_IRQn
^
.\mbed-os\targets\TARGET_STM\USBPhy_STM32.cpp:498:21: error: use of undeclared identifier 'USB_IRQn'
NVIC_DisableIRQ(USBHAL_IRQn);
^
./mbed-os/targets/TARGET_STM/USBPhyHw.h:42:22: note: expanded from macro 'USBHAL_IRQn'
#define USBHAL_IRQn  USB_IRQn
^
15 errors generated.

I have tried several configs but they all end up with errors...

I have found: https://os.mbed.com/users/va009039/code/L152RE_USBDevice_example/ is it a good advice to use his libraries with mbed OS5?, and most important should i desist in trying to configure USBDEVICE throught mbed_app.json, is it posible?

Thanks!