Odd behavior when bootloading FreeRTOS app

marshallmallow wrote on Monday, June 15, 2009:

I’ve written a boot loader for an ARM7 lpc2148.  The bootloader simply looks for a firmware file on an sd card and writes the file out to program memory.  It then starts execution of the firmware.  The firmware is the same as the orginal app, only the linker script designates program memory starting at address 0x20000.

When the bootloader starts execution of the app, I’m seeing some very odd behavior.  When the first task is run, if I step into each line of code,  everything works fine.  If I step over each line of code, then the first time I step over a function in the task, execution goes back to the bootloader.  I’m not seeing any kind of ARM exception such as data abort, execution just appears to restart at 0x0000.

Is there something I’m missing?  I don’t see why there would be any problem with what I’m doing.  Since all of the stacks are reinitialized when the app starts execution and the first task is actually starting, then why would there be a problem during the first function call?

Thanks for any insight.

davedoors wrote on Monday, June 15, 2009:

These problems are normally down to the vector table location. Where are you putting the vector table and how are you telling the mcu where it is? The ARM7 will attempt to read it from 0.

marshallmallow wrote on Monday, June 15, 2009:

You are indeed correct.  I stepped through until I hit a taskYield() and saw that execution dropped back to 0x0008 so the ARM7 is looking for the vector table at 0 as you said.  Apparently, stepping over function calls was giving FreeRTOS enough time to preempt the task I was looking at and perform a context switch.  I assume single stepping prevented the timer interrupt from being called enough to require a context switch.

Looks like I just need to map the interrupts to ram and copy them over for the bootloaded app.