top of page

Erasing NXP S32K1xx Safely When CSEc Is Enabled

3 days ago
2 min read

Choosing the right PEmicro erase algorithm for secure S32K1xx devices


The NXP S32K1xx family includes a Cryptographic Services Engine (CSEc) that brings hardware security to automotive and industrial designs. But security has a side effect on flash programming: once CSEc flash keys are allocated, a normal mass erase no longer works. This blog explains why, and which PEmicro algorithm files to use so your erase and programming steps keep running smoothly.




Why Mass Erase Stops Working

CSEc follows the SHE (Secure Hardware Extension) specification, which says flash keys must not be erased without authentication. On the S32K1xx, all flash keys are backed up in emulated EEPROM inside DFlash. According to the S32K1xx Reference Manual, once keys are allocated (even if never initialised):

  • Authentication is required first: the DBG_CHAL and DBG_AUTH commands must run and pass, removing all flash keys, before DFlash can be erased.

  • Erase All Blocks and Erase All Blocks Unsecure will not work.

  • Erase Flash Block / Sector will also fail if the selected block or sector includes the DFlash holding the keys.


Watch out: If any flash key is write-protected, it cannot be removed. Authentication will not pass, and the DFlash cannot be erased at all.


Selecting the Right Algorithm

This directly affects the algorithm you select in PEmicro’s PROGACMP programming software and the Cyclone Image Creation utility. In both cases the same EM; Erase Module command is used. What it erases depends on the algorithm file.


CSEc Disabled: Full Mass Erase

Use the pflashdflash_eeprom.arp algorithms. The EM command performs a full mass erase of PFlash, DFlash and EEPROM, which is ideal for restoring a device to its factory state.




CSEc Enabled: Sector Erase

Use the sectorerase.arp algorithms. Here EM performs a sector-by-sector erase of PFlash only, leaving the DFlash sectors that hold the CSEc keys untouched, so programming continues without hitting the key-protection lock.




Algorithm Quick Reference

Device

CSEc Disabled (full mass erase)

CSEc Enabled (sector erase)

S32K116

s32k116f128m4_pflash_dflash_eeprom.arp

s32k116f128m4_sector_erase.arp

S32K118

s32k118f256m4_pflash_dflash_eeprom.arp

s32k118f256m4_sector_erase.arp

S32K142W

s32k142wf256m8_pflash_dflash_eeprom.arp

s32k142wf256m8_sector_erase.arp

S32K144W

s32k144wf512m8_pflash_dflash_eeprom.arp

s32k144wf512m8_sector_erase.arp

S32K142

s32k142f256m15_pflash_dflash_eeprom.arp

s32k142f256m15_sector_erase.arp

S32K144

s32k144f512m15_pflash_dflash_eeprom.arp

s32k144f512m15_sector_erase.arp

S32K146

s32k146f1m0m11_pflash_dflash_eeprom.arp

s32k146f1m0m11_sector_erase.arp

S32K148

s32k148f2m0m11_pflash_dflash_eeprom.arp

s32k148f2m0m11_sector_erase.arp



Quick Decision Guide

  1. Not using CSEc? Pick the pflashdflash_eeprom.arp file for a complete factory-fresh erase.

  2. CSEc keys allocated? Pick the sectorerase.arp file so only PFlash is erased.

  3. Need to wipe DFlash on a CSEc part? Run CSEc authentication (DBG_CHAL / DBG_AUTH) first, and make sure no keys are write-protected.




Further Reading

For more detail on CSEc and flash programming, see NXP application notes AN12130, Section 3.2.5.2, “Mass erase and CSEc considerations”.

Comments


bottom of page