2024-04-09 01:53 PM
Hi,
I would like to setup a system with a telnet server and I'm trying to follow this guide: https://controllerstech.com/stm32-ethernet-4-tcp-server/ but unfortunately, upon launch, the system gets stuck at line1438 in queue.c:
/* Cannot block if the scheduler is suspended. */
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
}
#endif
it's a bit odd because it appears like when I don't change the MEM_SIZE variable but leave it its default (1600) it appears to not be stuck after creation of the config but once I change it to 10*1024 (as it's shown in the link above) I do not seem to be able to undo it anymore but it keeps getting stuck on call to MX_LWIP_Init(). Why is this I'm wondering and how can I fix it?
2024-04-09 02:17 PM
The code gets 'stuck" in queue.c because some function is waiting for a queue (or mutex) with a non-zero "wait" param BEFORE the FreeRTOS scheduler has started (osKernelStart() called). That is not allowed - as the comment says, tasks cannot be suspended if the scheduler is not (yet) running.
Where in MX_LWIP_Init() is the code getting "stuck"? Use the debugging tools, trace/step through the function.
If you are using dynamic allocation for your tasks, mutexes, queues, etc. then you definitely need to set MEM_SIZE much larger than the default 1600. I don't know what you mean by "do not seem to be able to undo it anymore".
2024-04-10 06:21 AM - edited 2024-04-10 06:33 AM
Hm? I've set MEM_SIZE to 10240 B now, would that be sufficient?
My application is empty at the moment, I just configured the empty framework in CubeIDE. I haven't modifed anything in the init sequence and my StartDefaultTask() function only looks like this:
void StartDefaultTask(void const * argument)
{
/* init code for LWIP */
MX_LWIP_Init();
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END 5 */
}
the init sequence is:
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
and the call stack when it hangs looks like this:
What I see is happening is:
any hints on how I can fix this? I've attacghed the empty project as *.7z file
2024-04-10 09:57 AM
Do you call osKernelInitialize()?
2024-04-10 01:47 PM
> Do you call osKernelInitialize()?
No, I don't see it being called anywhere but when I look at the implementation in cmis_os.c on line 141, it just shows the prototype without any content in the function:
/*********************** Kernel Control Functions *****************************/
/**
* @brief Initialize the RTOS Kernel for creating objects.
* @retval status code that indicates the execution status of the function.
* @note MUST REMAIN UNCHANGED: \b osKernelInitialize shall be consistent in every CMSIS-RTOS.
*/
osStatus osKernelInitialize (void);
not sure abou this, looks like it might have been kept for backwards compatibility or something?
2024-04-17 01:57 PM
Are you using CMSIS ver 1 or ver 2? In cmsis_os2.c that function is defined and initializes the RTOS heap regions and sets the kernel state (which is needed by osKernelStart()). I can't speak to CMSIS ver 1, never used it.