I'm creating my first bootloader with the S32K118 processor and i can't seem to correctly jump to my application.
What I'm trying to do is first flash my application on the MCU with a debug configuration. After that i flash my bootloader without erasing the application. When running my bootloader runs without problems but, when it tries to jump to the application i opens a new tab in IDE and stops the debugger at a breakpoint at address 0x346c.
Which if I'm looking at the .map file of my application is my reset handler? (See mapfile) But i doesn't execute any code. When it runs without debugger it seems to hang at the same point without executing the application.
Questions i have:
Thanks for any help in advance!
What I'm using:
main.c:
#define APP_RESET_ADDRESS 0x00003410
Boot_JumpToApp(APP_RESET_ADDRESS);
void Boot_JumpToApp(const uint32_t i_AppAddr)
{
if((*((uint32_t*)i_AppAddr)) != 0xFFFFFFFF)
{
/* Relocate vector table */
S32_SCB->VTOR = (uint32_t)0x00003000;
JumpToUserApplication(*((uint32_t*)i_AppAddr), *((uint32_t*)(i_AppAddr + 4)));
}
}
void JumpToUserApplication( unsigned int userSP, unsigned int userStartup)
{
/* Set up stack pointer */
DISABLE_INTERRUPTS();
__asm("msr msp, r0");
__asm("msr psp, r0");
ENABLE_INTERRUPTS();
/* Jump to application PC (r1) */
AppAddr resetHandle = (AppAddr)(userStartup);
(resetHandle)();
//__asm("mov pc, r1");
}
Solved! Go to Solution.
I checked the files your provided:
this function:Boot_JumpToApp(APP_RESET_ADDRESS);
the APP_RESET_ADDRESS should be 0x00003000 insteaded of 0x00003410
we have some application note for customer to know the bootloader process,you can refer to AN12218.
I attached the links for you.
Hello @Senlent ,
I tried your suggestion and this was indeed the solution, it's now jumping to the application!
I saw the document you are referring to but, this document only describes how you could do it with a described address. Nowhere in here is described why you use this specific address or how you could use a different one based on your requirements. It was helpful though!
If i understand it correctly the steps that are needed to jump to the application are as followed:
1. Set de Vector table address to the "m_interrupts" Origin adress of the application linker file.
2. Disable interrupts
3. Set the stack pointer the same address
4 Enable interrupts
5. Jump to application "m_interrupts" Origin address.
Is this correct or are there steps unneeded?
yes,your understanding is correct!
I checked the files your provided:
this function:Boot_JumpToApp(APP_RESET_ADDRESS);
the APP_RESET_ADDRESS should be 0x00003000 insteaded of 0x00003410
we have some application note for customer to know the bootloader process,you can refer to AN12218.
I attached the links for you.