Can't flash or debug from vscode with Jlink Base

Hi!

I can't flash or debug with Jlink Base from vscode with nrf connect extension. Using embedded Jlink in nRF52840 DK or embedded Jlink in EVK-ANNA-B112, I have no problems, I can flash and debug.

With Jlink Base I receive the following error:

-- west flash: using runner pyocd
-- runners.pyocd: Flashing file: C:\Users\pedro.castro\Pedro\Git\FW_BLE_B112_SPP\Peripheral\build\zephyr\merged.hex
0002304:CRITICAL:__main__:Target type 'nrf52832' not recognized. Use 'pyocd list --targets' to see currently available target types. See <https://github.com/mbedmicro/pyOCD/blob/master/docs/target_support.md> for how to install additional target support.
Traceback (most recent call last):
  File "C:\ncs\toolchains\v2.0.2\opt\bin\Lib\site-packages\pyocd\board\board.py", line 61, in __init__
    self.target = TARGET[self._target_type](session)
KeyError: 'nrf52832'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\ncs\toolchains\v2.0.2\opt\bin\Lib\site-packages\pyocd\__main__.py", line 401, in run
    self._COMMANDS[self._args.cmd](self)
  File "C:\ncs\toolchains\v2.0.2\opt\bin\Lib\site-packages\pyocd\__main__.py", line 556, in do_flash
    session = ConnectHelper.session_with_chosen_probe(
  File "C:\ncs\toolchains\v2.0.2\opt\bin\Lib\site-packages\pyocd\core\helpers.py", line 242, in session_with_chosen_probe
    return Session(probe, auto_open=auto_open, options=options, **kwargs)
  File "C:\ncs\toolchains\v2.0.2\opt\bin\Lib\site-packages\pyocd\core\session.py", line 189, in __init__
    or Board(self, self.options.get('target_override'))
  File "C:\ncs\toolchains\v2.0.2\opt\bin\Lib\site-packages\pyocd\board\board.py", line 63, in __init__
    six.raise_from(exceptions.TargetSupportError(
  File "<string>", line 3, in raise_from
pyocd.core.exceptions.TargetSupportError: Target type 'nrf52832' not recognized. Use 'pyocd list --targets' to see currently available target types. See <https://github.com/mbedmicro/pyOCD/blob/master/docs/target_support.md> for how to install additional target support.
FATAL ERROR: command exited with status 1: pyocd flash -e sector -a 0x10000 -t nrf52832 -u 50128277 -f 400000 'C:\Users\pedro.castro\Pedro\Git\FW_BLE_B112_SPP\Peripheral\build\zephyr\merged.hex'

 *  The terminal process terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

If I follow this instructions in another PC, with a just restored Windows installation, same problem occurs.

I've tried pyocd list --targets from vscode console and nrf52832 appears as supported. pyocd load .\merged.hex --target nrf52832 also works, but the flashing process is extremely slow.

Flashing stopped working after uninstalling and re-installing nRF Connect SDK v2.0.2 with Nordic Toolchain Manager v1.2.5. I did it because debugging wasn't working with Jlink Base. Now neither debugging or flashing work.

I've attached the support information.

Thanks and kind regards!

Pedro.

1586.support information.zip

Parents
  • Hi,

    First, can you make sure that you have nRF Command Line Tools installed? If unsure, please re-install it.

    Secondly, can you try to flash the board with the J-link base outside of VS Code by using nRF Command Line Tools,

    You can start with listing the debugger:

    nrfjprog --ids

    Then you can try to recover the board:

    nrfjprog --recover

    Next, you can try to flash the board:

    nrfjprog --program <HEX> --chiperase --verify

    Did it work?

    regards

    Jared 

  • Hi Jared,

    can you make sure that you have nRF Command Line Tools installed?

    Yes, I already re-installed it a couple of times.

    Did it work?

    Yes, from Windows console it works perfectly.

    I think the problem might be that when I launch flashing from vscode

    it does not use nrfjprog, it uses pyocd.

    -- west flash: using runner pyocd
    -- runners.pyocd: Flashing file: ...

    Any way to use nrfjprog from vscode, when using Jlink Base? (When using embedded jlink in evaluation boards, nrfjprog is the one used).

    Regards,

    Pedro.

  • Hi,

    Hmm I think something in your settings might be wrong, I tried connecting my J-link Base program the blinky sample from the VS Code and as you can see from the log it uses nRF Command Line Tools by default. I would just suggest re installing the VS code if you haven't already. 

    Log:

     *  Executing task: nRF Connect: Flash: blinky/build (active) 
    
    Flashing build to 50113943
    C:\WINDOWS\system32\cmd.exe /d /s /c "west flash -d c:\Users\....\blinky\build --skip-rebuild --dev-id ...."
    
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: Flashing file: c:\Users\....\blinky\build\zephyr\zephyr.hex
    Parsing image file.
    Verifying programming.
    Verified OK.
    Enabling pin reset.
    Applying pin reset.
    -- runners.nrfjprog: Board with serial number ..... flashed successfully.
     *  Terminal will be reused by tasks, press any key to close it. 

    Maybe you could also try to disable pyocd if it's an extension that you have enabled?

    regards

    Jared 

  • Hi Jared,

    I've partially solved the issue. It's a problem with the board.cmake file in Zephyr repo for arduino_nicla_sense_me board. It originally had the following content:

    # SPDX-License-Identifier: Apache-2.0
    
    board_runner_args(pyocd "--target=nrf52832" "--frequency=400000")
    include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)

    Only pyocd is included for this board. This board uses an integrated programmer/debugger based on CMSIS-DAP protocol, but nrf connect extension in vscode does not detect it as a programmer, so I have to use an external Jlink. 

    Any way for nrf connect extension to detect a CMSIS-DAP based debugger?

    I had to change board.cmake in Zephyr repository (Any way to override it locally, in the project folders?) to the following, to be able to flash using Jlink:

    # SPDX-License-Identifier: Apache-2.0
    
    board_runner_args(jlink "--device=nrf52" "--speed=4000")
    board_runner_args(pyocd "--target=nrf52832" "--frequency=4000000")
    
    include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
     

    Now I can flash using Jlink and nrfjprog, but I can't debug.

    When I try to debug I receive the following message:

    Do you think is something related with the board.cmake content?

    Thanks again and kind regards,

    Pedro.

  • Hi,

    Exactly what kind of onboard debugger is it? As far as I know, we only support SEGGER J-link debuggers.

    Also, looking at the Zephyr doc for the board, it looks like it should be programmable via west as well, it doesn't mention needing a stand alone debugger,

    regards

    Jared

  • Hi Jared,

    I'm not sure how to use west to program or debug. Can I visually debug using vscode with west?

    Anyway, I need my Jlink Base work for debugging, because I need to debug directly in our custom board (Product board, designed by us), which do not have any integrated programmer/debugger.

    Do you think is something related with the board.cmake content?

    Thanks again and kind regards,

    Pedro.

  • Hi,

    West can be run from the command line in vs code.

    I think you need to create a new board that is similar but has the modified board.cmake file, I don't think it's possible to change it locally with say an overlay. 

    regards

    Jared 

Reply Children
No Data
Related