Error when writing flash from bootloader

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

Error when writing flash from bootloader

1,361 Views
alejandronavarr
Contributor I

Hi all,

I am developing an application to write contents to a Kinetis KL03 microcontroller by using the "write flash" command in bootloader mode via I2C bus. During system tests we have realized that sometimes the write command fails (due to a power-off, or a problem with the I2C bus, for instance), then it is possible to restore the firmware running on the KL03 by using an emulator.

Since our customers do not necessarily have an emulator, or the end devices may be installed in inaccessible environments, we want the flash write process to become self-recovering, even if it has to start over until it succeeds. However, once the write command has failed, we have found no way to recover it and make it start again, or even reset the bootloader.

Therefore I would like to know how it is possible to return the bootloader to a known, consistent state in order to continue with the write process (after re-erasing flash, if needed). Sometimes the bootloader seems to recognize its own slave address, or even to respond correctly to a ping message, but otherwise we have not been able to send any other command.

Thank you very much in advance.

Best regards,

Alejandro

0 Kudos
Reply
2 Replies

1,012 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

In general, the bootloader located Flash sector was protected without any modification during load new application image. When the bootloader load new application image to Flash, if there with any unexpected behavior, there should not affect the bootloader itself. If there with a reset, the bootloader will be recovered and check if the application image is there to determine if jumping to application.

While, "However, once the write command has failed, we have found no way to recover it and make it start again, or even reset the bootloader." That means your bootloader software was modified during Flash write processing. Customer could check KL03 reference manual about Flash protect, more detailed info please check Program Flash Protection Registers (FTFA_FPROTn).


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,012 Views
alejandronavarr
Contributor I

We are using the ROM bootloader of the KL03, so the bootloader itself cannot have been modified. In a long-duration test, after many write cycles, the write command fails.Maybe there is an issue with another device attached to the I2C bus, but in any case the KL03 should be returned to a consistent state so we can finish the update process.

We can fetch more bytes from the I2C output buffer of the bootloader, and there was the acknowledge sequence, but after cleaning the buffer, the bootloader does not seem to accept any other commands.

On the other hand, the flash itself was not write-protected. If our application does not fail *right after* erasing flash, the Program Flash Protection Registers are not set to 0xFF..., so they do not prevent flash from being erased again.

0 Kudos
Reply