2415516_en-US

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2415516_en-US

2415516_en-US

FreeRTOS system cannot run (cannot run immediately after creation)

After my project program was built according to the specifications, I found that it could not run on the FreeRTOS system (I have investigated and it is not a memory shortage issue, nor should it be a priority issue). My S32DS compiler version is shown in the image below.

sunshine88_0-1790130461254.pngsunshine88_1-1790130512616.png

sunshine88_2-1790130568712.png


The task failed to be created. Does this version not support FreeRTOS? Or are there any special configuration requirements?

sunshine88_3-1790132595523.png


Re: freertos 系统跑不通问题(创建即跑不通)

Hello @sunshine88 ,

The application is not actually stuck because of the sys_msleep(5000) call itself. The behavior indicates that the time base used by sys_now() is not incrementing. Therefore, the timeout condition inside sys_msleep() can never be reached.

In the OSIF configuration screenshot, OsIfUseSystemTimer is enabled and the operating system type is set to FreeRTOS. However, the references under OsIfCounterConfig_0, including the counter and system timer clock references, appear to be incomplete or empty. Adding the PIT component alone does not guarantee that the OSIF time base is correctly configured and initialized.

Please do not modify the TCP/IP Stack source code or implement another delay workaround at this point. Instead, I recommend the following:

  1. Import the original lwip_FreeRTOS_s32K358 example from the installed TCP/IP Stack package.
  2. Build and run the original example without any modifications.
  3. Check whether sys_now() increments in the original example.
  4. Compare the FreeRTOS, BaseNXP/OSIF, PIT, clock, interrupt, and TCP/IP Stack configurations with your custom project.
  5. Verify that the generated initialization sequence includes the required BaseNXP/OSIF and timer initialization.

We still need the information requested previously to analyze the custom project correctly:

  • the exact MCU part number;
  • the exact evaluation board or custom board;
  • the original example or project type used as the starting point;
  • whether the unmodified lwip_FreeRTOS_s32K358 example works on the same hardware;
  • the generated implementation of sys_now();
  • whether the FreeRTOS tick count returned by xTaskGetTickCount() is increasing.

Please first check xTaskGetTickCount(). If it increases while sys_now() remains constant, the FreeRTOS scheduler and tick interrupt are running, and the problem is specifically in the OSIF time-base configuration or initialization. If xTaskGetTickCount() also remains constant, the problem is more fundamental and the FreeRTOS tick interrupt or scheduler configuration must be investigated.

If possible, please also provide the complete project archive rather than configuration screenshots only. Without the generated configuration and initialization code, it is not possible to determine which timer or clock source is actually used by sys_now().

Best regards,

Pavel

Re: freertos 系统跑不通问题(创建即跑不通)

Hello, I have created an LWIP program routine, but the Ethernet mainLoopTask task is stuck at sys_msleep(5000); unable to delay. When I step into this function, I find that startTime = sys_now(); the sys_now() function cannot count. My current configuration page is as follows. What could be causing this? I'm very confused.



sunshine88_0-1790145231434.png

sunshine88_2-1790145441575.pngsunshine88_3-1790145507892.pngsunshine88_4-1790145535109.png



Re: freertos 系统跑不通问题(创建即跑不通)

Hello @sunshine88 ,

The versions shown in your screenshots should support FreeRTOS. S32 Design Studio 3.5 Update 14, RTD 4.0.0, FreeRTOS 4.0.0, and TCP/IP Stack 1.0.4 appear to be the expected package combination, so this does not look like a general version compatibility issue.

According to the code shown, the failure occurs directly in xTaskCreate(). Could you please provide the following information?

  1. The exact MCU part number and evaluation board or custom board being used. You previously mentioned S32K358, but please confirm the exact device and board.
  2. The name of the original example used as the starting point.
  3. The value returned by xTaskCreate().
  4. The value printed by xPortGetFreeHeapSize() before and after the xTaskCreate() call.
  5. The configured values of configTOTAL_HEAP_SIZE, configSUPPORT_DYNAMIC_ALLOCATION, and the selected FreeRTOS heap implementation, for example heap_4.c.
  6. The exact point where the application stops, including the debugger call stack if it enters an assertion, exception, or HardFault handler.

Please note that sufficient total MCU RAM does not necessarily mean that sufficient FreeRTOS heap is available. xTaskCreate() dynamically allocates both the task control block and the task stack from the FreeRTOS heap. Also, the 1024U stack-depth argument normally represents stack elements rather than bytes, so the actual allocation is larger than 1024 bytes on the Cortex-M7.

As a baseline test, I recommend importing and running the original lwIP FreeRTOS example without modifications. Once the original example works, please add the additional task with a small stack, a normal priority, and a vTaskDelay() call inside its loop. This will help distinguish an environment or board configuration problem from an issue introduced by the additional task.

I also noticed that your xTaskCreate() call uses a stack depth of 1024U, while the original working example uses 256U. Please restore the original value of 256U and test the unmodified example first. Note that this parameter specifies the number of stack elements, not the number of bytes, so using 1024U requires significantly more FreeRTOS heap.
 

Best regards,
Pavel

Tags (1)
No ratings
Version history
Last update:
Thursday
Updated by: