AnsweredAssumed Answered

Jumping to user application from custom bootloader

Question asked by Alex Ferreirós on Dec 4, 2015
Latest reply on Oct 12, 2017 by Utsav Kumar



I'm coding a bootloader and a MQX user application using KSDK and KDS on a KL27 custom board. I've followed this awesome guide to properly change the linker files (.ld) so the bootloader was placed at 0x00000000 and the main application at 0x00004000.

After looking up in the .map file, I saw the "Reset_Handler" symbol was placed at address 0x0000442D. This way, my bootloader is able to successfully jump to the user application with this piece of code:


__asm("bl 0x0000442D");


So far so good. The issue is that I wouldn't like to hardcode that address in bootloader's code

I've seen in other threads a common approach to do that, but I couldn't make it work and I don't know why (wouldn't be a valid approach for my specific MCU?). The thing is that this snippet fails in my case:


#define USER_APP_ADDRESS   0x00004000

void JumpToUserApplication(uint32_t userSP, uint32_t userStartup) {
  __asm("msr msp, r0");
  __asm("msr psp, r0");
  __asm("mov pc,  r1");

JumpToUserApplication(*((unsigned long*)USER_APP_ADDRESS), *((unsigned long*)(USER_APP_ADDRESS+4)));


Does anybody know what could be wrong or knows other ways to jump to the user application without hardcoding its entry point address?


Best regards,