Part Number: MSP432E401Y
Other Parts Discussed in Thread: MSP-EXP432E401Y, UNIFLASH
We want to disable the external debug access to the MSP432 in order to protect our sensitive user data stored in the flash memory. This is crucial for our application. But it looks like the unlocking procedure does not perform a full erase possibly enabling an atacker to read out sensitive user data.
In detail: We set DBG1 of the BOOTCFG register to 0 and commit the new register value to the flash memory. Up to this point everything works as expected and we can't access the MSP432 an more using the debugger. Now we follow the instructions in section 3.3.4.3 (Recovering a "Locked" Microcontroller) of the technical reference manual. The section states: "The mass erase of the Flash memory caused by the sequence below occurs prior to the nonvolatile registers being restored." So we expect a mass erase to be performed. To verify whether this is the case, we manually write data to the flash memory (pretty much at the end of the flash region). After that we perform the unlock sequence with `dbgjtag -f @xds110 -Y unlock,mode=msp432e4` (we always need to execute this twice to work). Now our firmware doesn't load anymore and it causes us to be able to flash our firmware again (with the "Do not erase Flash memory" setting set). But: After that we are able to read the previously written (test) value from Flash memory. Did we omit one step?
The source code we are using to disable the debug interface is as follows:
HWREG(FLASH_FMA) = 0x75100000;
HWREG(FLASH_FMD) = 0x7FFFFFFC;
HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT;
while(HWREG(FLASH_FMC) & FLASH_FMC_COMT); //Wait for completion
We also tried:
HWREG(FLASH_FMA) = 0x75100000;
HWREG(FLASH_FMD) = 0x7FFFFFFC;
HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_WRITE;
while(HWREG(FLASH_FMC) & FLASH_FMC_WRITE); //Wait for completion
HWREG(FLASH_FMA) = 0x75100000;
HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT;
while(HWREG(FLASH_FMC) & FLASH_FMC_COMT); //Wait for completion