Skip to main content
LLope.31
Associate III
September 26, 2023
Solved

Help with integrating tinyusb in STM32CubeIDE

  • September 26, 2023
  • 3 replies
  • 11825 views

Hello,

I have problems with building the cdc_msc example on STM32CubeIDE. My board is STM32F411 blackpill.

I have followed the instructions in https://github.com/hathach/tinyusb/discussions/633 but get errors when building.

Below I will link my entire project and also a screenshot of the errors in STM32CubeIDE.

I would appreciate a lot if someone could help me with this. thanks

LLope31_0-1695717951238.png

 

This topic has been closed for replies.
Best answer by LLope.31

I managed to get it to compile and it seems to be working as a mass storage device as expected. Although the fix was sketchy:

#define CFG_TUSB_MCU OPT_MCU_STM32F4
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
#define BOARD_DEVICE_RHPORT_NUM 0
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED)
#define CFG_TUSB_RHPORT1_MODE 0

I added this last line to solve for the high speed case... was this really the only way to solve it, and there is a problem with the library?

3 replies

Bob S
Super User
September 26, 2023

The very first (top) error line tells you the problem.  Apparently the code is written to use the high speed (HS) USB port but you have the full speed (FS) port enabled/defined (in CubeMX?).  Either change your CubeMX config or change that #define to use the FS port.

Piranha
Principal III
September 26, 2023

Look at the code for the first error and go back through those definitions... For full-speed mode, instead of CFG_TUSB_RHPORT1_MODE one must define CFG_TUSB_RHPORT0_MODE.

LLope.31
LLope.31Author
Associate III
September 26, 2023

LLope31_0-1695761930365.png

I tried that already and got this

LLope.31
LLope.31AuthorBest answer
Associate III
September 26, 2023

I managed to get it to compile and it seems to be working as a mass storage device as expected. Although the fix was sketchy:

#define CFG_TUSB_MCU OPT_MCU_STM32F4
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
#define BOARD_DEVICE_RHPORT_NUM 0
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED)
#define CFG_TUSB_RHPORT1_MODE 0

I added this last line to solve for the high speed case... was this really the only way to solve it, and there is a problem with the library?

Piranha
Principal III
September 28, 2023

Again - look at the code and analyse why it is trying to use that CFG_TUSB_RHPORT1_MODE define. Most likely something else is still wrong.