S32K118 How to correctly jump from Bootloader to App with S32K Design Studio

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K118 How to correctly jump from Bootloader to App with S32K Design Studio

Jump to solution
1,759 Views
melvinw
Contributor II

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. 

mwiegman_0-1670334403510.png

 

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:

  1. Am i missing something and is my main.c code correct? (See main.c)
  2. Are the settings, linker files, correct to jump to the application or do i need a different address? ( See linker files)
  3. How do you correctly jump to the application? 
  4. What steps need to be taken? (Maybe I'm forgetting something.)

Thanks for any help in advance!

What I'm using:

  • S32K Design Studio 
  • S32K118 SDK RTM 4.0.1 with two seperate hello world example project for a blinking LED.
  • Costume PCB with S32K118 MCU
  • Multilink Universal debugger/programmer with a SWD connection to the MCU.

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");
}
0 Kudos
1 Solution
1,726 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@mwiegman

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.

https://www.nxp.com/search?keyword=AN12218&start=0 

View solution in original post

0 Kudos
3 Replies
1,720 Views
melvinw
Contributor II

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?

 

0 Kudos
1,712 Views
Senlent
NXP TechSupport
NXP TechSupport

yes,your understanding is correct!

0 Kudos
1,727 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@mwiegman

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.

https://www.nxp.com/search?keyword=AN12218&start=0 

0 Kudos