implement my own rt685 bootloader cant jump to application

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

implement my own rt685 bootloader cant jump to application

845 Views
Henry2
Contributor II

recently i have implement a bootloader for rt685, it just jump to application code, but something stuck

i put my bootloader at 0x8002000, and the application at 0x8015000(but i want it to run at ram),  the code may look like

int main(void) {
  uint32_t *app_code = (uint32_t *)0x8015000;
  uint32_t app_sp = app_code[0];
  uint32_t app_start = app_code[1];
  start_app(app_start, app_sp);
}
static void start_app(uint32_t pc, uint32_t sp) __attribute__((naked)) {
    __asm("           \n\
          msr msp, r1 /* load r1 into MSP */\n\
          bx r0       /* branch to the address at r0 */\n\
    ");
}
MEMORY
{
m_flash (RX) : ORIGIN = 0x08015000, LENGTH = 0x00200000
m_interrupts (RX) : ORIGIN = 0x00080000, LENGTH = 0x00000130
}
/* The startup code goes first into internal ram */
.interrupts :
{
. = ALIGN(4);
__VECTOR_TABLE = .;
__Vectors = .;
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} > m_interrupts AT> m_flash

I have some question:
1. is there any mistake about my code and linker script
2. if the application is going to run in ram, which address such i load (0x8015000 or 0x00080000)

 

Labels (1)
Tags (1)
0 Kudos
Reply
1 Reply

839 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
To provide the fastest possible support, I'd highly recommend you to refer to the jump_to_application() function which is from the evkmimxrt685_ota_bootloader demo in the SDK library, to implement the jumping application operation.

void jump_to_application(uint32_t imageStart)
{
    typedef void (*application_callback_t)(void);
    static uint32_t s_stackPointer;
    uint32_t applicationPointer;
    static application_callback_t s_appCallback;

    uint32_t *vectorTable = (uint32_t *)imageStart;

    s_stackPointer = vectorTable[0];
    applicationPointer = vectorTable[1];

    if (is_valid_application_location(applicationPointer))
    {
        debug_printf("Application address=%x\r\n", applicationPointer);
        s_appCallback = (application_callback_t)applicationPointer;
        // Set the MSPLIM to 0 to avoid potential stack related issues after jumping to the user application, the user
        // application can re-configure the SPLIM in the startup code
        __set_MSPLIM(0u);
        __set_MSP(s_stackPointer);
        s_appCallback();
    }
    // Fixed the stack popping issue before calling s_appCallback()
    __DSB();
    __ISB();
}


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply