Skip to main content
Associate III
June 13, 2025
Question

threadx does not allow BSP code to initialize

  • June 13, 2025
  • 2 replies
  • 488 views

with a standard project with only threadx and bsp code added via STM32CubeMX code generates the MX_ThreadX_Init function in main.c but the BSP initialization functions are below this call.

MX_ThreadX_Init actually starts the kernel task switching (unlike FreeRTOS) so it never returns ... BSP init code is never reached.

Workaround is to move the BSP init code to the user block above the call to MX_ThreadX_Init in main.c.

This should be fixed in MX code generation. 

2 replies

Andrew Neil
Super User
June 13, 2025

Another work around could be to have CubeMX not generate the initialisation calls at all - then you can put them into whatever sequence you like.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
dvescoviAuthor
Associate III
June 13, 2025

Unfortunately, that kind of defeats the whole purpose of using STM32CubeMX.... I want to do less work ... not more.;)

Andrew Neil
Super User
June 14, 2025

Agreed - but it is a workaround.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Technical Moderator
June 13, 2025

Hello @dvescovi 

Thank you for posting!
The CubeMX team is aware of this problem (as tracked by internal ticket number 196205) and it will be resolved as soon as possible.

BR,

Souhaib

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.