Manual jump to user code

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

Manual jump to user code

669 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by chiong.lai on Tue Jun 03 23:26:29 MST 2014
Hello,

I have implemented a bootloader, a main app for M4 and another main app for M0  to be run on lpc4337, all from internal flash bank A. When the device is power up or reset, it will first run the bootloader at address 0x1A000000. My issue is when I want to jump from bootloader to M4 main app at 0x1A010000, it stopped running (most likely the ISR). From my understanding, I need to setup the VTOR, SP and PC for the proper jump to my M4 main app. Can anyone please provide some guidance?

Removing the bootloader and replace it with M4 main app at address 0x1A000000 works (both M4 and M0) running well.

Regards,
CC
Labels (1)
0 Kudos
3 Replies

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by chiong.lai on Wed Jun 04 20:49:21 MST 2014
Hello jonper and Holger,

Thank you very much for your reply. Both your answers work and have helped me a lot. I have successfully solved my issue. The problems are:
1. I did not __enable_irq() after the jump, which causes my IRQ handlers not being called
2. The SystemInit() from CMSIS library which I was using sets the VTOR register to some other value without me knowing.

Apart from those, I noticed that I also need to disable the individual ISR by setting the bits in all NVIC->ICER registers before the jump (most likely because I am using RITimer interrupt in my bootloader)

Other than those, all works now. Bootloader can now jump to M4 main app, which in turns setup M0 main app, and both cores running in parallel (both from same internal flash bank, but different sector).

Thanks again for your great guidance.

Regards,
CC

0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hlsa on Wed Jun 04 08:47:33 MST 2014
Hello CC,

that's how I am doing this:

#define APPL_ADDRESS   ((uint32_t)0x1B000000)   /* Application start address */

/* Function boot jump, which is called from where I want to jump (see below) */
void boot_jump( uint32_t address ){
   __asm__("LDR SP, [R0]");      // Load new stack pointer address
   __asm__("LDR PC, [R0, #4]"); // Load new program counter address
}


/* --> JUMP */
    SCB->VTOR = APPL_ADDRESS;           /* Change vector table address */
    LPC_CREG->M4MEMMAP = APPL_ADDRESS;  /* Change memory mapping */
    boot_jump(APPL_ADDRESS);            /* Jump to application */


[list]
  [*]Getting this to work was a long run. In my case I forgot to change the memory mapping in LPC_CREG->M4MEMMAP. Maybe you got the same problem.
  [*]In my case the APPL_ADDRESS is 0x1B000000. You'll need to change this to 0x1A010000.
[/list]

Best regards,
Holger
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jonper on Wed Jun 04 06:49:41 MST 2014
I have used the following function to orderly exit one well behaved LPCOpen M4 app and start another M4 app in a different memory area:

void JumpToAppAt(unsigned int * vtbp)
    {
    __disable_irq();
    __set_MSP(vtbp[0]);    // load SP
    ((void (*)(void)) vtbp[1])();   // go...
    }

You would call it using:
   JumpToAppAt((unsigned int *) 0x1A010000);

It disables interrupts and sets the starting SP and PC assuming a viable 43xx vector table as the target address. The LPCOpen ResetISR takes over and the startup code should stop and clear interrupts, then undo the interrupt disable. I've not tried this with a running M0 and would be interested to hear if that introduces complications.

Good luck
0 Kudos