How to check memory flash sector in MCXA cpu

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to check memory flash sector in MCXA cpu

跳至解决方案
388 次查看
_Ferrari_
Contributor V

Dear all,

I'm developing a project based on the MCXA153VLH and I have to read and write a sector of internal flash memory.

I have developed a procedure based on romapi_flashiap example in the SDK but in the SDK example I can't find any procedure to verify if a sector of flash memory is erased or written.

The problem I have is that, on power-on, I need to check if a flash memory sector has never been written. If that's the case, I have to initialize it with default data.

 

Did you encountred asimilar problem ?

How did you fix it ?

Thank you very much for your help and cooperation

regards

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
238 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi _Ferrari_,

MCX and LPC55 Flash are different.  LPC55Sxx parts are delivered from the factory mass erased with ECC unset. If performing AHB reads of the flash memory contents AFTER a sector erase, we will have the same HardFault issue. We need to program the sector or use Flash controller read command to overcome it. See my article on this topic

[LPC55xx] How to fix AHB Read HardFault Error - NXP Community

MCX Flash don't have this limit.  While Flash verify API function still works for MCX.

Hope this will help you.

Jun Zhang

在原帖中查看解决方案

0 项奖励
回复
3 回复数
355 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi @_Ferrari_ 

The MCX153 Flash memory has default values of all 0xFF when erased. Therefore, we can check if the specific Flash memory bits are all ’1‘ to determine whether the Flash sector has been written to. If all the contents in a sector are read as 0xFF, the sector is unused.

Does this answer your question?

Hope this helps,

Jun Zhang

0 项奖励
回复
319 次查看
_Ferrari_
Contributor V

I previously used an LPC5526 processor, where the flash memory could have three states:

erased

programmed (or written)

uninitialized

So, before accessing the flash, I had to use the FLASH_VerifyErase function to check if the flash was accessible. It seems to me that, with this type of processor, the problem doesn't exist. Can you confirm?

Thank you very much for your help and cooperation

regards

标记 (2)
0 项奖励
回复
239 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi _Ferrari_,

MCX and LPC55 Flash are different.  LPC55Sxx parts are delivered from the factory mass erased with ECC unset. If performing AHB reads of the flash memory contents AFTER a sector erase, we will have the same HardFault issue. We need to program the sector or use Flash controller read command to overcome it. See my article on this topic

[LPC55xx] How to fix AHB Read HardFault Error - NXP Community

MCX Flash don't have this limit.  While Flash verify API function still works for MCX.

Hope this will help you.

Jun Zhang

0 项奖励
回复