S32K312 Bootloader jump to application address

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

S32K312 Bootloader jump to application address

1,686 Views
Vishnu3
Contributor III

Hi all,

I have been trying to develop a UART bootloader for the S32K312 evaluation board. My project has the following components:

1. Bootloader project with UART (Using RTD 3.0.0)

2. Application project (just a LED blinky) (Using RTD 3.0.0)

3. UART python utility to send the SREC file.

Step 1:

Generate an SREC file from application project. I have configured the linker file in this project with the pflash origin=0x00500000 with a length of 32 Kb. I make no other changes in the linker file or startup code. I get an SREC file which has 24bit address.

Step 2:

I configure the bootloader project with the linker file as follows pflash origin = 0x00400000 with a length of 64Kb. In the bootloader I have setup the UART to receive the SREC file and write it to flash (using c40 ) at the corresponding memory address with 16 byte alignment. Once the SREC file is completely received, the bootloader jumps to the address 0x0050000 (start address of the app).

 

Outcome:
1. My utility is able to send the SREC file line by line and the bootloader is writing it to the flash successfully. I checked the memory address and the data matches with that of the SREC file.

2. The bootloader jumps to the application address, but stops executing when the program reaches 0x00500800. Gives the error that is attached in the picture below. 

MicrosoftTeams-image.png

0 Kudos
Reply
4 Replies

1,484 Views
Vishnu3
Contributor III

Hi Vane,

Sorry for the long pause. I was able to use the code that you had provided (thanks a ton for that) and my bootloader is jumping to the application address (0x00500000). In the application I am blinking an LED in a while loop and it is executing properly. However, now there is a new issue:

 

When I added UART callback in my application code, along with the blinking LED, it works fine when I am testing it by flashing it into my board using Design Studio. However when I flash it through my bootloader and jump to the application, the LED blinks, however, the UART callback is not triggered. I suspect that the IVT is not being initialized properly and thus the UART callback is not working.

Following is my jump to application code: [Using RTD 2.0.0]

void Jump(uint32 address_location){

 

  uint32 ADDR_APP = address_location;
  Intrrupt_DeInit();
  __asm("cpsid i");
  S32_SCB->VTOR =ADDR_APP;

 

  __asm("ldr  r0, =0x00500000");
  __asm("msr msp, r0");

 

  func = *(uint32 volatile *)(ADDR_APP + 0xC);
  func = *(uint32 volatile *)(((uint32)func) + 0x4);
  func = (((uint32)func) & 0xFFFFFFFEU | 1U);
  (* (void (*) (void)) func)();
}

 

My application linker file is set to start at 0x00500000. This is the only change I have made in the application project (the one with LED and UART). I have not made any changes to the startup code. 

Any pointers will be really appreciated. Been at it for almost a week now. This is the only blocking point in my application  




0 Kudos
Reply

1,667 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @Vishnu3 

To jump from the bootloader to the application I suggest referring to the Unified Bootloader Demo. There is Boot_JumpToApp(const uint32 i_AppAddr) in boot_Cfg.c (S32K344_CAN_Bootloader_RTD100\src\S32K344_CAN\boot\src\)

Also, you can try the following code:

func = *(UINT32 volatile *)(ADDR_APP + 0xC);
func = *(UINT32 volatile *)(((UINT32)func) + 0x4);  //add this line of code.
func = (((UINT32)func) & 0xFFFFFFFEU);
(* (void (*) (void)) func)();

Additionally, check the following post. This is a discussion related to the topic. 

How to jump to the application from the bootloader after updating an image in S32K312.

 

B.R.

VaneB

0 Kudos
Reply

1,665 Views
Vishnu3
Contributor III

Hi Vane,

Thank you for the response. My code is able to jump to the specified address (0x00500000) however it is not able to execute the instruction at 0x00500800, as I have pointed out in the attached picture in my original post. Also, I have already gone through the discussion that you have pointed me to. 

Best,

 

Vishnu

0 Kudos
Reply

1,637 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @Vishnu3 

Please correct me if I understood wrong. The below situation occurs just after jumping from the bootloader to the app. Is that correct? In the following post, a similar situation has been discussed. 

bootloader jump to app

Also, if you debug the code, can you detect if a specific instruction causes the fault? 

0 Kudos
Reply