Arm Mbed OS support forum

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

Hi all!

I am a bit confused, i have a board with USB device hardware but get the runtime error:
“This board does not have a hardware USB driver”.
Hardware:

  • NUCLEO-L152RE Development board
    Software:
  • MBED STUDIO version 0.8.1
  • MBED OS 5.15.1

Complete error message:

++ MbedOS Error Info ++
Error Status: 0x80FF0100 Code: 256 Module: 255
Error Message: Fatal Run-time error
Location: 0x800394F
Error Value: 0x0
Current Thread: main Id: 0x2000192C Entry: 0x8008571 StackSize: 0x1000 StackMem: 0x20000428 SP: 0x20001364
For more info, visit: https://mbed.com/s/error?error=0x80FF0100&tgt=NUCLEO_L152RE
– MbedOS Error Info –
This board does not have a hardware USB driver

Any clues? Is this a known issue or limitation?

Hi there,

this feature need to be add in Mbed_app.json I think.

EDIT: after few minutes I found what I meant. Check this topic, maybe it will help.

BR, Jan

@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!

Hi there,

Try to add your target in USBPhy_STM32.cpp.
you can find the file in /mbed-os/targets/TARGET_STM/USBPhy_STM32.cpp

Add your target from line 204 in the list.

Use:
defined(TARGET_NUCLEO_L152RE) || \

I was able to compile the code.

I have been able to program the MAX32630FTHR board without bother using the online compiler.

I’ve tested all the examples on the hardware page. Many of the examples use “printf” both to send/receive data via serial (DAPLINK) and via virtual serial port when including “USBSerial.h”.

I’m now trying to replicate on Mbed Studio, using Mbed OS 5.15.4.

However this throws up the same fatal runtime error, as shown in this forum post, with the message “This board does not have a hardware USB driver”.

The suggested solution as shown above (adding “USBDEVICE” to the target) almost works.

I am getting just one compile error:
[Error] @0,0: L6218E: Undefined symbol get_usb_phy() (referred from BUILD/MAX32630FTHR/ARMC6/mbed-os/drivers/source/usb/USBAudio.o).

How do I fix this?

I also tried another method which was to import the maxim integrated library, which is used in the online compiler example.
https://os.mbed.com/teams/MaximIntegrated/code/USBDevice/

but this threw up loads more errors.

I see this issue was raised before on GitHub over a year ago (July 2019)

I get the feeling Maxim Integrated do not seem too bothered to fix all these errors, or maybe they don’t have high enough standards to consider these problems for them to deal with, or maybe they’ve basically abandoned this board… :persevere: :confounded: