occasional data abort with freertos and lpc22

I am using lpc2214 and FreeRTOS now, and I meet a problem. My system include two uart task, one flash led task and a LCD dispaly(touchscreen)task. Interrupt include two uart, timer1 and ext3. When using heap_1.c and I don’t delete a task or queue (one task create queue when task run), it some times(several hours or several minutes) enter the data abort mode. From the LR, I find it go to exception from vListInsertEnd() function and read a invalid address from stack of IRQ. When I change to use heap_2.c, this problen haven’t appeared for one  day test. So I an confused! Any reply would be appreciated. Thank you!

occasional data abort with freertos and lpc22

Have you checked that your stack is not overflowing? That is the most common cause. Other than that there could be a memory corruption somewhere that is clobbering the data structures.

occasional data abort with freertos and lpc22

You don’t say which compiler you are using, but are you writing you interrupt service routines exactly as described on the documentation page for the port you are using?  This is especially relevant if you are using GCC.  The demo application will provide an example that can be followed too. Regards.

occasional data abort with freertos and lpc22

Yes, I am sure that the task stack is not overflowing and I also write my interrupt service routine exactly as described on the documentation page for the port. I am using winarm. Testing for another day, it doesn’t happen. I have modified some insignificant parts of the code. I am really confused. I also think that there would be a memory corruption somewhere that is clobbering the data structures. But it’s very hard to find. Thanks for your replies.

occasional data abort with freertos and lpc22

Icefishhead, One problem I had with the ARM7 and GCC that was very hard to find: GCC has a bug that only appears under the following conditions: thumb  mode and "omit frame pointer = no". So, in my case the solution was to turn on "omit frame pointer". The compiler generates code that corrupts registers (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32838). Good luck!

occasional data abort with freertos and lpc22

Sorry, the link was broken: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32838

occasional data abort with freertos and lpc22

The problem with using omit frame pointer is that debugging can be tough due to debugger’s inability to properly unwind the stack. I have a ‘fix’ to FreeRTOS for ARM7 that allows use of ‘omit frame pointer = no’. In macro portSAVE_CONTEXT() in file portmacro.h you need to open up some space on the stack where FreeRTOS places the task context so the any stack data that might be clobbered by the context due to the flakey compiler code is in the space and hence is not clobbered. I add: SUB    R0, R0, #32 (with the appropriate syntactic sugar for the macro generation) just before the comment /* Push the return address onto the stack. */ This opens up 32 bytes just before the first item (return address) is put on the stack with STMDB  R0!, {LR} The 32 bytes was determined empirically… I have no way to know if this is the maximum amount that the flakely compiler code ever places the stack pointer behind to true top of stack. I have never had a problem since settling on 32 bytes. There is no need to strip this off the stack in portRESTORE_CONTEXT() because the existing code takes care of it. Glen