I'm trying to do a bootloader that jumps to an application. The following is what I've done so far:
- Created a bootloader project that configures the some peripherals and blink some LEDs. This works fine.
- Created a user application project that I want my bootloader to jump to (I'm not interested in loading from external source like SPI or UART yet; I just force app binary into flash and expect to jump to there).
The user application doesn't execute correctly. When I step through my bootloader I can see it jumping to the address I specify for the user application 0x00020000.
When I step past my application start address of 0x00020000 I run into undefEntry (at address x4). This may be because my bootloader project doesn't have symbols for my application, but I'm not sure. Regardless, my application doesn't continue to execute even when I simply power up and expect it to run. Note that my application doesn't configure any devices - it just tries to write to a GPIO, the same one the bootloader configured and successfully used. Correct me if I need to reinitialize any peripherals after bootloader does it and jumps to app.
The following are my linker scripts. As you can tell I'm trying to locate my user application at 0x00020000. I've tried converting both boot and app output to raw binary and loading them at address 0x0 and 0x00020000 respectively and it doesn't make a difference. The bootloader always runs OK, but not the app. I'll appreciate any help in debugging this or addressing anything I missed.
BOOT_LINKER.cmd
/*----------------------------------------------------------------------------*/
define memory mem with size = 4G;
define region VECTORS = mem:[from 0x00000000 size 0x00000020];
define region FLASH = mem:[from 0x00000020 size 0x0017FFE0]
| mem:[from 0x00180000 size 0x00180000];
define region STACK = mem:[from 0x08000000 size 0x00001500];
define region RAM = mem:[from 0x08001500 size 0x0003eb00];
define block HEAP with size = 0x800, alignment = 8{ };
initialize by copy {readwrite};
do not initialize {section .noinit};
place in VECTORS {readonly section .intvecs};
place in FLASH {readonly};
place in RAM {readwrite};
place in RAM {block HEAP};
/*----------------------------------------------------------------------------*/
APP_LINKER.cmd
/*----------------------------------------------------------------------------*/
define memory mem with size = 4G;
define region VECTORS = mem:[from 0x00020000 size 0x00000020];
define region FLASH = mem:[from 0x00020020 size 0x0017FFE0]
| mem:[from 0x00180000 size 0x00180000];
define region STACK = mem:[from 0x08000000 size 0x00001500];
define region RAM = mem:[from 0x08001500 size 0x0003eb00];
define block HEAP with size = 0x800, alignment = 8{ };
initialize by copy {readwrite};
do not initialize {section .noinit};
place in VECTORS {readonly section .intvecs};
place in FLASH {readonly};
place in RAM {readwrite};
place in RAM {block HEAP};
/*----------------------------------------------------------------------------*/