Booloader to Application jump

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

Booloader to Application jump

1,073 Views
aniketmarkande
Contributor III

Hi,

I am working on MK22 series controller. After flashing new code via custom usb bootloader, i am not able to jump to application.

code is as follows:

#define APP_START_ADDRESS             0x50000

#define __API_JMP_APPLICATION  (*((const void(*)(void))APP_START_ADDRESS))

void start_application(unsigned long app_link_location)
{
    __asm(" ldr sp, [r0,#0]");
    __asm(" ldr pc, [r0,#4]");
    __API_JMP_APPLICATION();
}

void Jump_To_Application(void)
{
    extern uint32_t __FBL_APP_HANDSHAKE;
    /* handshake signal */
    __FBL_APP_HANDSHAKE = 0x55EEAAB8;
    /* disable interrupt */
    INT_SYS_DisableIRQGlobal();
    /* deinitialize the hardware peripherals */
    Boards_HardwareDeInit(g_etBoard_t);
    /* deinit the clock */
    Boards_ClockDeInit();
    /* jump to application */
    start_application(APP_START_ADDRESS);
}

USB is not deinitialized before jumping.

Kindly let me know whats wrong.

Thank you in advance.

Regards,

Aniket

Labels (2)
0 Kudos
2 Replies

619 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Aniket,

There are several mistakes in the start_application().  Please refer to the NXP_Kinetis_Bootloader_2_0_0. You can download from NXP web site and extract it. 

The related code is in bl_main.c. There is a function named get_user_application_entry(). This function get the stack address and app entry address from applcation image.

The other useful function is jump_to_application().

You can follow these code or reuse them in your project.

Regards

0 Kudos

619 Views
aniketmarkande
Contributor III

hi,

modified code as follows.

void start_application(unsigned long app_link_location)
{
    uint32_t stackPointer = APP_VECTOR_TABLE[kInitialSP];
    uint32_t applicationAddress = APP_VECTOR_TABLE[kInitialPC];
    static uint32_t s_stackPointer = 0;
    s_stackPointer = stackPointer;

    static void (*farewellBootloader)(void) = 0;
    farewellBootloader = (void (*)(void))applicationAddress;

    // Set the VTOR to the application vector table address.
    SCB->VTOR = (uint32_t)APP_VECTOR_TABLE;

    // Set stack pointers to the application stack pointer.
    __set_MSP(s_stackPointer);
    __set_PSP(s_stackPointer);

    // Jump to the application.
    farewellBootloader();
}

when i dump led blinking program using bootloader, it works fine.

but when i dump my application  using bootloader, it does not work, please guide me, what might be worng?

Regards,

Aniket

0 Kudos