Skip to main content
ranran
Senior
January 20, 2019
Solved

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

  • January 20, 2019
  • 4 replies
  • 2830 views

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

This topic has been closed for replies.
Best answer by Tesla DeLorean

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

4 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
January 20, 2019

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

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Piranha
Principal III
January 20, 2019

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

ranran
ranranAuthor
Senior
January 24, 2019

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
Principal III
January 24, 2019