FreeRTOS maximum used priority is unreasonably big, not proceeding

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • FreeRTOS maximum used priority is unreasonably big, not proceeding

      [This issue was also posted at the NXP Community Forum under MCUXpresso IDE]
      community.nxp.com/message/1148845

      The problem I am having is the Segger debug session reports "FreeRTOS maximum used priority is unreasonably big, not proceeding" and the debug session stops.

      My environment is:

      Segger J-Link Pro, Version 6.44
      IDE: MCUXpresso 10.3.1
      Target MCU: MK22FN1M0Axxx12
      RTOS: Amazon FreeRTOS 10.0.1
      Microsoft Windows 7
      The default setting for configUSE_PORT_OPTIMISED_TASK_SELECTION is 1, thus FreeRTOS uses the 'ported' code to select the next task.
      Using RTOS Plugin: GDBServer/RTOSPlugin_FreeRTOS


      When the debug session stops, the debugger is configured to let the application run.
      When I 'attach' to the application it has run properly. The application is not hung.

      This appears to be a problem with the debug session.

      This is a problem that seems to have persisted for a couple of years.

      Below are links to prior reports of this issue.

      community.nxp.com/thread/457049 - Aug 2017
      https://forum.segger.com/index.php/Thread/4704-ABANDONED-FreeRTOS-plugin-under-Eclipse-crash/ - Dec 2017
      https://github.com/espressif/openocd-esp32/issues/7 - Mar 2017

      I have been able to solve this problem using the information at this link, community.nxp.com/thread/440321

      The error message is found in this version of OpenOCD code.
      http://openocd.org/doc-release/doxygen/FreeRTOS_8c_source.html

      There has been a report of OpenOCD not working correctly with uxTopUsedPriority missing from FreeRTOS.
      sourceforge.net/p/openocd/mailman/message/33274231/

      In the OpenOCD code, the FreeRTOS OpenOCD variable uxTopUsedPriority is part of the test that generates the error.

      From the Segger J-Link debug console is the following:

      Loading RTOS plugin: GDBServer/RTOSPlugin_FreeRTOS...
      RTOS plugin (API v1.0) loaded successfully
      RTOS plugin initialized successfully.
      Received symbol: pxCurrentTCB (0x20007FA0)
      Received symbol: pxReadyTasksLists (0x20007FA4)
      Received symbol: xDelayedTaskList1 (0x200080E4)
      Received symbol: xDelayedTaskList2 (0x200080F8)
      Received symbol: pxDelayedTaskList (0x2000810C)
      Received symbol: pxOverflowDelayedTaskList (0x20008110)
      Received symbol: xPendingReadyList (0x20008114)
      Received symbol: xTasksWaitingTermination (0x20008128)
      Received symbol: xSuspendedTaskList (0x20008140)
      Received symbol: uxCurrentNumberOfTasks (0x20008154)
      Received symbol: uxTopUsedPriority (0x00000000)
      Received symbol: uxTopReadyPriority (0x2000815C)
      Received symbol: vPortEnableVFP (0x000500D8)
      Received symbol: FreeRTOSDebugConfig (0x00000000)
      All mandatory symbols successfully loaded.


      Notice that uxTopUsedPriority is zero.
      Also FreeRTOSDebugConfig is zero, but don't know if it relates to any issue.

      The list of symbols above is used in the OpenOCD code referenced above.
      [I don't know if Segger is using OpenOCD, but the correlation with OpenOCD is interesting.]

      The solution shown above (/thread/440321) states that one should add the following code, along with updates to FreeRTOS_Config.h.
      [The link to the code solution is broken, but it's not difficult to figure it out.]


      int uxTopUsedPriority=configMAX_PRIORITIES; // Probably should be added to tasks.c


      The error occurs in the macro prvAddTaskToReadyList() in tasks.c of FreeRTOS.

      The instruction that generates the error message is:


      str R3, [R2,#0] // R3 = 0x85, R2 = 0x2000815c = &uxTopReadyPriority


      The value of (R3 + 1) is the value reported with the error message.


      /*-----------------------------------------------------------*/
      /*
      * Place the task represented by pxTCB into the appropriate ready list for
      * the task. It is inserted at the end of the list.
      */
      #define prvAddTaskToReadyList( pxTCB ) \
      traceMOVED_TASK_TO_READY_STATE( pxTCB ); \
      taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \
      vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \
      tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
      /*-----------------------------------------------------------*/



      This macro has successively created the first and second threads in my application. Tmr Svc and Idle task are also created.

      I'm not sure who is responsible for fixing this problem, FreeRTOS, Segger, or NXP.

      Hope you find this useful.