How do I perform a FLASH mass erase operation with s32k144 and s32 design studio? Can you describe me the precise steps to do that, without risking to brick my board as happened for other people, like here?
Thank you!
Based on the procedure of demo in AN12323.pdf, I don't think mass erase is able to remove partition. The only way to remove EEPROM partition is to do the partition again with suitable parameters. Otherwise, the SIM register for flash config will not be changed. Am I correct??
Hi,
mass erase is performed prior new flash image write operation. You can also use Emergency kinetis device recovery in debug configuration.
When you are using FLASH operations by MCU - make sure that you aren't modify flash config on address 0x400-0x410. Erase of that area is okay, but make sure that you don't write there data which disable mass erase and secure the chip.
Jiri
Ok, I understood that whenever I want to program/erase my s32k board, I must pay attention to not secure it, otherwise I could not be anymore able to re-program/re-erase it, if I do not have a backdoor key. The fields that I must pay attention to are in the following figure:
I highlighted in yellow what I want and in red what should happen when I perform a mass erase command (is it true that an erase command will put all flash bits at 1?). You said that an erase of this area is ok (i.e., the erase will not secure the device), even if the mass erase will write SEC = 11b (device is secure).
In the example provided with the SDK, after the erase of all flash blocks, the application will program the Flash Configuration Fields writing the following thing:
uint8_t unsecure_key[FTFx_PHRASE_SIZE] = {0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFEu, 0xFFu, 0xFFu, 0xFFu}
Where all bits are at 1, except for the FSEC[SEC] field that is at 10b.
So,
Hi,
actually you need to take special care to MEEN bit, when mass erase is disabled, chip is secured and backdoor key disabled - there is no way back. Secured chip with mass erase enabled is okay.
Jiri
Ok, so when I erase all the flash content, SEC field secures the chip but the MEEN field leaves the mass erase operation enabled (thus, the example provided with the SDK maybe only wants to show how the flash configuration fields can be written).
What about question 2, 3 and 4? Thank you.
Hi,
2. the default config is using FlexNVM as Dflash
3. If app performs mass erase - the app erases itself too (at least partly - the program probably ends in some exception).
4. It is part of debug session with PE Micro debugger. I'm not 100% sure what this option does, but it can erase secured device with key access (jf MEEN is enabled).
Jiri