west flash failed with KeyError: 'NRF52' with ncs v2.4.0 on Ubuntu 22.04

west flash
inja: no work to do.
-- west flash: using runner nrfjprog
Using board 801036305
-- runners.nrfjprog: Flashing file: /home/henry/ncs/v2.4.0/nrf/samples/minimal_log/build/zephyr/merged.hex
Traceback (most recent call last):
  File "/home/henry/ncs/toolchains/1f9b40e71a/usr/local/bin/west", line 8, in <module>
    sys.exit(main())
  File "/home/henry/ncs/toolchains/1f9b40e71a/usr/local/lib/python3.8/site-packages/west/app/main.py", line 866, in main
    app.run(argv or sys.argv[1:])
  File "/home/henry/ncs/toolchains/1f9b40e71a/usr/local/lib/python3.8/site-packages/west/app/main.py", line 111, in run
    self.run_command(argv)
  File "/home/henry/ncs/toolchains/1f9b40e71a/usr/local/lib/python3.8/site-packages/west/app/main.py", line 385, in run_command
    self.run_extension(args.command, argv)
  File "/home/henry/ncs/toolchains/1f9b40e71a/usr/local/lib/python3.8/site-packages/west/app/main.py", line 467, in run_extension
    self.cmd.run(args, unknown, self.topdir, manifest=self.manifest,
  File "/home/henry/ncs/toolchains/1f9b40e71a/usr/local/lib/python3.8/site-packages/west/commands.py", line 194, in run
    self.do_run(args, unknown)
  File "/home/henry/ncs/v2.4.0/zephyr/scripts/west_commands/flash.py", line 32, in do_run
    do_run_common(self, my_args, runner_args, domains=domains)
  File "/home/henry/ncs/v2.4.0/zephyr/scripts/west_commands/run_common.py", line 174, in do_run_common
    do_run_common_image(command, user_args, user_runner_args, d.build_dir)
  File "/home/henry/ncs/v2.4.0/zephyr/scripts/west_commands/run_common.py", line 250, in do_run_common_image
    runner.run(command_name)
  File "/home/henry/ncs/v2.4.0/zephyr/scripts/west_commands/runners/core.py", line 611, in run
    self.do_run(command, **kwargs)
  File "/home/henry/ncs/v2.4.0/zephyr/scripts/west_commands/runners/nrf_common.py", line 398, in do_run
    self.program_hex()
  File "/home/henry/ncs/v2.4.0/zephyr/scripts/west_commands/runners/nrf_common.py", line 260, in program_hex
    self.flush(force=False)
  File "/home/henry/ncs/v2.4.0/zephyr/scripts/west_commands/runners/nrf_common.py", line 188, in flush
    self.flush_ops(force=force)
  File "/home/henry/ncs/v2.4.0/zephyr/scripts/west_commands/runners/nrf_common.py", line 375, in flush_ops
    self.do_exec_op(self.ops.popleft(), force)
  File "/home/henry/ncs/v2.4.0/zephyr/scripts/west_commands/runners/nrfjprog.py", line 91, in do_exec_op
    self.check_call(cmd + ['-f', families[self.family]] + core_opt +
KeyError: 'NRF52'

  • Hi,

    It looks like you might have missed some steps in the installation procedure. Are you able to compile any other nRF Connect SDK samples through with either command line or through the Visual Studio Code extension?

    Could you retrace the installation steps either through https://academy.nordicsemi.com/topic/exercise-1-1/ or https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/getting_started/assistant.html and make sure that nrfutil and nrf command line tools are properly installed

    Kind regards,
    Andreas

  • Hi,

    I just updated SDK to v2.4.0 and I have the same problem with our custom nrf9160 board. Flashing works on SDK 2.3.0 without any issues.

    Flashing build to 821010929
    /bin/sh -c west flash -d /home/eetnev/git/ncs/v2.4.0/zephyr/samples/hello_world/build --skip-rebuild --dev-id 821010929 --erase
    
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: mass erase requested
    -- runners.nrfjprog: Flashing file: /home/eetnev/git/ncs/v2.4.0/zephyr/samples/hello_world/build/zephyr/merged.hex
    Traceback (most recent call last):
      File "/home/eetnev/git/ncs/toolchains/1f9b40e71a/usr/local/bin/west", line 8, in <module>
        sys.exit(main())
      File "/home/eetnev/git/ncs/toolchains/1f9b40e71a/usr/local/lib/python3.8/site-packages/west/app/main.py", line 866, in main
        app.run(argv or sys.argv[1:])
      File "/home/eetnev/git/ncs/toolchains/1f9b40e71a/usr/local/lib/python3.8/site-packages/west/app/main.py", line 111, in run
        self.run_command(argv)
      File "/home/eetnev/git/ncs/toolchains/1f9b40e71a/usr/local/lib/python3.8/site-packages/west/app/main.py", line 385, in run_command
        self.run_extension(args.command, argv)
      File "/home/eetnev/git/ncs/toolchains/1f9b40e71a/usr/local/lib/python3.8/site-packages/west/app/main.py", line 467, in run_extension
        self.cmd.run(args, unknown, self.topdir, manifest=self.manifest,
      File "/home/eetnev/git/ncs/toolchains/1f9b40e71a/usr/local/lib/python3.8/site-packages/west/commands.py", line 194, in run
        self.do_run(args, unknown)
      File "/home/eetnev/git/ncs/v2.4.0/zephyr/scripts/west_commands/flash.py", line 32, in do_run
        do_run_common(self, my_args, runner_args, domains=domains)
      File "/home/eetnev/git/ncs/v2.4.0/zephyr/scripts/west_commands/run_common.py", line 174, in do_run_common
        do_run_common_image(command, user_args, user_runner_args, d.build_dir)
      File "/home/eetnev/git/ncs/v2.4.0/zephyr/scripts/west_commands/run_common.py", line 250, in do_run_common_image
        runner.run(command_name)
      File "/home/eetnev/git/ncs/v2.4.0/zephyr/scripts/west_commands/runners/core.py", line 611, in run
        self.do_run(command, **kwargs)
      File "/home/eetnev/git/ncs/v2.4.0/zephyr/scripts/west_commands/runners/nrf_common.py", line 398, in do_run
        self.program_hex()
      File "/home/eetnev/git/ncs/v2.4.0/zephyr/scripts/west_commands/runners/nrf_common.py", line 260, in program_hex
        self.flush(force=False)
      File "/home/eetnev/git/ncs/v2.4.0/zephyr/scripts/west_commands/runners/nrf_common.py", line 188, in flush
        self.flush_ops(force=force)
      File "/home/eetnev/git/ncs/v2.4.0/zephyr/scripts/west_commands/runners/nrf_common.py", line 375, in flush_ops
        self.do_exec_op(self.ops.popleft(), force)
      File "/home/eetnev/git/ncs/v2.4.0/zephyr/scripts/west_commands/runners/nrfjprog.py", line 91, in do_exec_op
        self.check_call(cmd + ['-f', families[self.family]] + core_opt +
    KeyError: 'NRF91'
    
     *  The terminal process terminated with exit code: 1. 
     *  Terminal will be reused by tasks, press any key to close it.

    Flashing nrf9160dk seems to work.

     Flashing build to 960035939
    /bin/sh -c west flash -d /home/eetnev/git/ncs/v2.4.0/zephyr/samples/hello_world/build --skip-rebuild --dev-id 960035939 --erase
    
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: mass erase requested
    -- runners.nrfjprog: Flashing file: /home/eetnev/git/ncs/v2.4.0/zephyr/samples/hello_world/build/zephyr/merged.hex
    Parsing image file.
    Verifying programming.
    Verified OK.
    Applying pin reset.
    -- runners.nrfjprog: Board with serial number 960035939 flashed successfully.
     *  Terminal will be reused by tasks, press any key to close it. 

    Edit:

    I updated our board.cmake using ncs/v2.4.0/zephyr/boards/arm/nrf9160dk_nrf9160/board.cmake and flashing started to work.

  • Thanks for your great support! I can flash successfully after modifying board.cmake as follows.

    board_runner_args(nrfjprog "--softreset")
    board_runner_args(jlink "--device=nRF52832_xxAA" "--speed=4000")
    include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)

Related