I’m troubleshooting a problem with task creation in freeRTOS, Atollic TrueStudio, STM32.
In the first call of xTaskCreateStatic() the code runs into an error: “Invalid selected thread”. When debugging I can see that the pxNewTCB gets initialized correctly in prvInitialiseNewTask( ). But in prvAddNewTaskToReadyList( ) the code breaks at the assignment of pxNewTCB to pxCurrentTCB:
static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
{
/* Ensure interrupts don't access the task lists while the lists are being
updated. */
taskENTER_CRITICAL();
{
uxCurrentNumberOfTasks++;
if( pxCurrentTCB == NULL )
{
/* There are no other tasks, or all the other tasks are in
the suspended state - make this the current task. */
pxCurrentTCB = pxNewTCB;
...
I couldn’t find something related to this problem in the freeRTOS or STM/Atollic forum but something that looks similar in the openstm32 forum http://www.openstm32.org/forumthread2824 …but it didn’t help me.
I double checked the task settings, priority, stack size,… but I don’t find something that looks wrong.
If I deactivate the first taks creation (call of the xTaskCreateStatic() ) it gets stuck at the second (or now first) call of xTaskCreateStatic().
Any ideas what might cause the problem and how to solve it?
If I shall post more stuff, please let me know!
I’m using TrueStudio V9, freeRTOS V9, basic code generated with CubeMX(V4.25.1), Debugger j-link Ultra+.
an addition; I was experimenting with the Debug Config.
When I deactivate Thread-aware RTOS support (No RTOS), debugging the code seems to work. I can still debug RTOS for SEGGER SysView. The code runs good, didn’t find something unexpected yet. Anyway I can’t tell why this could be a problem, because I got the “extra” expression…
thread 2
continue
…in my Startup Script. But if this is the best solution, I will do it like that.
Next experiment:
When I deactivate Thread-aware RTOS support AND Trace System (I use SWV), the code runs into assertion. It then seems to mess up with SystemView, because when I deactivate SystemView (not calling SEGGERSYSVIEWConf() ), the code is running without problems.
Well, at least I found a workaround to be able to keep on working. But still I have the feeling that there must be something horrible wrong in the project…maybe somebody has an idea with this new information?
For some reason my reply to your first post, some ten hours ago, never showed up here. It was:
I’m afraid your description isn’t really clear enough for me to determine what the issue you are reporting is.
In the first call of /xTaskCreateStatic()/ the code runs into an error: “Invalid selected thread”.
Where is this error, by which I mean how did you determine that was the error?
When debugging I can see that the /pxNewTCB/ gets initialized correctly in /prvInitialiseNewTask( )/. But in /prvAddNewTaskToReadyList( )/ the code breaks at the assignment of /pxNewTCB/ to /pxCurrentTCB/:
What is meant by the code ‘breaking’? Does it crash, and if so, how does that crash occur? Is it related to the “Invalid selected thread” error from above?
I double checked the task settings, priority, stack size,… but I don’t find something that looks wrong.
If I deactivate the first taks creation (call of the /xTaskCreateStatic()/ ) it gets stuck at the second (or now first) call of /xTaskCreateStatic()/
Do you have configASSERT() defined so it checks the size of the static task structure against the non static task structure? If you have something like configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES defined then the structures could be different sizes, which would cause a problem.
thanks for the reply. I’ll try to answer your questions.
The problem, however, is that the error is gone. I can’t reproduce it right now. I jumped back in my code history when it occured but I can’t trigger it now…must be evil black magic.
The error was outputted on the debugging console. The code crashed and I was able to isolate it to the assignment mentioned above (pxCurrentTCB = pxNewTCB). The scheduler didn’t start at that point yet, it was all during initialization.
At the moment it’s hard to tell you more as I cannot reproduce it. configASSERT() is defined, configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is not defined (gets defined to 0 in projdef.h by default).
I will try to reproduce the error and make more and detailed tests if it occurs.