U32 _aPINMode[8]; // JLINK_PIN_MAX_NUM_PINS U32 _aPINState[8]; // JLINK_PIN_MAX_NUM_PINS int InitTarget(void) { int v; int Key0; int Key1; int i; int r; i = 0; do { _aPINMode[i] = JLINK_PIN_OVERRIDE_MODE_RELEASE; // Do not override any pin by default i += 1; } while(i < JLINK_PIN_MAX_NUM_PINS); // // Initially, we check if pin override is supported // r = JLINK_PIN_Override(&_aPINMode[0], &_aPINState[0]); if (r < 0) { JLINK_SYS_Report("ERROR: Pin override is not supported by the connected J-Link"); return r; } JLINK_SYS_Report1("START pin JTAG_MOD => ", _aPINState[7]); _aPINMode[7] = JLINK_PIN_OVERRIDE_MODE_PIO_OUT_HIGH; JLINK_SYS_Report1("START2 pin JTAG_MOD => ", _aPINState[7]); r = JLINK_PIN_Override(&_aPINMode[0], &_aPINState[0]); JLINK_SYS_Report1("START3 pin JTAG_MOD => ", _aPINState[7]); JLINK_SYS_Report("Set pin JTAG_MOD => 1"); // Secure response stored @ 0x600, 0x610 in eFUSE region (OTP memory) Key0 = 0x12345678; Key1 = 0x12345678; JLINK_CORESIGHT_Configure("IRPre=0;DRPre=0;IRPost=0;DRPost=0;IRLenDevice=5"); CPU = CORTEX_M7; JLINK_SYS_Sleep(100); JLINK_JTAG_WriteIR(0xC); // Output Challenge instruction // Readback Challenge, Shift 64 dummy bits on TDI JLINK_JTAG_StartDR(); JLINK_SYS_Report("Reading Challenge ID...."); // 32-bit dummy write on TDI / read 32 bits on TDO JLINK_JTAG_WriteDRCont(0xffffffff, 32); v = JLINK_JTAG_GetU32(0); JLINK_SYS_Report1("Challenge UUID0:", v); JLINK_JTAG_WriteDREnd(0xffffffff, 32); v = JLINK_JTAG_GetU32(0); JLINK_SYS_Report1("Challenge UUID1:", v); JLINK_JTAG_WriteIR(0xD); // Output Response instruction JLINK_JTAG_StartDR(); JLINK_JTAG_WriteDRCont(Key0, 32); JLINK_JTAG_WriteDREnd(Key1, 24); _aPINMode[7] = JLINK_PIN_OVERRIDE_MODE_PIO_OUT_LOW; JLINK_SYS_Report1("START4 pin JTAG_MOD => ", _aPINState[7]); r = JLINK_PIN_Override(&_aPINMode[0], &_aPINState[0]); JLINK_SYS_Report1("START5 pin JTAG_MOD => ", _aPINState[7]); JLINK_SYS_Report("Change pin JTAG_MOD => 0"); return 0; }