The problem is the Segger debug session reports "FreeRTOS maximum used priority is unreasonably big, not proceeding" and the debug session stops.
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 report of a problem that seems to have persisted for a couple of years.
Below are links to prior reports of this issue.
https://community.nxp.com/thread/457049 - Aug 2017
I have been able to solve this problem using the information at this link, https://community.nxp.com/thread/440321
My environment is:
Segger J-Link Pro, Version 6.44
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
The error message is found in this version of OpenOCD code.
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.
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.
I'll start with NXP as they consolidate FreeRTOS and Segger.
Hope you find this useful.