Jump from bootloder to Application

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

Jump from bootloder to Application

3,686 Views
ambarishhundeka
Contributor III

Hi NXP team,

I am using S32K144 controller in our project.

I am facing some problems with " jump to application from boot loader".

my application may starts from 0xA000 or 0x9000 address as per our requirement.

 

Problem 1:

code is

 

JumptoApp(T_U32 *ptr)

   DISABLE_INTERRUPTS();

      asm("ldr r0,=0x0000A000");

      asm("blx r0");

 

}

__attribute__((section (".App_codearea"))) void Application(void)

{

int b;

b = 10;

while(1);

// ENABLE_INTERRUPTS();

 

}

 

.App_codearea section starts from 0x0000A000;

If I run the above code , then it goes to default isr, it is not jumping to application.

if I use asm("bl 0x0000A000") it is jumping to the application address.

if I load the PC with 0x9000 address also , it jumps to application and goes to default ISR.

why above code is not jumping to application? 

 

Problem 2 :

 

could you please tell me how to load the other registers with  pointer value?

 

JumptoApp(T_U32 *ptr)

{

//how to load the register with pointer value (passed as input argument to this function)

    asm("ldr r1, ptr"); ????

}

address 0xA000 (or 0x9000)  application entry point -  Application() function start address.

yes, by default S32DS projects start with IRQ, flash config etc, as you mentioned it in the above reply and it jump to main(changed to BLC_Main()).

 

I have created the App_codeArea section in the linker file , placed the Application() code to the App_codeArea section.

Application() starts from the 0x0A000.

 

 

I need to copy App start address to some register( Application start address is not fixed, OX0A000 or 0x09000) and jump to the register address.

 

facing problems with blx and loading the address to PC , it goes to f\default isr.

Regards,

Ambarish.

5 Replies

2,163 Views
klau
Contributor II

Hi All,

I am having the same problem.

Could someone please share the solution?

I have verified that I have flashed the bootloader and application correctly on the MCU at the same time.

Both the bootloader and application co-exist on the same chip.


The program fails if I start the bootloader first at 0x0000, and the program works if I start the application first at 0x3000.

Thanks,
Kevin

0 Kudos

2,163 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

 

Cortex M4 supports only thumb instructions. When BX <Rm> or BLX <Rm> instructions are used for jump, the LSB of the register used in a BLX operation must be set to 1 because the Cortex-M4 processors only support the Thumb state. The LSB bit says if the code will be executed in thumb state or in ARM state. So, if you load immediate value, there must be 0x0000A001 instead of 0x0000A000.

 

If you pass one word as a parameter to function, r0 is used to pass the parameter to function. If you pass a pointer to int as a parameter and if you want to load a value where the pointer points to, then use:

 

JumptoApp(T_U32 *ptr)

 

{

    asm("ldr r0, [r0]");

    …

}

 

Regards,

Lukas

2,163 Views
mangeshk
Contributor II

Hi,

My Application starting address is 0xD000 and below are the routine which i am using.

#define APP_START_ADDRESS 0xD000

//***************************************************************************************************

main()

{

   .......

JumpToUserApplication(*((uint32_t*)APP_START_ADDRESS), *((uint32_t*)(APP_START_ADDRESS + 4)));

   .......

}

//***************************************************************************************************
void JumpToUserApplication( unsigned int userSP, unsigned int userStartup)
{
/* Check if Entry address is erased and return if erased */
if(userSP == 0xFFFFFFFF){
return;
}

/* Set up stack pointer */
__asm("msr msp, r0");
__asm("msr psp, r0");

/* Relocate vector table */
S32_SCB->VTOR = (uint32_t)APP_START_ADDRESS;

/* Jump to application PC (r1) */
__asm("mov pc, r1");
}

//************************************************************************************************************

Still ni am facing issue related to switching from bootloader to application.

Please help me on above issue.

Thanks,

Mangesh

0 Kudos

2,163 Views
ranshalit
Senior Contributor I

Hello Ambarish,

Is it finally resolved ?

How did you eventually implemet the jumping ?

Thank you!

ranran

0 Kudos

2,163 Views
ambarishhundeka
Contributor III

Hi Lukas,

Thank you for your support.

I will check and update you.

Regards,

Ambarish

0 Kudos