STM32CubeIDE Integration #633
-
I've been able to build/make the tinyusb examples for various targets (including STM32), but, I am completely lost in figuring out how to integrate it into happily building in an existing project in STM32CubeIDE. I will probably figure it out eventually and when I do I will post the details into this discussion since there doesn't seem to be a reference anywhere on the general Internet. If somebody already knows how and wants to assist to help speed things up that would also be cool :) Update: I have figured out how to do this finally; however it's 5:30am and I'm going to sleep 🙃 I'll answer the question tomorrow |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 11 replies
-
I have recently done this with microchip IDEs and really meant to make a blog post and just haven't had time. What you should start out doing is either include tinyusb as a sub module and initialize it recursively or copy tinyusb into your project folder. Then I go into an example for the type of device I am making and open the makefile. I then look for all the spots a makefile is included and open those. Then go one by one copying over any include lines that you find throughout these make files into a separate text file. Then in STM32CUBE there should be a way to edit project include folders, start adding in all the directories. Then do the same with all the c files. You want to add then as a link though, I am not sure how stm32cube has you do that. (You just don't want it to copy the file to where you are adding it, which atmel studio will do). This is definitely something that is easier to see done than read but I hope this was at least somewhat helpful. |
Beta Was this translation helpful? Give feedback.
-
The procedure:
// ^^^ <...> omitted stuff above, generic C language boilerplate crap, see any example in tinyusb
#define CFG_TUSB_MCU OPT_MCU_STM32H7
#define CFG_TUSB_OS OPT_OS_NONE
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED // 480mbps
#define BOARD_DEVICE_RHPORT_NUM 1
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)
// In the case of the STM32H7 with an external HS 480 PHY, you must use root hub port 1 instead of 0
// 0 is for the internal FS 12mbit PHY so you'd use BOARD_DEVICE_RHPORT_NUM set to 0 and CFG_TUSB_RHPORT1_MODE set to (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED)
// vvv<...> (see tinyusb examples for remainder, configuring USB Class and buffer size basics)
There may be a cleaner way to do this. It might not be necessary to use the USB initialization code provided by ST at all and let tinyusb handle that; however I haven't tested that yet. Will update post in the future. I wrote this from memory, will double check when I make a new project with this procedure sometime soon. |
Beta Was this translation helpful? Give feedback.
-
successfully added library to CubeIDE without HAL generation (for BluePill f103)
|
Beta Was this translation helpful? Give feedback.
-
I could use some pointers on getting my STM32L433 custom board working with MSC & CDC tinyUSB. I followed the instructions above and I have the project building. The USB global interrupt is enabled and the addition to call the tinyUSB handler were made. However, the interrupt is never raised. Any pointers to debugging this would be very much appreciated. |
Beta Was this translation helpful? Give feedback.
-
@MimitechIndustries @viteo I could use some help here. I am a first-time user of tinyUSB and at this time I am stuck :( This is all the log output I see: 00> USBD init on controller 1 |
Beta Was this translation helpful? Give feedback.
-
@viteo I have created a new project based upon the msc_cdc example to try to learn more about tinyUSB. TThe first issue I see in my project is that the "USV" bit is not getting set in PWR->CR2. I have search the code and do not find any reference to this. This suggest I am missing some code somewhere. |
Beta Was this translation helpful? Give feedback.
-
I made an example repository integrating the TinyUSB and CDC dual ports example from TinyUSB to STM32 Nucleo F446RE board. It follows the steps from @MimitechIndustries answer and may be useful for someone starting out with TinyUSB on STM32 |
Beta Was this translation helpful? Give feedback.
The procedure: