Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


prefetch abort when scheduler starts

Posted by andy on July 27, 2007

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]
LDRR0, =ulCriticalNesting
STRR1, [R0]
LDMFDLR, {R0-R14}^
LDRLR, [LR, #+60]

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 = ( portSTACK_TYPE ) 0xaaaaaaaa;/* R14 */
*pxTopOfStack = ( portSTACK_TYPE ) pxOriginalTOS; /* Stack used when task starts goes in R13. */
*pxTopOfStack = ( portSTACK_TYPE ) 0x12121212;/* R12 */
*pxTopOfStack = ( portSTACK_TYPE ) 0x11111111;/* R11 */
*pxTopOfStack = ( portSTACK_TYPE ) 0x10101010;/* R10 */
*pxTopOfStack = ( portSTACK_TYPE ) 0x09090909;/* R9 */
*pxTopOfStack = ( portSTACK_TYPE ) 0x08080808;/* R8 */
*pxTopOfStack = ( portSTACK_TYPE ) 0x07070707;/* R7 */
*pxTopOfStack = ( portSTACK_TYPE ) 0x06060606;/* R6 */
*pxTopOfStack = ( portSTACK_TYPE ) 0x05050505;/* R5 */
*pxTopOfStack = ( portSTACK_TYPE ) 0x04040404;/* R4 */
*pxTopOfStack = ( portSTACK_TYPE ) 0x03030303;/* R3 */
*pxTopOfStack = ( portSTACK_TYPE ) 0x02020202;/* R2 */
*pxTopOfStack = ( portSTACK_TYPE ) 0x01010101;/* R1 */

/* When the task starts is will expect to find the function parameter in
R0. */
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */

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!



RE: prefetch abort when scheduler starts

Posted 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?


RE: prefetch abort when scheduler starts

Posted by andy on July 29, 2007

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. */

I'll check what the debugger says about the mode tomorrow. Thanks,

RE: prefetch abort when scheduler starts

Posted 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.

RE: prefetch abort when scheduler starts

Posted by Dave on July 30, 2007
Which Hitex port was that? Can you provide a link?

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

Meet us at Embedded World. Hall 3A-525.

Hear from Richard Barry at Embedded World. Feb 28, 16:00, Hall 4-428.

Video: Watch James Gosling & Richard Barry at re:Invent, Las Vegas 2017.

FreeRTOS kernel V10.0.1 is available for immediate download. Now MIT licensed.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS