Hi,
We are currently working with a LPC5526 and LPC5528 (both JBD64 non-S variant) and for production purposes we want to disable debug access through SWD and ISP to prevent code readout.
From https://community.nxp.com/t5/LPC-Microcontrollers/LPC5528-how-to-reach-code-security-equal-to-CRP2-i... and the user manual I understand we can write the CC_SOCU_PIN and CC_SOCU_DFLT to disable debug subdomains.
For this I wrote the following code:
#define CMPA_PAGE_LENGTH (512)
// Initialize ROM API for reading CMPA
flash_config_t flashInstance;
FFR_Init(&flashInstance);
// Allocate memory
cmpa_cfg_info_t* cmpaPageData = (cmpa_cfg_info_t*)calloc(CMPA_PAGE_LENGTH, 1);
if (cmpaPageData != NULL) {
// Read CMPA page back
FFR_GetCustomerData(&flashInstance, (uint8_t*)cmpaPageData, 0, CMPA_PAGE_LENGTH);
// Disable all debug subdomains by writing 1/0 for PIN/DFLT
cmpaPageData->dcfgPin = 0b1111111111;
// Mirror the value as described in the forum post
cmpaPageData->dcfgPin |= (~cmpaPageData->dcfgPin << 16);
cmpaPageData->dcfgDflt = 0b0000000000;
cmpaPageData->dcfgDflt |= (~cmpaPageData->dcfgDflt << 16);
// Disable ISP
cmpaPageData->bootCfg = 0b1110000;
// Write CMPA page
FFR_CustFactoryPageWrite(&flashInstance, (uint8_t*)cmpaPageData, false);
// Free allocated memory
free(cmpaPageData);
}
So for this we read the content from the CMPA page back, configure the CC_SOCU registers and write the page with the modified page content.
Result of running this is code is that the SWD and ISP are disabled, which is good. But additionally the application that was programmed will not run after resetting the microcontroller. The FFR_GetCustomerData function returns success status.
Next to this, I've attempted to leave out modifying the registers and just write the result of FFR_GetCustomerData back using FFR_CustFactoryPageWrite. This also had the same result.
I cannot find any clue in the documentation why our application won't run anymore after a reset/power-cycle. Is there something I'm missing? Is there another way to write CMPA from the application?