What is the intended method of exiting the bootloader

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

What is the intended method of exiting the bootloader

Jump to solution
2,021 Views
nickdolling
Contributor IV

In my application I have an embedded host running the bootloader host based on the example.

I have successfully implemented a jump into the bootloader in my target application, however once the host is done updating the target, what is the intended method for getting the target to restart?

If I look at the examples (both the embedded one and the Kinetis Updater windows application), it appears the host issues a Reset command, however looking at the source for the v1.2 bootloader (the KL17 I am using has ROM bootloader K1.1.0, which I assume is probably close enough), the reset command leaves the FORCEROM bits in the RCM set, which causes it to restart back into the bootloader.... does this just then assume that the peripheral detection will timeout and eventually cause a "proper" reset to start the application?

I tried using the Execute command to jump the normal Reset_Handler, but the bootloader source seems to think this is invalid and returns an error... 

Which leaves me wondering.... what is the intended method for exiting the bootloader when done?

Why is jumping to the normal Reset_Handler not a valid option?

Nick

1 Solution
1,701 Views
ramboyang
NXP Employee
NXP Employee

Hi Nick,

If the MCU boots from ROM, it can exit ROM if one of below conditions meets:

1. Boot pin is not asserted, active peripheral detection time out and application is valid

2. Users call execute command and forcely jump to application. 

Regarding your case, it looks like that the stack pointer in your case exceed the valid memory range. ROM considers the valid address of SRAM like [start, start + ram_size -1], while in some linker file, the sp base is at <start + ram_size>, so ROM treat it as invalid address, please try to update the linker file, and set the sp base to <start + ram_size -4>.

Hope it helps.

View solution in original post

4 Replies
1,701 Views
nickdolling
Contributor IV

Ok... so I've found the source for version K1.1.0 and it is slightly different, but with essentially the same end result..

The handle_reset function doesn't even call the cleanup function, just goes straight to NVIC_SystemReset, which doesn't clear the FORCEROM flag, so it ends up back in the bootloader.

The original question still stands.

1,702 Views
ramboyang
NXP Employee
NXP Employee

Hi Nick,

If the MCU boots from ROM, it can exit ROM if one of below conditions meets:

1. Boot pin is not asserted, active peripheral detection time out and application is valid

2. Users call execute command and forcely jump to application. 

Regarding your case, it looks like that the stack pointer in your case exceed the valid memory range. ROM considers the valid address of SRAM like [start, start + ram_size -1], while in some linker file, the sp base is at <start + ram_size>, so ROM treat it as invalid address, please try to update the linker file, and set the sp base to <start + ram_size -4>.

Hope it helps.

1,701 Views
nickdolling
Contributor IV

This did the trick... thank you!

It might be helpful for the demo application to actually demonstrate how it's meant to be done :smileyhappy:

Nick

1,701 Views
nickdolling
Contributor IV

Hi Fan Yang,

Thank you for your reply.

It's possible that the SP value I was passing was out of range as you suggest, I will check.

The Embedded Host Demo or the Kinetis Updater application use neither of the methods above but instead just send a Reset command to the bootloader target when done.... does this just rely on the peripheral detection timeout to get back into the user application?

Nick