I wrote my own boot loader to program an allocated section in the flash memory. Erase and program seem to work, my code also performs a post updatezero checksum test for the particular mem section and it passes. I can also tell the program update works by viewing the memory window after update. However the micro failed to boot and run after power cycle.
So I re-ran the the update sequence. This time I noticed both Flash Option Register (FOPT) @ 0x40c and
Flash Security Register (FSEC) @ 0x40d now containing different settings, after the erase call (by invoking the stand API FlashEraseSector()) . Instead of 0x3ffe. they now read as 0xffff. According to the KL17 reference manual, 0xfe read of FSEC indicates MCU flash secure status. Would it prevent the micro from running?
FYI I took your suggestion and reprogrammed the two bytes after sector erase. It works.
Hi,
After had a brief look through the statement above, I found that the FOPT and FSEC registers become the different from the compete the first update after the second update sequence.
It seems very weird.
So I'd highly recommend that you can choose the integrated ROM bootloader in your implementation, instead of your own bootloader.
Wish it helps.
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
How to "program the appropriate bits in the NVM option byte"? If I can do that, I will able to ensure FOPT and FSEC registers reload the original settings properly after reset.
Hi Ming Jiang,
In my opinion, you should follow the kind of produce to configure the 0x40D and 0x40C field.
1. First of all, you'd better to load the whole bootloader code run in the RAM instead of flash.
2. Next, assure the 0x40D and 0x40C field are 0xFF, in another word, the field need to be erased previously before reprogram.
So you can use some kind of erase commands to achieve it.
3. Finally, reprogram the field and other erased area by using the program longword command.
Hope it helps.
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------