Call SDK flash API and some data in D_Flash missing of S32K144 Hi team: I call SDK flash init API in my project (S32K144), and then call Flash erase and Flash write. Then I find some data in Flash became to 0xFF. Then I try to add a Delay between Flash init and flash Erase/Write, and then the data is normal. And then I try to check while (!(FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK)); instead of using delay function. But it still failed. So, I wonder if it has to delay some time to wait for the flash module to complete initialization on hardware layer. BR Loky Re: Call SDK flash API and some data in D_Flash missing of S32K144 Hi @Loky,
Which driver version are you using? It is not recommended to use the legacy SDK drivers; RTD drivers should be used instead.
The Flash_Init function does not modify flash contents. The erase and write functions already poll the CCIF flag internally, so there is no need to poll it in your application code. The behavior you observe may be related to cache or the flash prefetch buffer. Please try disabling them (PCCCR, OCMDR0) and check if the issue persists.
Regards,
Daniel Re: Call SDK flash API and some data in D_Flash missing of S32K144 Hi Daniel: This is the SDK Flash Driver Version now we are using. My colleague told me that S32K144 only has SDK Flash Driver and no RTD Driver. Could you briefly explain what's wrong with the SDK driver? And could you please share it to me if you have S32K144 RTD driver. I tried to use the methed you mentioned(Disable cache), but it didn't work. I will record some information in flash when power on reset or LVD reset, and some other data is in the same sector. I will read all sector data out and update information and rewrite to the sector. But I've had some new discoveries. I found that the data was already 0xFF before reading the flash. If the flash is accidentally powered off while executing erase or write instructions, it will cause the data in the sector to be 0xFF after power on again? I will continue to investigate this issue, maybe it is a bug in my software. BR Loky Re: Call SDK flash API and some data in D_Flash missing of S32K144 Hi @Loky,
The SDK is legacy software. NXP now provides RTD drivers, which also include Flash drivers, both the MCAL layer and the low-level IP layer equivalent to the legacy SDK. You can download the RTD package here:
https://www.nxp.com/webapp/swlicensing/sso/downloadSoftware.sp?catid=SW32K1-RTD44-D
Please ensure that you use a compatible version of S32 Design Studio, as specified in the RTD Release Notes.
Did you also disable the prefetch buffers?
OCMDR0 – Program Flash prefetch buffer OCMDR1 – Data Flash prefetch buffer
If the Flash is unexpectedly powered down while an erase or program operation is in progress, NXP cannot guarantee data integrity. The affected Flash contents become undefined and may contain ECC errors.
Consider using the Emulated EEPROM functionality.
It is optimized for this purpose.
Please refer to AN11983 – Using the S32K1xx EEPROM Functionality
https://www.nxp.com/docs/en/application-note/AN11983.pdf
Chapter 5 S32K1xx brownout detection
Chapter 6 S32K1xx new quick write mode
Regards,
Daniel
Re: Call SDK flash API and some data in D_Flash missing of S32K144 Hi Daniel: Thanks for your RTD package, I'll check it tomorrow. I haven't tried to disable prefetch buffers yet. Do you mean I should disable both cache and prefetch before erase and write flash? I'll try it also. Yes, I did come across an uncorrectable ECC and it triggered Hardfault today. Except erasing this sector again after powering on the device, is there any way to fix this ECC issue? I think this way is not applicable to my current software design. Thank you for your suggestion. I will discuss the Emulated EEPROM with my colleagues. BR Loky Re: Call SDK flash API and some data in D_Flash missing of S32K144 Hi Daniel: I'm glad to tell you we have found the root cause, because the VCC-5v is unstable during power down and MCU reset at low voltage repeatedly, resulting in the software erasing flash during initialization but not writing flash. BR Loky
View full article