I’m trying to get usb serial working in my project, but I get the following error:
usbd_def.h: No such file or directory
I’ve followed the instructions in this topic: PlatformIO for stm32 and CubeMX include error
I’ve copied the contents of inc and source to lib/stm32 and I’ve added the required lines to platformio.ini.
The tool stm32pio doesn’t work for me.
I’m creating a few projects in platformio with vscode. The projects have to run on an ESP32 and two different STM32 mictrocontrollers. For STM32 I’m using stm32cube framework so I can do bare metal programming. I’ve got freertos working.
SO what exactly is your profile structure (tree
)? Where did you put the USB middleware files, what’s your platformio.ini
and code?
Ini file:
[env:nucleo_f446ze]
platform = ststm32
board = nucleo_f446ze
framework = stm32cube
lib_deps =
STM32Cube Middleware-FreeRTOS
Class
Core
custom_freertos_config_location = lib/FreeRTOS_config/FreeRTOSConfig.h
build_flags =
-mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
-I Inc
-I Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc
-I Middlewares/ST/STM32_USB_Device_Library/Core/Inc
lib_extra_dirs =
Middlewares/ST/STM32_USB_Device_Library/Class
Middlewares/ST/STM32_USB_Device_Library
This is my tree:
│ .gitignore
│ .travis.yml
│ CMakeLists.txt
│ platformio.ini
│ README.md
│ sdkconfig
│
├───.pio
│ ├───build
│ │ │ project.checksum
│ │ │
│ │ └───nucleo_f446ze
│ │ │ .sconsign.py36.dblite
│ │ │
│ │ ├───lib1b5
│ │ │ └───e2_board
│ │ │ e2_board.o
│ │ │
│ │ ├───lib34d
│ │ │ └───stm32
│ │ │ stm32f4xx_hal_msp.o
│ │ │ stm32f4xx_it.o
│ │ │ system_stm32f4xx.o
│ │ │
│ │ ├───lib5cc
│ │ │ libClass.a
│ │ │
│ │ ├───lib886
│ │ │ │ libSTM32Cube Middleware-FreeRTOS_ID6696.a
│ │ │ │
│ │ │ └───STM32Cube Middleware-FreeRTOS_ID6696
│ │ │ │ list.o
│ │ │ │ queue.o
│ │ │ │ tasks.o
│ │ │ │
│ │ │ ├───CMSIS_RTOS
│ │ │ │ cmsis_os.o
│ │ │ │
│ │ │ └───portable
│ │ │ ├───GCC
│ │ │ │ └───ARM_CM4F
│ │ │ │ port.o
│ │ │ │
│ │ │ └───MemMang
│ │ │ heap_4.o
│ │ │
│ │ ├───liba26
│ │ │ libFreeRTOS_config.a
│ │ │
│ │ ├───libf89
│ │ │ └───e2_hal
│ │ │ e2_hal.o
│ │ │ e2_i2c.o
│ │ │
│ │ └───src
│ │ app.o
│ │
│ └───libdeps
│ ├───esp32doit-devkit-v1
│ └───nucleo_f446ze
├───.vscode
│ c_cpp_properties.json
│ extensions.json
│ launch.json
│
├───include
│ README
│
├───lib
│ │ README
│ │
│ ├───e2_board
│ │ e2_board.cpp
│ │ e2_board.h
│ │
│ ├───e2_hal
│ │ e2_hal.cpp
│ │ e2_hal.h
│ │ e2_i2c.cpp
│ │ e2_i2c.h
│ │ e2_i2c_interface.h
│ │
│ ├───FreeRTOS_config
│ │ FreeRTOSConfig.h
│ │
│ └───stm32
│ main.c
│ main.h
│ stm32f4xx_hal_conf.h
│ stm32f4xx_hal_msp.c
│ stm32f4xx_it.c
│ stm32f4xx_it.h
│ system_stm32f4xx.c
│ usbd_cdc_if.c
│ usbd_cdc_if.h
│ usbd_conf.c
│ usbd_conf.h
│ usbd_desc.c
│ usbd_desc.h
│ usb_device.c
│ usb_device.h
│
├───Middlewares
│ └───ST
│ └───STM32_USB_Device_Library
│ └───Class
├───src
│ app.cpp
│ CMakeLists.txt
│ sdkconfig
│ sdkconfig.h
│
└───test
README
my middlewares are stored here:
C:\Users\Chris\.platformio\packages\framework-stm32cube\f4\Middlewares\ST\STM32_USB_Device_Library
I did not create the middlewares folder in my project tree. I’m thinking it doesn’t link to the library in the framework.
Ok. The project builds if I manually copy the middlewares folder. A dirty solution because both platformio and stm32cube exist to provide users with basic drivers. A missed opportunity.