This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How can I jump to flash address? NRF51422

Hi,

I have problem while jumping to another application (address) in flash code region.

I placed first app at 0x00000000 address and the second at 0x00002800 what I want to do is just to jump from first addess to second and execute the second app. Both applications are without softdevice.

When I execute this code with start_addr = 0x00002800, first program start over again. Why not the socond one?

__asm void deinit_system(uint32_t start_addr)
{
    LDR   R2, [R0] 							  ; Get App MSP.
    MSR   MSP, R2                ; Set the main stack pointer to the applications MSP.
    LDR   R3, [R0, #0x00000004]  ; Get application reset vector address.
    BX    R3                     ; No return - stack code is now activated only through SVC and plain interrupts.
    ALIGN
}
  • Look at the generated assembler. Depending on which compiler you are using, writing what you wrote with no 'naked' keyword and no extended syntax may not actually start with start_addr in R0 but add a preamble which uses it. The compiler is also at liberty to assume start_addr isn't used at all and not bother to set it.

    You'd be better off writing this with the extended syntax, something like appending : : r (start_addr) and then using %0 instead of R0 in the code

Related