VS Code Debug/Flash works once, then fails on second instantiation

I have been able to identify and repeat an issue with the nrf tools via VS Code.  The problem, is that after I build and debug one time, any subsequent attempt to flash the HW (nrf9160 dk) results in the following error message (below).  I have included the part of the log that shows the flash working the first time.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
* Executing task: nRF Connect: Flash: dect-demo/build (active)
Flashing build to 960084282
/bin/sh -c west flash -d /Users/jpnorair/.../build --skip-rebuild --dev-id 960084282
-- west flash: using runner nrfjprog
-- runners.nrfjprog: Flashing file: /Users/jpnorair/.../build/zephyr/merged.hex
[ #################### ] 4.555s | Erase file - Done erasing
[ #################### ] 1.110s | Program file - Done programming
[ #################### ] 1.024s | Verify file - Done verifying
Applying pin reset.
-- runners.nrfjprog: Board with serial number 960084282 flashed successfully.
* Terminal will be reused by tasks, press any key to close it.
* Executing task: nRF Connect: Flash: dect-demo/build (active)
Flashing build to 960084282
/bin/sh -c west flash -d /Users/jpnorair/.../build --skip-rebuild --dev-id 960084282
-- west flash: using runner nrfjprog
-- runners.nrfjprog: Flashing file: /Users/jpnorair/.../build/zephyr/merged.hex
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I'm using an M1 Mac, and I've reviewed the results of the following tickets, which have some similarity.  My experience is different, because I have no trouble identifying/detecting the device or using the NRF programmer tool.

https://devzone.nordicsemi.com/f/nordic-q-a/83279/nrf-connect-for-vs-code-unable-to-connect-to-device/346241?focus=true

 NRF Connect - Programmer Fails to Connect to Device 9160-DK JLINKARM_DLL_COULD_NOT_BE_OPENED 

I can, however, acknowledge that the issue seems to be in the 'nrfutil-device' program.  This program is getting stuck, and it needs to be terminated.  I can workaround the issue by the following means:

  1. Quit VScode
  2. terminate 'nrfutil-device'
  3. turn off devkit
  4. turn on devkit
  5. restart VScode

Then, I can get one more flash to the target.

Here is a screenshot of 'nrfutil-device' in my activity monitor, hanging around after I quit VSCode.  It's an intel-binary app.

Here is a second screenshot of the 'nrf' named processes during a successful debug and flash.  Notice: the other tools are Apple-silicon.  I installed everything through the NRFConnect app using the automatic mode, so whatever is here is the default.  (You can disregard the "https://..." line, that's a website I must be looking-at now).

Anyway, I'd like to know if there are any workarounds.  I have a team of engineers using M1/M2 macs who will need to use the debug tools for the NRF91 Slight smile.  If there's anything I can do on my end, such as rebuilding nrfutil-device, just let me know.

Best regards,

JPN

  • Update: I have found another workaround.

    1. Try to debug --> get the error message.  It is important to get the error.
    2. unmount the mass storage device that gets mounted when the dev kit is plugged-in.
    3. turn-off the dev kit
    4. turn-on the dev kit
    5. Debug again --> works.
  • Hi John,

    Could you try nrfjprog --recover? After this, please try to flash and then let me know how it goes?

    Best Regards,

    Priyanka

  • Here is what I did:

    1. Attempt to debug board, and get error
    2. call nrfjprog --recover.  This was successful.
    3. Try to debug again.  This resulted in a new error (shown below).

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    * Executing task: nRF Connect: Flash: .../build (active)
    Flashing build to 960084282
    /bin/sh -c west flash -d /Users/jpnorair/.../build --skip-rebuild --dev-id 960084282
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: Flashing file: /Users/jpnorair/.../build/zephyr/merged.hex
    [ #################### ] 4.471s | Erase file - Done erasing
    [ #################### ] 1.106s | Program file - Done programming
    [ #################### ] 1.022s | Verify file - Done verifying
    [error] [ Client] - Encountered error -254: Worker process is dead, cannot execute command.
    ERROR: An internal error has occurred, please try again.
    NOTE: For additional output, try running again with logging enabled (--log).
    NOTE: Any generated log error messages will be displayed.
    FATAL ERROR: command exited with status 63: nrfjprog --pinreset -f NRF91 --snr 960084282
    * The terminal process terminated with exit code: 63.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Next, I tried to debug again, just to see.  It worked this time.  However, when I stop the debugging session, again the device gets stuck during programming (same old error).

  • What is the nrf CmmandLine Tools version that you have installed?

    Please try nrfjprog --version for this.

    -Priyanka

  • Fullscreen
    1
    2
    3
    % nrfjprog --version
    nrfjprog version: 10.21.0 external
    JLinkARM.dll version: 7.80c
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

1 2