K64 Internal Flash Erase Error

cancel
Showing results for 
Search instead for 
Did you mean: 

K64 Internal Flash Erase Error

413 Views
Contributor II

Hi,

I am writing my application data to internal flash for FRDM-K64. My data is 8 byte aligned.

I was getting fault while erasing the sector and later on I find that I should disable all IRQ before flash operation. So I did changes for the same. 

int Internal_FlashErase(uint32_t destAdrss)
{
status_t result; /* Return code from each flash driver function */
uint32_t regPrimask = 0U;
regPrimask = DisableGlobalIRQ();

do
{
result = FLASH_Erase(&s_flashDriver, destAdrss, 4096, kFTFx_ApiEraseKey);
if (kStatus_FTFx_Success != result)
{
PRINTF("Internal Flash Erase Fail, Addr: %x", destAdrss);
result = -1;
break;
}
result = 0;
}while(0);
/* Enable IRQ if previously enabled. */
EnableGlobalIRQ(regPrimask);
return result;
}

Is this correct?

After long run, I am getting error now for erase operation. After debugging I found that MGSTAT0 bit is set in FTFE_FSTAT which casue error while erasing. What will be the cause of this?

How many write/erase operations are allowed for a single sector?

0 Kudos
8 Replies

161 Views
Contributor I

Hello, I am experiencing a similar (or maybe the same) issue with K64 flash memory.  

I have 3 units from the field that are bricked.
They seem to have been bricked as they were being updated to a new version of FW.
I extracted and inspected the flash for all three units.
They all exhibit an error reading/writing flash from the exact same sector (FE000).
 
I need to determine how the flash became corrupted.
 
I saw the comment above about checking the FPROTn register.  Can I do that with PROGACMP flash programmer from PE Micro (https://www.pemicro.com/products/product_viewDetails.cfm?product_id=15320138&productTab=1)?  That's what I have been using to extract the contents of the flash on these bricked units.

The flash indicator is in a different sector (FF000) so protection of that sector would seem not to be the issue.
 
Do you have any hints or areas that I can look at?

0 Kudos

247 Views
NXP TechSupport
NXP TechSupport

Hello Darshan Shah

 

It is important to verify that the security state of the flash is unsecured, if the flash is secured you cannot write/erase the flash. In order to know the cause of this problem, can you please share with me the value of the variable "result" when you execute the function FLASH_Erase()?

 

Regarding the write/erase operations allowed, you can consult the datasheet under chapter 3.4.1.4

pastedImage_2.png

 

Let me know if this is helpful, if you have questions do not hesitate to ask me.

Best regards,

Omar

0 Kudos

247 Views
Contributor II

Thanks for your reply.

Flash is unsecure. And I am getting result code 0x69 for address 0xFD000. If I just change address from FD000 to FA000, I am able to write my data.

0 Kudos

247 Views
NXP TechSupport
NXP TechSupport

Hello Darshan Shah

 

Please check the value of the FPROTn register is 0xFF, if some bits of the FPROTn register are in 0 then some regions cannot be programmed or erased by any command.

 

If the swap system is enabled, the swap indicator address in each program flash block is implicitly protected from sector erase unless the swap system is in the UPDATE or UPDATE-ERASED state and the program flash sector containing the swap indicator address being erased is in the non-active block.

 

Let me know if this is helpful, if you have questions do not hesitate to ask me.

Best regards,

Omar

0 Kudos

247 Views
Contributor II

Hello,

I run the NXP example code pflash and change the destination address to 0xFD000. And in result, in alternative attempts, it got failed. Please find below logs,

[MCUXpresso Semihosting Telnet console for 'frdmk64f_pflash LinkServer Debug' started on port 44950 @ 127.0.0.1]
######################################

PFlash Example Start

PFlash Information:
Total Program Flash Size: 1024 KB, Hex: (0x100000)
Program Flash Sector Size: 4 KB, Hex: (0x1000)
Flash is UNSECURE!

Erase a sector of flash


---- HALTED DUE TO FLASH ERROR! ----
########################################
PFlash Example Start

PFlash Information:
Total Program Flash Size: 1024 KB, Hex: (0x100000)
Program Flash Sector Size: 4 KB, Hex: (0x1000)
Flash is UNSECURE!

Erase a sector of flash
Successfully Erased Sector 0xfd000 -> 0xfe000

Program a buffer to a sector of flash
Successfully Programmed and Verified Location 0xfd000 -> 0xfd010

End of PFlash Example
#########################################
PFlash Example Start

PFlash Information:
Total Program Flash Size: 1024 KB, Hex: (0x100000)
Program Flash Sector Size: 4 KB, Hex: (0x1000)
Flash is UNSECURE!

Erase a sector of flash


---- HALTED DUE TO FLASH ERROR! ----
#########################################
PFlash Example Start

PFlash Information:
Total Program Flash Size: 1024 KB, Hex: (0x100000)
Program Flash Sector Size: 4 KB, Hex: (0x1000)
Flash is UNSECURE!

Erase a sector of flash
Successfully Erased Sector 0xfd000 -> 0xfe000

Program a buffer to a sector of flash
Successfully Programmed and Verified Location 0xfd000 -> 0xfd010

End of PFlash Example
#########################################

Let me know if you need other details. Due to this flash error, I am not able to use this device. Please suggest a way to recover it. I did mass erase as well yet not success.

0 Kudos

247 Views
NXP TechSupport
NXP TechSupport

Hello Darshan Shah

 

I replicated this on my side with a FRDM-K64. The example runs successfully with 0xFD000 address as well with other different addresses.

If you have another board available I suggest you run the pflash example on this other board.

 

I will be waiting for your results, if you have more questions do not hesitate to ask me.

Best regards,

Omar

0 Kudos

247 Views
Contributor II

Hello Omar,

Yes same application and pflash example works on other device but not on my device.

That's why I would like to know the condition so we can prevent it in our production.

0 Kudos

247 Views
NXP TechSupport
NXP TechSupport

Hello Darshan Shah

 

Applying voltages to the I/O when the processor is not powered can lead to corruption of flash contents, corruption of flash control logic, or corruption of device configuration and trim values which in turn can lead the processor reporting as secured or failure the processor to respond to and complete flash commands.

 

Let me know if this is helpful, if you have more questions do not hesitate to ask me.

Best regards,

Omar

0 Kudos