I found some conflicting info on how to enable/disable ISP and SWD. After some trial and error, the below appears to lock a part, but unlocking after results in a bricked device (LPC5502);
static status_t set_locked_state(cmpa_context *ctx, cmpa_cfg_info_t *buffer, bool locked) {
// UM11424 pg. 136, table 184. ISP download mode based on DEFAULT_ISP_MODE bits (6:4, word 0 in CMPA)
const uint32_t kISPbits = 0x70;
// Do not follow UM11424 pg. 965, table 1000 - 1003. Debug access restriction levels
// See AN13037 3.2.3, PIN should be 1, DFLT 0 to "debug access always disabled (pinned)"
// Also see https://community.nxp.com/t5/LPC-Microcontrollers/CC-SOCU-DLFT-in-CMPA/m-p/1043919
const uint32_t kDBGbitsPin = 0xFF2000DF;
const uint32_t kDBGbitsDisable = 0xFFFF0000;
const uint32_t kDBGbitsEnable = 0x0000FFFF;
status_t ret = FFR_GetCustomerData(&ctx->flash_instance, (uint8_t*)buffer, 0, CMPA_PAGE_SIZE);
if(ret != kStatus_Success) {
return ret;
}
// Always pin (no debug auth)
buffer->dcfgPin = kDBGbitsPin;
if(locked) {
buffer->bootCfg |= kISPbits;
buffer->dcfgDflt = kDBGbitsDisable;
} else {
buffer->bootCfg &= ~kISPbits;
buffer->dcfgDflt = kDBGbitsEnable;
}
// Don't seal
return FFR_CustFactoryPageWrite(&ctx->flash_instance, (uint8_t*)buffer, false);
}
What values should I be using instead?
Hello,
Could you please tell me where the function come from? SDK driver?
BR
Alice
Hi Alice,
Apologies, I was unavailable for a bit. What function do you mean? The snippet is my code, FFR_GetCustomerData is in fsl_iap_ffr.h.
Thanks