freertos hanging on vListInsert

Hi All, I think you will nail my problem easily I am still new to FreeRTOS, and my program is hanging always in the same line of code after random times (minutes or hours), generally with ethernet traffic. I am using Cortex-M3 from luminary, with lwip raw. The code always hangs on this line: for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) in vListInsert , filename: list.c pxIterator->pxNext points to itself, so it hangs there. As this code is "inside" freeRTOS, what could have causing this? Where should I look for? Thank you very much, and sorry if it is a stupid question. Sergio P. Sider

freertos hanging on vListInsert

Just by reading the subject of your post I would guess you are using a Cortex M3 and have your interrupt priorities wrong.  I would say though – read the comment directly above the line that is crashing.  I have replicated it below for your convenience. /* *** NOTE *********************************************************** If you find your application is crashing here then likely causes are: 1) Stack overflow –    see http://www.freertos.org/Stacks-and-stack-overflow-checking.html 2) Incorrect interrupt priority assignment, especially on Cortex M3    parts where numerically high priority values denote low actual    interrupt priories, which can seem counter intuitive.  See    configMAX_SYSCALL_INTERRUPT_PRIORITY on http://www.freertos.org/a00110.html 3) Calling an API function from within a critical section or when    the scheduler is suspended. 4) Using a queue or semaphore before it has been initialised or    before the scheduler has been started (are interrupts firing    before vTaskStartScheduler() has been called?). See http://www.freertos.org/FAQHelp.html for more tips.         **********************************************************************/         for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) Regards.

freertos hanging on vListInsert

HI RIchard, Thanks… I think my version is outdated, because these comments do not exist on my version… I will check it all (all I know for now it´s not a stack overflow). Thanks again, Sergio Sider.

freertos hanging on vListInsert

Hi I am having the exact same problem. Code stays in the for loop and never comes out. I was also suspicious about the stack overflow but that is not the case. In my system, other than operating system tasks, I have one UART task and 5 more tasks with priority 1. Other than uart task, all other tasks just suspend the execution with vTaskDelay. One final note is, just like Sergio’s code, my FreeRTOS code doesn’t have the comments shown by Richard. Thanks a lot.

freertos hanging on vListInsert

With the risk of just repeating myself "Just by reading the subject of your post I would guess you are using a Cortex M3 and have your interrupt priorities wrong".  Neither respondent has indicated whether this is the case or not.  Without further information all I can do is give you the same advice as the original poster. Regards.

freertos hanging on vListInsert

Hi Richard, I just confirmed that was the interrupt priority as you suggested. I forgot to set the interrupt priority of one of my interrupt handlers, so it defaults to ‘whatever’ and this handler was calling a API function. BTW, I will update my version to the current one… I probably would not have to bother you if I the comments were there… ;-) Thanks again!!! Sergio P. SIder

freertos hanging on vListInsert

I tried another way and it worked too. If you are not sure about the priorities of your system yet, set configMAX_SYSCALL_INTERRUPT_PRIORITY to 0. Which will disable interrupt masking. The function that uses configMAX_SYSCALL_INTERRUPT_PRIORITY is xPortPendSVHandler. The inliner assembler will look like this: … … … mov r0, %0 msr basepri, r0 bl vTaskSwitchContext mov r0, #0 msr basepri, r0 ldmia sp!, {r3, r14} … … … where %0 is configMAX_SYSCALL_INTERRUPT_PRIORITY. Setting configMAX_SYSCALL_INTERRUPT_PRIORITY to 0 will execute the same instruction (msr basepri, r0) twice. Also, I haven’t seen a usage of configKERNEL_INTERRUPT_PRIORITY variable other than assigning to a constant variable in GCC port file. Thanks Richard!