Bootload doesn't launch application

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

Bootload doesn't launch application

733 Views
MarcoGiammarini
Contributor III

Dear all,

I'm working on bootloader over KL27. I put the bootloader at address 0x0, and the application at 0x4000.

After I write the new application into flash memory, I try to restart the application by pointing to application startup address, but it fail and restart the code from 0 (from the bootloader).

The launch code is the following. Is it correct?

Any ideas?

Thanks

Marco

appStartAddress = APPLICATION_START_ADDRESS;
p_appStartAddress = (uint32_t *) appStartAddress;

// Read the first location of application section
// which contains the address of stack pointer.
// If it is 0xFFFFFFFF then the application section is empty.
if (*p_appStartAddress == 0xFFFFFFFF)
{
    while (1)
    {
                // Wait indefinitely
    }
}

// Start address is valid...
// Pointer to the Application Section
void (*applicationCodeEntry)(void);

// Rebase the Stack Pointer
__set_MSP(*(uint32_t *) APPLICATION_START_ADDRESS);

// Rebase the vector table base address
SCB->VTOR = ((uint32_t) APPLICATION_START_ADDRESS & SCB_VTOR_TBLOFF_Msk);

// Load the Reset Handler address of the application
applicationCodeEntry = (void (*)(void))(unsigned *)(*(unsigned *)(APPLICATION_START_ADDRESS + 4));

// Jump to user Reset Handler in the application
applicationCodeEntry();

 

Labels (1)
Tags (2)
0 Kudos
3 Replies

721 Views
nxf56274
NXP Employee
NXP Employee

Hi,

You can refer this link. bootloader

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 days 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

714 Views
MarcoGiammarini
Contributor III

Dear @nxf56274 

with the code suggested in the post, the MCU reset immediately with LOCKUP bit high.

What's wrong?

Best,

Marco

0 Kudos

699 Views
nxf56274
NXP Employee
NXP Employee

Hi,

Please use the led demo as application. And show me how you go to application.

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 days 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