sjackerman wrote on Saturday, December 15, 2012:
Working with FreeRTOS v7.1 and Rx62N port.
My application would run for several hours or up to a day then execute the BRK exception handler. I have removed and verified that there are no BRK instructions in my application.
Upon investigating after a invalid BRK exception, I found that somehow the pxCurrentTCB variable was being set to 2 instead of the address of a valid TCB. When this bogus pointer value was used to switch contexts the USP would point to an area of memory that was zeros - which, when excuted is the BRK instruction. All of the tasks stacks and interrupt stack appear to have plenty of room, and I have stack checking enabled.
Using my Renesas E1 emulator I set a event breakpoint for a write to the pxCurrentTCB address with a value of 2. The event captured this bogus write at the end of vTaskSwitchContext() called from within vSoftwareInterruptISR(), prvYieldHandler() at the MVTIPL #1 instruction.
253 void vSoftwareInterruptISR( void )
254 {
255 prvYieldHandler();
FFFE89B0 7FA8 _vSoftwa SETPSW I
FFFE89B2 7EAF PUSH.L R15
FFFE89B4 FD6A2F MVFC USP,R15
FFFE89B7 60CF SUB #0CH,R15
FFFE89B9 FD68F2 MVTC R15,USP
FFFE89BC E00F MOV.L ,
FFFE89BE E50F0101 MOV.L 04H,04H
FFFE89C2 E50F0202 MOV.L 08H,08H
FFFE89C6 62C0 ADD #0CH,R0
FFFE89C8 7FA9 SETPSW U
FFFE89CA 6E1E PUSHM R1-R14
FFFE89CC FD6A3F MVFC FPSW,R15
FFFE89CF 7EAF PUSH.L R15
FFFE89D1 FD1F0F MVFACHI R15
FFFE89D4 7EAF PUSH.L R15
FFFE89D6 FD1F2F MVFACMI R15
FFFE89D9 6D0F SHLL #16,R15
FFFE89DB 7EAF PUSH.L R15
FFFE89DD FBF2740E0100 MOV.L #00010E74H,R15
FFFE89E3 ECFF MOV.L ,R15
FFFE89E5 E3F0 MOV.L R0,
FFFE89E7 757004 MVTIPL #4H
FFFE89EA 05BCC7FF BSR.A _vTaskSwitchContext
FFFE89EE 757001 MVTIPL #1H <- this is where the pxCurrentTCB=2 event occurred.
FFFE89F1 FBF2740E0100 MOV.L #00010E74H,R15
FFFE89F7 ECFF MOV.L ,R15
FFFE89F9 ECF0 MOV.L ,R0
FFFE89FB 7EBF POP R15
FFFE89FD FD171F MVTACLO R15
FFFE8A00 7EBF POP R15
FFFE8A02 FD170F MVTACHI R15
FFFE8A05 7EBF POP R15
FFFE8A07 FD68F3 MVTC R15,FPSW
FFFE8A0A 6F1F POPM R1-R15
FFFE8A0C 7F95 RTE
FFFE8A0E 03 NOP
FFFE8A0F 03 NOP
FFFE8A10 02 RTS
256 }
It looks like perhaps the listGET_OWNER_OF_NEXT_ENTRY(pxTCP, &(pxReadyTasksLists ) is returning an incorrect value ? The value of uxTopReadyPriority = 2 and the contents of pxReadyTasksLists is:
ADDRESS LABEL +0 ASCII
0001046C _pxReadyTasksLi 00000001 ….
00010470 000079A4 .y…
00010474 FFFFFFFF ….
00010478 000079A4 .y…
0001047C 000079A4 .y…
00010480 00000003 ….
00010484 0000B2FC ….
00010488 FFFFFFFF ….
0001048C 0000980C ….
00010490 0000A55C \…
00010494 00000001 ….
00010498 0001051C ….
0001049C FFFFFFFF ….
000104A0 0000ACF4 ….
000104A4 0000ACF4 ….
000104A8 00000000 ….
000104AC 000104B0 ….
000104B0 FFFFFFFF ….
000104B4 000104B0 ….
000104B8 000104B0 ….
Any ideas on how to track this down ? I’ve been trying to debug this for several weeks.
Steven J. Ackerman, Consultant
ACS, Sarasota, Florida
http://www.acscontrol.com