K66 flash swap fails after reset

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

K66 flash swap fails after reset

Jump to solution
1,313 Views
cfgmgr
Contributor III

I'm porting some existing working K60 code to the K66, but am having problems getting the "swap flash" mechanism (described in AN4533) to work properly.  The code works fine on my K60, but not on my K66. 

The MCU in question is a bare-metal MK66FN2M0VLQ18.  I am using V1.0.4 of the C90TFS flash driver. I am NOT running in HSRUN mode (I'm running at 120Mhz).

I get no errors while preparing the flash sectors, erasing and programming the flash, and issuing the swap command (0x46);  However after the MCU reboots, I immediately get ACCERR and FPVIOL in the FTFE_FSTAT register, at which point the the processor is locked up.  I then have to do a "mass erase" to get the MCU back to a usable state.

Has anyone else experienced this when porting their K60 flash swapping code to the K66?   

Thanks in advance for any insights!

Tags (1)
0 Kudos
1 Solution
992 Views
cfgmgr
Contributor III

Solved!  (As usual, this was a completely self-inflicted wound - not enough sleep). 

I was using the flash sector and block sizes from the older 1MB-sized K60 chip.  When I used the correct sizes and addresses for the 2MB K66 chip, and moved the FLASH_SWAP_INDICATOR_ADDR to the correct address (0xFF000), all works as expected.

View solution in original post

0 Kudos
3 Replies
993 Views
cfgmgr
Contributor III

Solved!  (As usual, this was a completely self-inflicted wound - not enough sleep). 

I was using the flash sector and block sizes from the older 1MB-sized K60 chip.  When I used the correct sizes and addresses for the 2MB K66 chip, and moved the FLASH_SWAP_INDICATOR_ADDR to the correct address (0xFF000), all works as expected.

0 Kudos
992 Views
jeremyzhou
NXP Employee
NXP Employee

Hi cfgmgr,

I was wondering if you can share the whole demo, then I run the demo on the FRDM-K66F board to replicate the issue.

I'm looking forward to your reply.
Have a great day,
Ping

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

0 Kudos
992 Views
cfgmgr
Contributor III

Not easily - the code is part of a whole larger application that includes a bunch of RTOS tasks, and is custom to our bare-metal board hardware.  It would be quite difficult to peel out just the relevant code and get it to compile.

But I noticed in the K66 manual that the program swap flash system swaps blocks 0-1 with blocks 2-3.   Since our original K60 code only had 2 blocks (0 and 1) and the K66 we are using has 4 blocks (0-3), I'm wondering if the problem lies somewhere in there...

0 Kudos