return to main() for ARM ports

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

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

Greetings, 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 ? /RaceMouse

return to main() for ARM ports

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