FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [July 2007 Threads] prefetch abort when scheduler startsPosted by andy on July 27, 2007 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:
LDRR0, =pxCurrentTCB LDRR0, [R0] LDRLR, [R0] LDRR0, =ulCriticalNesting LDMFDLR!, {R1} STRR1, [R0] LDMFDLR!, {R0} MSRSPSR, R0 LDMFDLR, {R0-R14}^ NOP LDRLR, [LR, #+60] SUBSPC, 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.
RE: prefetch abort when scheduler startsPosted by Richard on July 28, 2007 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.
RE: prefetch abort when scheduler startsPosted by andy on July 29, 2007 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.
RE: prefetch abort when scheduler startsPosted by andy on July 30, 2007 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.
RE: prefetch abort when scheduler startsPosted by Dave on July 30, 2007 Which Hitex port was that? Can you provide a link?
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|