cancel
Showing results for 
Search instead for 
Did you mean: 

Limitation of freeRTOS's stack size from main to maximum ~1480 bytes ?

ranran
Senior II

Hello,

I am trying to overcome some strange issue using IAR when starting freeRTOS thread from main.

I have used the following example for usb

\en.stm32cubeh7\STM32Cube_FW_H7_V1.3.0\Projects\STM32H743I_EVAL\Applications\USB_Host\HID_RTOS

It detects a HID automatically when inserting into board, and display information about it on LCD.

But when I started adding some threads, it suddeny stopped detecting the inserted device.

After some debugging, I've came to conculsion that it is a matter of stack size.

Even if I have only one thread (the usbtest thread) and I give it a large size then it fails:

- osThreadDef(USER_Thread, StartThread, osPriorityNormal, 0,

        128);

+ osThreadDef(USER_Thread, StartThread, osPriorityNormal, 0,

        1480);

I thought that stack size from main is a matter of changing in icf and rebuild :

-define symbol __ICFEDIT_size_cstack__ = 0x400;

+define symbol __ICFEDIT_size_cstack__ = 0x4400;

But surprisingly, it did not help !

Does anyone have any idea ?

Thanks,

ran

1 ACCEPTED SOLUTION

Accepted Solutions

Doesn't it allocate these dynamically from its own heap?​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4

Doesn't it allocate these dynamically from its own heap?​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Piranha
Chief II

Clive is right, it does. Each thread has it's own stack and those are not related to main stack.

ranran
Senior II

Hello,

I am not sure I understand the suggestion how to solve this issue.

Do you mean that I should increase configMINIMAL_STACK_SIZE ? I've tried that.

Please see main here:

int main(void)
{
  MPU_Config();
 
  CPU_CACHE_Enable();
 
  HAL_Init();  
 
  osThreadDef(EthThread, StartEthThread, osPriorityNormal, 0,  configMINIMAL_STACK_SIZE*2 );
  osThreadCreate (osThread(EthThread), NULL);
 
  osThreadDef(rxUART, UART_RxThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
  osThreadCreate (osThread(rxUART), NULL);
 
  osThreadDef(LOGGER, Logger_Thread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE*3 );
  LoggerThreadHandle = osThreadCreate(osThread(LOGGER), NULL);
 
  osKernelStart();
  /* We should never get here as control is now taken by the scheduler */
  for( ;; );
}

Thank you!

ranran

Piranha
Chief II