locking / unlocking SWD debug on LPC550x

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

locking / unlocking SWD debug on LPC550x

600 Views
mmvm
Contributor I

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?

Labels (1)
0 Kudos
3 Replies

566 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

Could you please tell me where the function come from? SDK driver?

 

BR

Alice

0 Kudos

541 Views
mmvm
Contributor I

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

0 Kudos

536 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ,

About disable ISP and SWD, you can refer to attachment, this is from SE team.

About unlock, it seems need erase CMPA if can enter ISP mode.

 

BR

Alice

0 Kudos