cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX FreeRTOS USB and USB_CoreInit function

Ryan Stephen
Associate II
Posted on January 20, 2017 at 17:05

Hi

I used STM32CubeMX and configured a project using RTOS and USB_DEVICE (I am trying to run the USB CDC functionality with the FreeRTOS). The program runs until it hits the USB_CoreInit function inside stm32f4xx_hal_pcd.c file and then something bizarre occurs, it hangs and when i hit pause in EWARM the program counter is somewhere random. If i comment out the function the RTOS runs fine but obviously then the USB still doesn't work.

Has anyone had a similar issue?

Thanks

Ryan

6 REPLIES 6
Nesrine M_O
Lead II
Posted on January 20, 2017 at 17:58

Hi

stephen.ryan

,

Try to increase heap and stack sizes. Then, please let me know if it is OK with this suggestion.

-Nesrine-

Posted on January 23, 2017 at 09:33

Hi

ELMHIRI.Syrine

Thank you for your reply,

Is there an option for increasing these in cubeMX? I have tried increasing the stack size for the RTOS task allocated to USB and have also increased the heap and stack size within the linker configuration. I notice that whenever I rebuild the cubeMX project it returns the heap and stack size back to their default value. Is there a minimum heap size for the USB?

Many thanks

Ryan

Ryan Stephen
Associate II
Posted on January 23, 2017 at 12:19

As it turns out it determined the issue was to do with enabling low power mode. I disabled that and it is now working. But it does jump to the vApplicationStackOverflowHook function. Which should I increase? the stack for the RTOS or increase the linker stack information?

Many thanks

Posted on January 23, 2017 at 11:43

Hi

Stephen.Ryan

,

  • Is there an option for increasing these in cubeMX?

0690X000006062FQAQ.png

  • Is there a minimum heap size for the USB?

    maybe you can refer to USB example under the STM32CUBE F4 package : STM32Cube_FW_F4_V1.0\Projects\STM32469I_EVAL\Applications\USB_Device

-Nesrine-

Stephen.Ryan wrote:

Hi

ELMHIRI.Syrine

Thank you for your reply,

Is there an option for increasing these in cubeMX? I have tried increasing the stack size for the RTOS task allocated to USB and have also increased the heap and stack size within the linker configuration. I notice that whenever I rebuild the cubeMX project it returns the heap and stack size back to their default value. Is there a minimum heap size for the USB?

Many thanks

Ryan

Posted on January 23, 2017 at 11:44

A little further investigation shows that it actually isnt hanging, Looking in the call stack I can see that an interrupt handler 'OTG_FS_WKUP_IRQHandler' is invoked whilst in USB_CoreInit, it also shows '<Exception frame>' but when it is in the interrupt handler it tries to call the SystemClock_Config() again which is what is hanging on line: ' if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)'

Posted on January 24, 2017 at 11:19

Thank you for your help

ELMHIRI.Syrine

‌, i increased the stack and heap sizes further and the device operates without a driver failed to start error which i was seeing before. The low power mode of the USB seem'd to crash the program, out of interest how would one implement the low power mode? is there a function which should invoke a power up/ low power mode enable?