K70 flash swap and erase

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

K70 flash swap and erase

Jump to solution
727 Views
xxofeval
Contributor I

We have an application using a Kinetis K70 that requires a refresh of all flash storage. This refresh is executed every 10 years in a maintenance mode without the main application running. The flash refresh includes a bootloader area.  We were considering using duplicate copies of the bootloader and the flash swap capability to protect the device during maintenance.  Our application requires much more than half the flash size so we cannot simply dedicate blocks.  We were hoping to just maintain a bootloader at 0x0000 offset of both block halves.  The bootloader would detect a block swapped boot which would indicate a problem and do a targeted rewrite of its own image to the alternate block.  Can we erase and then write the non-active block sector by sector without a full block erase when swapped? 

0 Kudos
1 Solution
519 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello d verdello:

I see how that statement could be confusing.

Actually it just means that before writing to the nonactive block, any spaces to be written must be in "erased state" (all 1's). See this note from the Reference Manual:

pastedImage_1.png

So the text in the appnote does not mean that you need to erase the entire block. But for the swap to work as expected, it is mandatory to erase at least the sector with the flash swap indicator.

:smileyinfo: The K70 uses phrase programming (8 bytes at a time), so you need to consider flash memory location as a phrase (8-bytes space).

I hope this clarifies. Let me know if you have questions.

Regards!

Jorge Gonzalez

View solution in original post

0 Kudos
3 Replies
519 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello d verdello:

I did not fully understand your design or use case, but in regards of your question, after sending the SWAP command to set the system in UPDATE state, then you have the choice to erase only part of the nonactive block, but it is strictly required that you erase at least the sector that contains the SWAP indicator. See the next text from application note AN4533:

pastedImage_1.png

In case you are not familiar with all the SWAP mechanism, then I recommend you to read the whole application note AN4533.

If I misunderstood your question or you need further clarification please let me know.


Regards!,
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
519 Views
xxofeval
Contributor I

Thanks for the response Jorge

We're looking for clarification on targeted sector erase and rewrite of the nonactive block.  Our application looks to erase and rewrite specific sectors leaving the remainder of the nonactive block intact.

From 4.2 of the appnote:

"You can use block erase or sector erases. It is only specifically required to erase the flash swap indicator sector in the

nonactive block. However, to update the software in the nonactive block, you must first erase it."

This could imply that the entire nonactive block needs to be erased if you wish to rewrite in the nonactive block before the swap.  This would not fit our needs.  It is clear we can execute a targeted sector erase and then swap.  What is not clear is if we can erase only a few sectors including the flash swap indicator and then rewrite some of those non swap indicator sectors before executing a swap.

All examples we've found show a full block erase prior to writing.

0 Kudos
520 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello d verdello:

I see how that statement could be confusing.

Actually it just means that before writing to the nonactive block, any spaces to be written must be in "erased state" (all 1's). See this note from the Reference Manual:

pastedImage_1.png

So the text in the appnote does not mean that you need to erase the entire block. But for the swap to work as expected, it is mandatory to erase at least the sector with the flash swap indicator.

:smileyinfo: The K70 uses phrase programming (8 bytes at a time), so you need to consider flash memory location as a phrase (8-bytes space).

I hope this clarifies. Let me know if you have questions.

Regards!

Jorge Gonzalez

0 Kudos