prefetch abort when scheduler starts
Hi,
I’m using your nice clean freeRTOS code, having heard very good things about it. But I’m stuck. I have read the FAQs and documents and so on and I haven’t yet found out what I’m doing wrong. Apologies for the long post but it’s usually best to get as much info as possible in …
I’ve been trying to get a simple demo running on an LPC2368. This has been hacked together from bits of the Rowley LPC2368 demo and bits of the GCC LPC2106 demo and I’m using the WinARM gcc(arm-elf) toolchain.
Everything seems to work ok right up until the point where I call vTaskStartScheduler(). Then it tries to do a portRESTORE_CONTEXT() on the first task:
LDR R0, =pxCurrentTCB
LDR R0, [R0]
LDR LR, [R0]
LDR R0, =ulCriticalNesting
LDMFD LR!, {R1}
STR R1, [R0]
LDMFD LR!, {R0}
MSR SPSR, R0
LDMFD LR, {R0-R14}^
NOP
LDR LR, [LR, #+60]
SUBS PC, LR, #4
as I understand it, the task creation sets up the stack so that the task can just do a restore and be ready to go. What’s actually on the stack is 0x01010101, 0x02020202 … and so on, in my case R13/sp has a sensible value (0x400002c0 or something like that). But it loads 0xaaaaaaaa into the link register and tries to do something with that. This is what is set up in the pxPortInitialiseStack:
*pxTopOfStack = ( portSTACK_TYPE ) pxCode + portINSTRUCTION_SIZE;
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0xaaaaaaaa; /* R14 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) pxOriginalTOS; /* Stack used when task starts goes in R13. */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x12121212; /* R12 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x11111111; /* R11 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x10101010; /* R10 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x09090909; /* R9 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x08080808; /* R8 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x07070707; /* R7 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x06060606; /* R6 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x05050505; /* R5 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x04040404; /* R4 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x03030303; /* R3 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x02020202; /* R2 */
pxTopOfStack–;
*pxTopOfStack = ( portSTACK_TYPE ) 0x01010101; /* R1 */
pxTopOfStack–;
/* When the task starts is will expect to find the function parameter in
R0. */
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */
pxTopOfStack–;
So unless I’m supposed to do any further initialization of the task stack after this, I don’t see how the context restore will work. I didn’t have -fomit-frame-pointer and I didn’t have it boot in supervisor mode, but now I’ve done that and still the same thing happens. Since I’ve copied as much code as I can, I think I’m doing the task setup and start correctly.
Any suggestions gratefully received, and feel free to abuse me if I’m being thick!
cheers,
Andy.
prefetch abort when scheduler starts
Problems with the link register when starting the first task is normally a symptom of the processor not being in Supervisor mode. Can you show the code you use to switch to Supervisor mode, or alternatively, use the debugger to confirm that you are in Supervisor mode when portRESTORE_CONTEXT is called?
Regards.
prefetch abort when scheduler starts
Hi,
I put this in after the stack setups and before the .bss zeroing, which is where it lives in boot.s
/* We want to start in supervisor mode. Operation will switch to system
mode when the first task starts. */
msr CPSR_c, #MODE_SVC|I_BIT|F_BIT
I’ll check what the debugger says about the mode tomorrow. Thanks,
Andy.
prefetch abort when scheduler starts
well it’s working now. I was probably doing a few stupid things but being in the right processor mode helped. I also looked at the Hitex port for LPC2378.
cheers,
Andy.
prefetch abort when scheduler starts
Which Hitex port was that? Can you provide a link?