LPC55S69 : recover after Flash Error

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC55S69 : recover after Flash Error

694 Views
EugeneHiihtaja
Senior Contributor I

Hi !

During flash erase/program operation error can happens and it seems to me it is not recoverable.

Even reading of this area of memory cause Hardfault.

Only erasing of whole flash can suppress it.

Does it possible to detect this kind of memory areas and erase only several Flash sectors ?

Can this problem be similar to one what is explained in errata ?

"3.5 ROM.5: ROM fails to enter ISP mode when image is corrupted with
flash pages in an erased or unprogrammed state

"

Regards,

Eugene

Labels (1)
0 Kudos
7 Replies

489 Views
EugeneHiihtaja
Senior Contributor I

Hi !

I have ECC error all the time even Flash prefetch is disabled,

I have initialized FLASH_Init at 96Mhz and use it at 12Mhz as well.

I have dumped 16 bytes at different stages, But 512 erase/write in use.

+FMCCR 0x101A
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <--- erased flashmemory


01 00 00 00 00 02 00 00 00 C4 02 10 FF FF FF FF <--------- memory buffer for write


FLASH_Program() new slot at 0x2C000 , size 512


21 00 00 00 00 02 00 00 00 C4 02 10 FF FF FF FF <--- read flash memory directly 

116 Unknown status  <--- print error 116 (  kStatus_FLASH_EccError)


FLASH_Verify( 116 ) fail, Addr - 0x2C000, Data - 0x2E2E2E2E  <-- call verify after that

You can see that first byte have value 0x21 instead of 0x01.

And it can happens in different places.

After that even reading of this memory cause HardFault and erasing of this sector dosn't help, even erase/Verify return OK.

Only mass erase or erase  by sectors can recover this flash sector.

Can you explain what can be problems with Flash memory ?

Some caches, prefetches should be not only disabled but also flushed some how ?

MPU is active on nonsecure side. But flash access done via NSC call but source memory buffer on secure side.

Flash API is called with disable interrupts aslo.

__disable_irq();
__DSB();
__ISB();
status = FLASH_Program(&flashInstance, dest_address, (uint8_t*) &buffer[0], sizeof(buffer));
__enable_irq();
__NOP();
verify_status(status);

What can be problem with IAP usage of flash memory ?

Regards,

Eugene

0 Kudos

490 Views
EugeneHiihtaja
Senior Contributor I

Hi !

If I write to the same place  it show other failed bit and after that hardfault :

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
01 00 00 00 00 02 00 00 00 C8 02 10 FF FF FF FF | ................
FLASH_Program() at 0x2C400 , size 512

41 00 00 00 00 02 00 00 00 C8 02 10 FF FF FF FF | A...............

116 Flash Ecc Error.


FLASH_Verify( 116 ) fail at addr - 0x2C400, Data - 0x2E2E2E2E
-Core clock 12000000 Hz
-FMCCR 0x101A

write 3rd time
+FMCCR 0x101A
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
01 00 00 00 00 02 00 00 00 CC 02 10 FF FF FF FF | ................
FLASH_Program() at 0x2C800 , size 512

Entering HardFault interrupt!
SCB->BFSR:PRECISERR fault: Precise data access error.
Address that caused secure bus violation is 0x1002C800.

It little bit weird but it is not clear what kind of RAM buffer is used in Bootrom for execute

flash command ( like it was in K82).

May be that RAM is not allocated properly ?

Or what can be reason for ECC errors ?

Regards,

Eugene

0 Kudos

490 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Eugene,

As the suggestion from UM11126,

"Read operations performed using flash controller commands (See Section 5.6.2 “Command listing (CMD)”) will not cause a hardfault."

pastedImage_2.png

I am preparing an article on this issue. I will update you once I post it to community.


Have a great day,
Jun Zhang

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

490 Views
EugeneHiihtaja
Senior Contributor I

Hi ZhangJennie‌ !

It mean if reading of flash memory via Flash controller return error, one 512 sector can be erased and read error should vanish ?

Is this so ?

While my experiments with ECC error I have found next dependence. 

If the same 32KB flash block is also used for code execution and NSC area and I try to use some part of it ( 8-16KB) for erase/write operation ( areas are not overlapped :smileyhappy:, they just located in the same 32KB block),

write operation almost always return ECC error. Even Flash acceleration and prefetch is disabled completely.

And I use now completely independent 32KB flash block by "storage" to test how reliable it can be.

I can see Flash properties returns 32KB as Sector size :

FLASH_PropertyPflashSectorSize = 32768
FLASH_PropertyPflashTotalSize = 655360
FLASH_PropertyPflashPageSize = 0x200

It means Flash memory is really organised as 32KB independent blocks and Erase/Write of 512 page is just some internal SW trick

in ROM API.

Do you have any comment about it ?

Regards,

Eugene

0 Kudos

490 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,Eugene Hiihtaja

LPC55Sxx checks FLASH ECC while AHB read. During IDE debugger connecting a LPC55Sxx board, FLASH is mass erased first. The LPC55S69 mechanism is, FLASH contents are erased but the ECC values are not updated with that erasing. Therefore, when executing FLASH read code ( for example, mytemp = *(uint32_t*)0x4000 ) through AHB bus, it detects the ECC values not match the erased memory content, which leads to fail to read and go to HardFault_Handler.

Unlike mass erasing, programing FLASH updates the related ECC value. Thus with a successful ECC check, read AHB can be realizable by below code.

volatile uint32_t mytemp;

……

mytemp = *(uint32_t*)0x1000;//read memory content 0x1000 to mytemp

 

NOTE: 0x1000 MUST be a “programed” address.

The unused FLASH sector is in “erased” state, thus in order to read it, we need manually program it before AHB read.

Have a great day,
Jun Zhang

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

490 Views
EugeneHiihtaja
Senior Contributor I

Hi ZhangJennie !

Yes direct reading of flash memory via pointer cause Hardfault. Flasing of code via SWD and mass erase is out of scope right now.

I have small 8KB data storage on flash memory and would like to erase and write it by using 512 bytes chunks.

And need recover procedure for case when writing of 512 bytes is fail.

Does erasing of 512 byte page should recover error for this sector or NOT ?

Or only mass erase ( like suggested in MCU errata can recover flash memory) ?

Regards,

Eugene

0 Kudos

490 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

I would suggest you refer my article method two. This is also UM suggested method of read Flash.

How to fix LPC55Sxx AHB Read HardFault Error
https://community.nxp.com/docs/DOC-345423

0 Kudos