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:

- The Backdoor Compartison Key is something similar to a password, that if known permits to unsecure the flash
- FPROT0-3 must be at 0xFF in order to not secure the P-Flash
- FDPROT must be at 0xFF in order to not secure the D-Flash
- FEPROT must be at 0xFF in order to not secure the E-Flash (i.e., the EEPROM backup memory)
- FOPT must be at 0xFF in order to not customize the boot options
- FSEC is composed as following:

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,
- How is it possible that when I upload a new application inside the S32K, even if it performs a mass erase operation, it will not secure the device?
- Does the mass erase operation remove the partitions of the FLASH memory resetting it to the "default" configuration? If yes, which is the default configuration?
- If the application residing in the P-Flash performs a mass erase operation, is the P-Flash not erased?
- I do not know how to use the Emergency Kinetis Device Recovery. What is it needed for? Why should I use it instead to perform my mass erase operation from inside the application?