Hi @nourgati
Please use J-Link Commander to read the MDM-AP registers (see Section 58.6, "MDM-AP Status and Control Registers," in the S32K1xx Series Reference Manual, Rev. 14.1). Then, manually trigger the mass-erase. Before you do this, make sure the MDM-AP_STATUS[1] bit (Flash ready) and the MDM-AP_STATUS[5] bit (mass erase enabled) are both set. You can find the J-Link script in the S32Kxxx SEGGER Knowledge Base.
Also, before the MCU was locked, did you enable CSEc (keys allocated) in the MCU? This might have happened if you tested the encrypted SDK example. If CSEc was enabled before the MCU was locked, you cannot recover the MCU, as mass erase is not allowed even if the MDM-AP status register shows that mass erase is enabled.
Be aware that the first sector might not be programmed correctly when loading new code, which can cause the MCU to become permanently locked.
BR, VaneB