AnsweredAssumed Answered

KL03 ROM Bootloader fails if application contains FTFx Flash Driver

Question asked by John Doe on Jan 3, 2017
Latest reply on Jan 3, 2017 by jeremyzhou

I am having an issue with the KL03 becoming bricked if power is lost during transfer of the application to flash via the ROM bootloader.  If power is lost, the only way to upload the application is via the debugger.  One way around this is to always have the device start in bootloader mode by setting the Flash Option boot source bit to "Boot from ROM".  However, always booting from ROM draws too much current for our ultra low power application.  I would like to have a bit of code at the beginning of the application, that checks if the application was successfully uploaded, then check if the Boot from ROM source is set.  If it is, then set the source to Flash.

 

To do this, I have the main program start at 0x800.  Then, I copy 0x400 to 0x7FF to a RAM buffer, change the boot source bits to the desired setting, then copy the RAM buffer to flash.  The flash driver I'm using are the "Standard Software Flash Driver For FTFx" contained in the flash writing examples.

 

This procedure works fine if I copy and run the application using the debugger.  I can see the bits change and the rest of the program runs as expected.  The issue I'm having is that if I try uploading this application via the Kinetis bootloader, the bootloader only copies the first 1024 bytes and then it hangs.  If I comment out the one function that contains the flash reading and writing, I'm able to upload the application using the bootloader just fine.

 

Does anyone have any suggestions on what to do?  Thanks!

Outcomes