My application needs to store some configuration data on the MCXN547 internal Flash memory, so I started looking at the SDK mcxn5xxevk_mcxromapi_flashiap_cm33_core0 example. I have some questions about it:
Hello @Vagni
Thanks for your patience. I have confirmed with our internal team.
This issue is caused by not invalidate cache after erasing/programing flash, you can add below macro:
#define LPCAC_INVALIDATE 1
Then copy fsl_cache_lpcac.c/h files to drivers folder and re-build the project, you will see the flash erase verify error code will disappear.
We have created a ticket to SDK team to update SDK example.
Sorry for the inconvenience for you.
BR
Alice
Hello @Vagni
Thanks for your patience.
After I confirmed with our internal team,
"The error code 153 and 154 will be added in the latest MCX N RM, the new RM is still under review and will be published on NXP website at the end of Feb or early of March. You can see the description for error code 154 in below figure.
For the sector erase, I think we can erase the sector after writing, but please note that the code execution should not be on the same sector at this moment.
"
Sorry for the inconvenience for you.
BR
Alice
OK Alice, error code 154 indicates the flash sector is not erased.
Also my added direct reading back from flash fails in verifying erased sector from the first beginning address (at destAdrss = 0x000FC000 read 0x00000000 instead of 0xFFFFFFFF).
But the debug memory reading reports the flash sector is actually erased:
I added a delay of 1 sec after the FLASH_Erase() call (which never fails), but I get no behavior change.
Anyway, the subsequent flash write is always (and unexpectedly) successful.
Hello @Vagni
->> No, it is not needed.
->> Yes.
->>Yes.
->>Yes, It can work well as long as you don't erase or program the address that your code uses. Also, the start address must be sector - size aligned (that is, a multiple of 8 KB).
->> About the two questions, please send your project that can reproduce the issue. Thanks.
->> This is just a demo, in real project, we recommend disable all the interrupt when erasing/programming flash.
Hope it helps.
BR
Alice