Read/Write DP registers using JLinkARM.dll on a locked device

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Read/Write DP registers using JLinkARM.dll on a locked device

    I have a Silicon Labs Giant Gecko Starter Kit connected to the PC by USB. What I would like to do is to Lock the debug access to the device and then unlock it again using the JLinkARM.dll and SWD communication.

    First I verify that the device is not locked by reading the IDR register.
    In JLink commander I do this by writing:
    // First Write 0x000000F0 to SELECT to select
    // the last register bank of AP #0.
    SWDWriteDP 2 0x000000F0
    //Dummy-read the fourth register in this
    // bank (A[3:2] == 0b11), this is the IDR register.
    SWDReadAP 3
    // Read the RDBUFF register to get the
    // actual contents of IDR
    SWDReadDP 3

    This works perfectly fine.

    When I do the same thing by using the JLinkARM.dll I do this:

    JLINKARM_EMU_SelectByUSBSN(SerialNumber);
    JLINKARM_Open();
    JLINKARM_TIF_Select(JLINKARM_TIF_SWD);
    JLINKARM_SetSpeed(4000);
    JLINKARM_CORESIGHT_WriteAPDPReg(2, 0, 0x000000F0);
    JLINKARM_CORESIGHT_ReadAPDPReg(3, 1, Data);
    JLINKARM_CORESIGHT_ReadAPDPReg(3, 0, Data);

    When the device is unlocked this works fine and I get the expected result in the variable Data.

    However when I then lock the debug access to the device, I try to redo the sequence above to verify that the device is locked.

    When using the JLink Commander I get the expected result. But when I use the JLinkARM.dll I get an error when running the CORESIGHT_Write command. The errorcode is -1.

    I know that the device really is locked BTW.

    Why is this not working? Does anyone have any idea to help me debug this?
    I have attached a screenshot of what I get when I use the JLink Commander to read the IDR register on the locked device.

    Thanks in advance for your help!

    Regards,
    Kristian
    Images
    • Capture.JPG

      115.08 kB, 676×606, viewed 2,106 times

    The post was edited 2 times, last by ksskogva ().