Factory Reset/Mass Erase LPC55S28 I am using the LPC55S28 MCU. For production units, we want to disable SWD/JTAG access so memory can not be read out of the MCU. However, we need a way to recover a unit once this happens. Usually, we do a Mass Erase command to factory reset the MCU to recover access. With the LPC55S28 secure bootloader and CMPA/CFPA and the KeyStore/PFR, I am not sure how to do this. Questons: 1. If I have FA_ME_CMD_EN=ENABLED, but then ISP_CMD_EN, ISP_CMD_EN, TAPEN, DBGEN and NIDEN DISABLED, is that ok. Can I still factory reset the MCU? Including the CMPA, CFPA, PFR, etc? 2. How can I do a complete factory reset via SWD if only the FA_ME_CMD_EN is enabled? I have a JLINK debugger. I have tried the below JLINK script that I wrote, which does not clear the CMPA: SelectInterface SWD Speed 1000 Device LPC55S28 Connect // Send Debug Mailbox Activation while connected WriteAP 0x01000000 0x00000001 WriteAP 0x01000004 0x00000001 Sleep 100 ReadAP 0x01000000 Reset Exit Below are my CMPA settings right now, which keeps everything enabled until I figure out how to do a factory reset/mass erase. But everything I try seems to still keep the CMPA settings. # --------------------------------------===== DCFG_CC_SOCU_PIN [Optional] =====--------------------------------------- # Description: Offset: 0x00000010, Width: 32b; Device Configuration Credential Constraints for SoC specific Use # Pinned. # Combinations of PIN and DFLT bits and resulting restriction level: # - PIN=1,DFLT=1: Restriction level 0. Access to the sub-domain is always enabled. This setting is provided for module # use case scenario where DCFG_CC_SOCU_NS would be used to define further access restrictions before final deployment # of the product. # - PIN=0,DFLT=0: Restriction level 1. Access to the sub-domain is disabled at startup. But the access can be enabled # through debug authentication process by providing appropriate Debug Credential (DC) certificate. # - PIN=0,DFLT=1: Illegal setting. Part may lock-up if this setting is selected. # - PIN=1,DFLT=0: Restriction level 3. Access to the sub-domain is permanently disabled and can't be reversed. This # setting offers the highest level of restriction. DCFG_CC_SOCU_PIN: # -------------------------------------------===== NIDEN [Optional] =====------------------------------------------- # Description: Offset: 0b, Width: 1b, Non Secure non-invasive debug enable # - USE_DAP, (0): Use DAP to enable # - FIXED_STATE, (1): Fixed state # Possible options: NIDEN: FIXED_STATE # -------------------------------------------===== DBGEN [Optional] =====------------------------------------------- # Description: Offset: 1b, Width: 1b, Non Secure debug enable # - USE_DAP, (0): Use DAP to enable # - FIXED_STATE, (1): Fixed state # Possible options: DBGEN: FIXED_STATE # -------------------------------------------===== TAPEN [Optional] =====------------------------------------------- # Description: Offset: 4b, Width: 1b, JTAG TAP enable # - USE_DAP, (0): Use DAP to enable # - FIXED_STATE, (1): Fixed state # Possible options: TAPEN: FIXED_STATE # ----------------------------------------===== ISP_CMD_EN [Optional] =====----------------------------------------- # Description: Offset: 6b, Width: 1b, ISP Boot Command enable # - USE_DAP, (0): Use DAP to enable # - FIXED_STATE, (1): Fixed state # Possible options: ISP_CMD_EN: FIXED_STATE # ---------------------------------------===== FA_ME_CMD_EN [Optional] =====---------------------------------------- # Description: Offset: 7b, Width: 1b, Fault Analysis/Mass Erase Command enable # - USE_DAP, (0): Use DAP to enable # - FIXED_STATE, (1): Fixed state # Possible options: FA_ME_CMD_EN: FIXED_STATE # ----------------------------------------===== UUID_CHECK [Optional] =====----------------------------------------- # Description: Offset: 15b, Width: 1b, Enforce UUID match during Debug authentication. # - DISABLED, (0): Disabled # - ENABLED, (1): Enabled # Possible options: UUID_CHECK: DISABLED # --------------------------------------===== DCFG_CC_SOCU_DFLT [Optional] =====-------------------------------------- # Description: Offset: 0x00000014, Width: 32b; Device Configuration Credential Constraints for SoC specific Use Debug # Filter. # Combinations of PIN and DFLT bits and resulting restriction level: # - PIN=1,DFLT=1: Restriction level 0. Access to the sub-domain is always enabled. This setting is provided for module # use case scenario where DCFG_CC_SOCU_NS would be used to define further access restrictions before final deployment # of the product. # - PIN=0,DFLT=0: Restriction level 1. Access to the sub-domain is disabled at startup. But the access can be enabled # through debug authentication process by providing appropriate Debug Credential (DC) certificate. # - PIN=0,DFLT=1: Illegal setting. Part may lock-up if this setting is selected. # - PIN=1,DFLT=0: Restriction level 3. Access to the sub-domain is permanently disabled and can't be reversed. This # setting offers the highest level of restriction. DCFG_CC_SOCU_DFLT: # -------------------------------------------===== NIDEN [Optional] =====------------------------------------------- # Description: Offset: 0b, Width: 1b, Non Secure non-invasive debug fixed state # - DISABLED, (0): Disabled # - ENABLED, (1): Enabled # Possible options: NIDEN: ENABLED # -------------------------------------------===== DBGEN [Optional] =====------------------------------------------- # Description: Offset: 1b, Width: 1b, Non Secure debug fixed state # - DISABLED, (0): Disabled # - ENABLED, (1): Enabled # Possible options: DBGEN: ENABLED # -------------------------------------------===== TAPEN [Optional] =====------------------------------------------- # Description: Offset: 4b, Width: 1b, JTAG TAP fixed state # - DISABLED, (0): Disabled # - ENABLED, (1): Enabled # Possible options: TAPEN: ENABLED # ----------------------------------------===== ISP_CMD_EN [Optional] =====----------------------------------------- # Description: Offset: 6b, Width: 1b, ISP Boot Command fixed state # - DISABLED, (0): Disabled # - ENABLED, (1): Enabled # Possible options: ISP_CMD_EN: ENABLED # ---------------------------------------===== FA_ME_CMD_EN [Optional] =====---------------------------------------- # Description: Offset: 7b, Width: 1b, Fault Analysis/Mass Erase Command fixed state # - DISABLED, (0): Disabled # - ENABLED, (1): Enabled # Possible options: FA_ME_CMD_EN: ENABLED # ----------------------------------------===== VENDOR_USAGE [Optional] =====----------------------------------------- # Description: Offset: 0x00000018, Width: 32b; Vendor Usage VENDOR_USAGE: # ---------------------------------------===== VENDOR_USAGE [Optional] =====---------------------------------------- # Description: Offset: 16b, Width: 16b, Upper 16 bits of vendor usage field defined in DAP. Lower 16-bits come from # customer field area. VENDOR_USAGE: 0 # ---------------------------------------===== SECURE_BOOT_CFG [Optional] =====--------------------------------------- # Description: Offset: 0x0000001C, Width: 32b; Secure boot configuration SECURE_BOOT_CFG: # -------------------------------------------===== RSA4K [Optional] =====------------------------------------------- # Description: Offset: 0b, Width: 2b, Select minimal key length. To enforce usage of RSA4096, setting 0b11 value is # recommended to allow RSA4096 keys only. # - RSA2048, (0): RSA2048 or higher can be used for image signing. Only RSA2048 can be used as debug keys. # - RSA4096_0, (1): Only RSA4096 keys can be used for image signing and debug authentication. # - RSA4096_1, (2): Only RSA4096 keys can be used for image signing and debug authentication. # - RSA4096_2, (3): Only RSA4096 keys can be used for image signing and debug authentication. # Possible options: RSA4K: RSA2048 # -------------------------------------===== DICE_INC_NXP_CFG [Optional] =====-------------------------------------- # Description: Offset: 2b, Width: 2b, Include NXP area in DICE computation. # - NOT_INCLUDE, (0): not included # - INCLUDE_0, (1): included # - INCLUDE_1, (2): included # - INCLUDE_2, (3): included # Possible options: DICE_INC_NXP_CFG: NOT_INCLUDE # ---------------------------------------===== DICE_CUST_CFG [Optional] =====--------------------------------------- # Description: Offset: 4b, Width: 2b, Include Customer factory area (including keys) in DICE computation. # - NOT_INCLUDE, (0): not included # - INCLUDE_0, (1): included # - INCLUDE_1, (2): included # - INCLUDE_2, (3): included # Possible options: DICE_CUST_CFG: NOT_INCLUDE # -----------------------------------------===== SKIP_DICE [Optional] =====----------------------------------------- # Description: Offset: 6b, Width: 2b, Skip DICE computation # - ENABLE, (0): Enable DICE # - DISABLE_0, (1): Disable DICE # - DISABLE_1, (2): Disable DICE # - DISABLE_2, (3): Disable DICE # Possible options: SKIP_DICE: DISABLE_0 # --------------------------------------===== TZM_IMAGE_TYPE [Optional] =====--------------------------------------- # Description: Offset: 8b, Width: 2b, TrustZone-M mode # - HEADER, (0): TZ-M image mode is taken from application image header # - DISABLED, (1): TZ-M disabled image, boots to non-secure mode # - ENABLED, (2): TZ-M enabled image, boots to secure mode # - PRESET, (3): TZ-M enabled image with TZ-M preset, boot to secure mode TZ-M pre-configured by data from # application image header # Possible options: TZM_IMAGE_TYPE: HEADER # ---------------------------------------===== BLOCK_SET_KEY [Optional] =====--------------------------------------- # Description: Offset: 10b, Width: 2b, Block PUF key code generation # - ALLOW, (0): Allow PUF Key Code generation # - DISABLE_0, (1): Disable PUF Key Code generation # - DISABLE_1, (2): Disable PUF Key Code generation # - DISABLE_2, (3): Disable PUF Key Code generation # Possible options: BLOCK_SET_KEY: ALLOW # ---------------------------------------===== BLOCK_ENROLL [Optional] =====---------------------------------------- # Description: Offset: 12b, Width: 2b, Block PUF enrollment # - ALLOW, (0): Allow PUF enroll operation # - DISABLE_0, (1): Disable PUF enroll operation # - DISABLE_1, (2): Disable PUF enroll operation # - DISABLE_2, (3): Disable PUF enroll operation # Possible options: BLOCK_ENROLL: ALLOW # ------------------------------------===== DICE_INC_SEC_EPOCH [Optional] =====------------------------------------- # Description: Offset: 14b, Width: 2b, Include security EPOCH in DICE DICE_INC_SEC_EPOCH: 0 # ----------------------------------------===== SEC_BOOT_EN [Optional] =====---------------------------------------- # Description: Offset: 30b, Width: 2b, Secure boot enable # - DISABLE, (0): Plain image (internal flash with or without CRC) # - ENABLE_0, (1): Boot signed images. (internal flash, RSA signed) # - ENABLE_1, (2): Boot signed images. (internal flash, RSA signed) # - ENABLE_2, (3): Boot signed images. (internal flash, RSA signed) # Possible options: SEC_BOOT_EN: ENABLE_0 Re: Factory Reset/Mass Erase LPC55S28 Hello @guitardenver
Thanks for your question. Please refer to the thread below for more information.
[LPC55]: Disable ISP and SWD to utilize code protection
If this does not fully address your requirements, please feel free to contact me. I will be happy to help further.
BR
Alice Re: Factory Reset/Mass Erase LPC55S28 Alice, Thanks for that link, very informative. I do still have some questions. From the link you sent, I think I understand how to disable ISP and SWD. But my main question is how to recover access and erase everything, including the CMPA, CFPA, etc to factory defaults. I think I have already bricked a couple devices and need help to prevent bricking more. What is the best way to do a complete factory reset? Assuming I didn't set any settings that prevent that. What I'm trying to do: 1. Use the ROM bootloader to do .sb (SB2.1) file updates. So secure/authenticated firmware updates over USB using the ROM bootloader. 2. Disable the ability to read and write to the MCU memory via SWD or JTAG. I do not use TrustZone or any special settings in the PFR that locks access to any application flash. 3. USB Bootloader should not be able to arbitrarily read/write to flash/ram. Just like we don't want anybody to read/write to memory via SWD or JTAG. But the bootloader should still be able to do secure .sb file updates over USB or from my own application code. 4. Once SWD/JTAG is disabled/locked, I would like to be able to recover access to SWD and completely erase/default the CMPA, CFPA, PFR, etc to factory default to start over. Can this be done via SWD mass erase or can it be done by a special SB2.1 file I can make? Questions: 1. Does the SWD DebugMailbox mass erase also erase the CMPA, CFPA, keystore, etc? If NIDEN and DBGEN settings are in the CMPA, and the MassErase does not erase CMPA, then how can you recover NIDEN and DBGEN access? 2. If I disable NIDEN, DEBGEN, TAPEN, ISP_CMD_EN. And Keep FA_ME_CMD_EN enabled, does this achieve what I am looking for? Locks down the MCU, but is completely recoverable via erasing everything? What settings or method would you recommend here? I have also contacted SEGGER on what specific tools/examples they have to be able to recover LPC55S28 devices via the DAP to factory default. If I can write a JLINK script to do this, that would be fine too. Thanks for your help!
View full article