[SOLVED] Cannot connect to Adafruit M0 board with J-Link Commander ****** Error: InitTarget(): PCode returned with error code -1

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

  • [SOLVED] Cannot connect to Adafruit M0 board with J-Link Commander ****** Error: InitTarget(): PCode returned with error code -1

    I am trying to connect to both a Adafruit Feather M0 Express and a Adafruit Metro M0 Express using J-link Commander.
    I have tried both on a mac book pro running El Capitan and a Windows 10 Dell XPS 15 Laptop and am getting the same error on both.
    I have connected directly into the USB port without going through any hubs.
    I the J-link software today so I presume I am on the latest version.

    If anybody could assist or help me identify the problem that would be appreciated.
    The full output from J-Link commander is below







    SEGGER J-Link Commander V6.32g (Compiled Jun 15 2018 17:26:48)
    DLL version V6.32g, compiled Jun 15 2018 17:26:15



    Connecting to J-Link via USB...O.K.
    Firmware: J-Link EDU Mini V1 compiled Mar 29 2018 17:48:40
    Hardware version: V1.00
    S/N: 801001239
    License(s): GDB, FlashBP
    VTref=3.297V




    Type "connect" to establish a target connection, '?' for help
    J-Link>connect
    Please specify device / core. <Default>: ATSAMD21G18
    Type '?' for selection dialog
    Device>
    Please specify target interface:
    J) JTAG (Default)
    S) SWD
    TIF>S
    Specify target interface speed [kHz]. <Default>: 4000 kHz
    Speed>
    Device "ATSAMD21G18" selected.




    Connecting to target via SWD
    InitTarget()
    Secured Atmel SAMD device detected.
    For debugger connection the device needs to be unsecured.
    Note: Unsecuring will trigger a mass erase of the internal flash.
    Executing default behavior previously saved in the registry.
    Device will be unsecured now.
    InitTarget()
    Secured Atmel SAMD device detected.
    For debugger connection the device needs to be unsecured.
    Note: Unsecuring will trigger a mass erase of the internal flash.
    Executing default behavior previously saved in the registry.
    Device will be unsecured now.



    ****** Error: InitTarget(): PCode returned with error code -1



    InitTarget()
    Secured Atmel SAMD device detected.
    For debugger connection the device needs to be unsecured.
    Note: Unsecuring will trigger a mass erase of the internal flash.
    Executing default behavior previously saved in the registry.
    Device will be unsecured now.
    InitTarget()
    Secured Atmel SAMD device detected.
    For debugger connection the device needs to be unsecured.
    Note: Unsecuring will trigger a mass erase of the internal flash.
    Executing default behavior previously saved in the registry.
    Device will be unsecured now.



    ****** Error: InitTarget(): PCode returned with error code -1



    Cannot connect to target.
    J-Link>

  • Hello,

    Thank you for your inquiry.
    J-Link is trying to connect to the target but detects that it has been secured e.g. by the SSB bit: wiki.segger.com/ATSAM_Device_Series
    This can usually be recovered automatically by J-Link upon connect. However the SAM devices can also be locked permanently by disabling the debug interface. In such a case J-Link can't recover the device anymore.

    Is some application already running in the target that might block access from J-Link?
    Could you check if the Adafruit boards have some extra setting/pin/bootloader that needs to be enabled/configured to enable external debug access?

    We tried to reproduce the issue with a Genuino Zero and SAMD21 Xplained Pro board but in both cases locking and unlocking the device was working without any issues using J-Link.


    Best regards,

    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • I think it is fixed, It appears to be cable related.
    I managed to get connected to the Feather board on almost the first try today, but wasn't able to connect to either board reliably, that showed me that there wasn't an inherent reason that it would not work.
    But after lots of messing around with different USB ports and having the boards in different positions on my desk I noticed that getting a good connection depended on the position of the cable from the J-Link to the target board. Gently pulling the cable towards the USB connector seemed to get it working and then a squeeze on top of the IDC header got it working reliably.
  • Hello,

    Great to hear that you are up and running again.
    We will consider this thread as solved now.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.