What should be the Jump address while jumping from Boot to App

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

What should be the Jump address while jumping from Boot to App

Jump to solution
2,100 Views
Kamran
Contributor II

Hello All,

 

I am new to bootloader programming.

Currently I am trying to create a basic boot loader which will jump to application on S32K144. I have both bootloader and application flashed on the ECU.

I tried to jump on Address 0x00014200 (start of interrupts) and 0x00014600 (start of code) but none of them worked.

Also I tried to make bootloader jump on the address of main() function still no luck.

What address should I make the bootloader jump to?

I have reserved fist 80KB for bootloader and then the remaining for application. (Linker screenshot below)

Application Linker file:

Kamran_1-1606835849358.png

 

Bootloader Linker file:

Kamran_0-1606835733762.png

 

What am I missing?

Kindly help!

1 Solution
1,997 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello @Kamran,

1.-

API MSP: __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );

API PSP:  __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );

The PSP and MSP should point to the start of the application address.

2.-

Cast for API:

static void (*farewellBootloader)(void) = 0;
farewellBootloader = (void (*)(void))applicationAddress;

This should point 4 bytes after the start of the application address.

Best Regards,

Alexis Andalon

View solution in original post

0 Kudos
3 Replies
2,033 Views
Kamran
Contributor II

Hello Alexis,

 

Thank you for the information.

 

I have some doubts in the steps mentioned:

1. I have modified the VTOR, but I don't know how to modify the Main Stack Pointer and Process Stack pointer.

      a. Are there any assembly level commands that I need to use to modify them?

      b. What address should be loaded in the Main Stack Pointer and Process Stack pointer?

2. Define the API and Call it to jump

     a. Does this imply to type cast jump address and use it as a function to jump to the Application?

 

Apart from this I have one query, what if I create an API of the application Reset Handler address and jump to it? (Without modifying the VTOR  and other pointers)

Will that work and is it leagl to do so?

 

Best Regards,

Kamran

0 Kudos
1,998 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello @Kamran,

1.-

API MSP: __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );

API PSP:  __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );

The PSP and MSP should point to the start of the application address.

2.-

Cast for API:

static void (*farewellBootloader)(void) = 0;
farewellBootloader = (void (*)(void))applicationAddress;

This should point 4 bytes after the start of the application address.

Best Regards,

Alexis Andalon

0 Kudos
2,037 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Kamran,

Jump to the m_interrupts should be good since this is the first address in your application. So I think this could be a problem of how are you jumping from the bootloader, the usual process to jump to the application is the following:

  • Shutdown all the peripherals used in the bootloader
  • Modify the VTOR, Main Stack Pointer and Process Stack Pointer
  • Define the API to jump to the application and call it.

Best Regards,

Alexis Andalon