2019-01-20 02:08 AM
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
Solved! Go to Solution.
2019-01-20 03:35 AM
Doesn't it allocate these dynamically from its own heap?
2019-01-20 03:35 AM
Doesn't it allocate these dynamically from its own heap?
2019-01-20 09:25 AM
Clive is right, it does. Each thread has it's own stack and those are not related to main stack.
2019-01-24 01:46 AM
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
2019-01-24 03:01 PM
And read the FreeRTOS FAQ link provided there.