1 year, 2 months ago.

compile error occurs for USB Device on L4R5ZI

Hello, I get trouble to use USBDevice library on NUCLEO- L4R5ZI board.

When USBDevice library is from mbed_official is used, follow compile error occur Error: Cannot open source input file "USBHAL_STM_TARGET.h": No such file or directory in "USBDevice/targets/TARGET_STM/USBHAL_STM32.cpp", Line: 37, Col: 32

How to use USBDevice library?


Question relating to:

A world leader in providing the semiconductor solutions that make a positive contribution to people’s lives, both today and in the future.

1 Answer

1 year, 2 months ago.

Hi SH,

Did you see https://os.mbed.com/teams/ST/code/USBDEVICE/?

You can find an example for USBmouse here : https://developer.mbed.org/teams/ST/code/Nucleo_usbmouse/

thanks Daniel,

Accepted Answer

I already USBDEVICE of ST. (https://os.mbed.com/teams/ST/code/USBDEVICE/) I just did a test of USBmouse example but I got a same error. I seems that the usb library is not supported to the MUCLEO-L4R5ZI. In the USBDEVICE/TARGET_STM/USBHAL_STM_TARGET.h, target is defined but my board is not exist at that file


posted by SH Paek 29 Jul 2019

Yes, I've checked ST's USB DEVICE example code. You're right!. That example code is based on mbed 2. But NUCLEO L4R5ZI was included after Mbed OS 5.11. Furthermore, almost USB API was changed in Mbed OS 5. Let's download the mbed-os-example-blinky

$ mbed import mbed-os-example-blinky

And changing main.cpp to example code's main.cpp of ST(https://os.mbed.com/teams/ST/code/USBDEVICE/). You can successfully compile by MUCLEO-L4R5ZI. Let's try it!

posted by Daniel Lee 29 Jul 2019

thank you very much. It works well when I use mbed-os-example-blinky without imporint USBDEVICE.

posted by SH Paek 29 Jul 2019