I've written a boot loader for the Atmel SAM4E device which is working to a point, it can receive new application code via SPI, erase flash and write to flash, but I don't understand how to execute the new application. I've learned the VTOR can be relocated, but I'm not sure how. (my application sits at address 0x00420000).I'm very new to writing code for ARM, so I'd appreciate any help.
Many thanks
Paul
Thank you for your reply.
I just tried using this code in my bootloader to reset the stack pointer and change the program counter;
// Jump to a foreign application as if it were a reset (load SP and PC)
//
extern void start_application(unsigned long app_link_location)
{
asm(" ldr sp, [r0,#0]");
asm(" ldr pc, [r0,#4]");
}
the function is then called like this ;
start_application(0x00420000);
the idea being that the stack pointer and correct start address are pulled from the applications VTOR.
The application on first start is still setting the VTOR to 0x00420000.
I still got "stack overflow 0"
Hello Paul,
how did you set the MSP (Main Stack Pointer)?
I think you'd better read the initial stack pointer value from 0x00420000 and set it to MSP.
Best regards,
Yasuhiko Koumoto.
So I found out how to relocate the VTOR;
SCB->VTOR = 0x00420000;
Problem is now finding the start vector, I believe it's held in address 0x00420004.
So reading that (manually) and jumping to it like this (hardcoded, I obviously need to make that dynamic) ;
void _JumpBootLoader(void)
__asm__ (
"b 0x00423c3d"
);
Almost works, the new program executes, but during the initialisation I get " -- Mstack overflow 0"
View all questions in Embedded forum