Team,
FLASH_DRV_Erase interface erases the block which is selected (highBlockSelect in my case). But the option seems to erase entire block (16KB). Can we erase or write less than the block size? i do not see such interface.
FYI, I could erase or write successfully if i select entrie block. But it takes ~14 sec to complete the process of erase & write 16KB
Can anyone please help me to know if there is any other interface or method to erase/write less than the block size?
smallest portion of flash memory to erase is one block. The block size varies from 16KB to 256KB in case of MPC5746C.
Smallest portion of flash memory to program is one double word (64bit). You can program only 32bit word but ECC is handled on 64bit boundary, so it won't be possible to program second 32bit word (I mean in the same double word) without erase of whole block.
If this is not acceptable, an option is to use Emulated EEPROM driver. See please this application note to understand the principle:
https://www.nxp.com/docs/en/application-note/AN4868.pdf
Then you can find this example in the SDK package:
c:\NXP\S32DS_Power_v2.1\S32DS\software\S32_SDK_S32PA_RTM_3.0.3\examples\MPC5746C\demo_apps\eeprom_emulation\
And the documentation can be found here:
c:\NXP\S32DS_Power_v2.1\S32DS\software\S32_SDK_S32PA_RTM_3.0.3\doc\S32SDK_MPC5746C_UserManual.pdf
Regards
Lukas
@lukaszadrapa Thanks for your reply.
you mentioned we can erase as one block (16KB to 256K as per MPC5746C). But when write to the 2nd word, we need to erase the block. What if i want to write again the same 1st word? Still we need to erase the 16KB block right?
My concern is if i use fixed address to write a data multiple times (say ~ 100 times in its life), am i need to erase entire block each time?
On Emulated EEPROM (yet to explore), how it will handle the same condition? i believe fixed address is not considered here and the partitions are handled using partition handle or something.
Hi @karthikravi
yes, if the double word is not fully erased, you can't program it again and it is necessary to erase whole block. This part of the reference manual explains it in detail:
It also talks about over-programming which may be done for EEPROM emulation. Notice that this is very specific case related to some patterns only, it should be used by our EEPROM Emulation driver only.
If you have just some small amount of data which will be rewritten like ~100 times in life time then I would use one of these solutions:
1. Use EEPROM Emulation driver. See please mentioned AN4868. Basically and in very short - it is something like circular buffer mechanism.
2. If you have only a few words to store ~100 times, you can implement own simple mechanism:
Select some area in flash for the data. Then write your data in format like (64bit aligned): <header or counter> + <your data>. When you need to update the data, just search for first free (erased) location and write new record in the same way, so you do not need to erase the block.When you need to read the data, just search for the last record.
In case of small amount of data, only one block is needed here, EEPROM would need two blocks, at least. Also I believe that the code size for second solution would be much smaller.
Regards,
Lukas