Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


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) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists