I’ve spent weeks grinding my way through getting FreeRTOS to actually run on the secondary M0 core of the LPC4350. First was getting the RGU_RESET register polarity right, then determining that NXP neglected to put a SysTick timer on the M0 and completely failed to mention this rather fundamental fact in the documentation.
At this point I have a “port” of FreeRTOS that will compile and run directly on the main M4 via openocd and gdb. It replaces SysTick with LPC’s RITimer, and successfully runs two tasks with vTaskDelay() that flash LEDs. A debug LED confirms that the FreeRTOS RITimer interrupt handler is indeed running as it should.
FWIW, I have my linker script set to keep everything in SRAM, at 0x10000000. The MEMMAP register for the M4 is set to that (remapping 0x00000000 to 0x10000000) and runs from there.
Now, I recompile it to target the M0, which means changing compiler parameters as well as the interrupt table (though I can actually cheat since the RITimer is in the same vector slot, and the M4’s vector table is longer so it just “wastes” the extra vectors). The M4 loads the binary image into 0x10000000, set’s the M0APP REMAP to that address, and starts up the M0.
At this point, I get the two tasks running and toggling their LEDs, then a set of RITimer interrupts toggling it’s debug LED. However, as soon as the first timer expires, the M0 halts. My first attempt at keeping RITimer running was to comment out the trigger of the PendSVC interrupt in xPortSysTickHandler (renamed to xPortRITimerHandler in my “port”), but strangely that didn’t do it. I had to comment out the entire block that ran xTaskIncrementTick() and checked its output in order for the RITimer not to stop running.
Any idea why moving working code from the M4 to the M0 would fail like this? Also, any idea how I can actually get GDB working in such a way as to debug the M0? As it stands I’ll have to move around LED debugging lines in order to try to track down what’s going on, and that gets old fast.
I’ll post code snippets as requested because there’s a lot going on.