Quality RTOS & Embedded Software

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


return to main() for ARM ports

Posted by *anonymous on December 13, 2005

I thought I would share the following Idle Task hook that returns to main() when all tasks die. Feedback is welcome.

You could turn off the Tick ISR here or when back in main().

This assumes all allocated queues have been freed by the tasks themselves before they are deleted (or delete themselves) with vTaskDelete().

Also assumes this function is compiled as ARM code (say in portISR.c). Untested for return to Thumb code although I think it is correct.

void    vApplicationIdleHook(void) { __static bool     die = false;         _// when only the idle task remains, we may need one last pass of the idle _// task to free resources of last application task, and then we quit   __if (die) __{ // return to old context at end of vPortISRStartFirstTask()

____die = false; ____asm volatile ( "msr   cpsr_c,#0xD3");    // back to supervisor state ____asm volatile ( "ldmia sp, {r11,sp,lr}"); // restore regs for return ____asm volatile ( "bx    lr");              // and return __}     __else if (uxTaskGetNumberOfTasks()==1) __{ // only the idle task remains. so ____// die on next pass after all deleted task TCBs are sure to be freed     ____die = true; __} }

return to main() for ARM ports

Posted by nobody on December 13, 2005

Neat....maybe this should be the default behaviour for vPortEndScheduler() in port.c, which is at the moment "not implemented for the arm".

return to main() for ARM ports

Posted by racemouse on July 10, 2007


I quess it's time to revive this old thread...

We use FreeRTOS in a bootloader. When the bootloader's job is finished we need to stop the scheduler and jump to a different location where the main application starts. When trying to compile the "new" vPortEndScheduler (which I moved to portISR.c for compilation in ARM Mode) I get the following junk thrown at me:

/cygdrive/c/DOCUME~1/RFI~1.LOD/LOCALS~1/Temp/cczKqAza.s: Assembler messages: /cygdrive/c/DOCUME~1/RFI~1.LOD/LOCALS~1/Temp/cczKqAza.s:12: Error: flag for {c}psr instruction expected -- `msr CPSR_C,#0xD3' /cygdrive/c/DOCUME~1/RFI~1.LOD/LOCALS~1/Temp/cczKqAza.s:14: Error: bad instruction `sbx LR' make[1]: *** [Source/portable/GCC/ARM7_AT91SAM7/portISR.o] Error 1

I have no idea what this means. Can someone help me here ?


return to main() for ARM ports

Posted by racemouse on July 10, 2007

Hmmm... My fault. One spelling error and one letter that should not be versal but was... Works now :-)


[ 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