Quality RTOS & Embedded Software

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


Loading

prefetch abort when scheduler starts

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

Regards.

RE: prefetch abort when scheduler starts

Posted 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 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.
cheers,
Andy.

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 ]    [ Privacy ]    [ Sitemap ]    [ ]


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner