Myke Predko

Implementing Kinetis Flash "SWAP" in MQX

Discussion created by Myke Predko on Jan 21, 2014
Latest reply on Aug 31, 2015 by thiagow

I just wanted to make a comment regarding implementing Flash SWAP in MQX - I was able to do it using the code kindly given by David White in the discussion: Using flashx io_ioctl FLASH_IOCTL_SWAP_FLASH_AND_RESET for bootloader


However, if you want to write to the Flash after the swap, you cannot write to the last sector of Flash in each block (in a 512k part these sectors are at 0x3F800-0x3FFFF and 0x7F800-0x7FFFF). 


As I have implemented a file system in my application, I treat these sectors as they are defective so there are no attempts to write/read to them. 


This is documented in the Kinetis documentation and David's code adds the functionality needed for implementing the SWAP, but, as noted, if you want to write to the Kinetis Flash afterwards you need to avoid the sectors listed above.