Failed to flash with nRF Connect

Hello.

Thank you very much for releasing nRF Connect SDK v3.0.0-preview1.

I quickly tried the sample program, and while the build was successful, I encountered an issue with the flash operation.
The error is as follows:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\ncs\toolchains\8bd3ff36a2\opt\bin\Scripts\west.exe\__main__.py", line 7, in <module>
  File "C:\ncs\toolchains\8bd3ff36a2\opt\bin\Lib\site-packages\west\app\main.py", line 1085, in main
    app.run(argv or sys.argv[1:])
  File "C:\ncs\toolchains\8bd3ff36a2\opt\bin\Lib\site-packages\west\app\main.py", line 244, in run
    self.run_command(argv, early_args)
  File "C:\ncs\toolchains\8bd3ff36a2\opt\bin\Lib\site-packages\west\app\main.py", line 505, in run_command
    self.run_extension(args.command, argv)
  File "C:\ncs\toolchains\8bd3ff36a2\opt\bin\Lib\site-packages\west\app\main.py", line 623, in run_extension
    self.cmd = self.extensions[name].factory()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ncs\toolchains\8bd3ff36a2\opt\bin\Lib\site-packages\west\commands.py", line 546, in __call__
    mod = _commands_module_from_file(self.py_file)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ncs\toolchains\8bd3ff36a2\opt\bin\Lib\site-packages\west\commands.py", line 701, in _commands_module_from_file
    spec.loader.exec_module(mod)
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "C:\ncs\v3.0.0-preview1\zephyr\scripts\west_commands\flash.py", line 11, in <module>
    from run_common import add_parser_common, do_run_common, get_build_dir
  File "c:\ncs\v3.0.0-preview1\zephyr\scripts/west_commands\run_common.py", line 28, in <module>
    from runners.core import FileType
  File "c:\ncs\v3.0.0-preview1\zephyr\scripts/west_commands\runners\__init__.py", line 71, in <module>
    _import_runner_module(_name)
  File "c:\ncs\v3.0.0-preview1\zephyr\scripts/west_commands\runners\__init__.py", line 14, in _import_runner_module
    importlib.import_module(f'runners.{runner_name}')
  File "importlib\__init__.py", line 90, in import_module
  File "c:\ncs\v3.0.0-preview1\zephyr\scripts/west_commands\runners\jlink.py", line 39, in <module>
    for root in [os.environ["ProgramFiles"], os.environ["ProgramFiles(x86)"], str(Path.home())]: # noqa SIM112
                                             ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "<frozen os>", line 714, in __getitem__
KeyError: 'ProgramFiles(x86)'

In the "jlink.py" file, the "ProgramFiles(x86)" environment variable could not be found.
However, of course, the environment variable exists.
I created a simple Python script as shown below and executed it on the same PC, and the "ProgramFiles(x86)" environment variable was found.

import os

for key, value in os.environ.items():
	print(f"{key}: {value}")

..
PROGRAMDATA: C:\ProgramData
PROGRAMFILES: C:\Program Files
PROGRAMFILES(X86): C:\Program Files (x86)
PROGRAMW6432: C:\Program Files
..

I also added the same code to the "jlink.py" file, but it still couldn't find the "ProgramFiles(x86)" environment variable.

..
PROGRAMDATA: C:\ProgramData
PROGRAMFILES: C:\Program Files
PROGRAMW6432: C:\Program Files
..

This seems to be more of a Python-related question than an nRF Connect SDK issue, but what could be causing this discrepancy?

Thanks for reading.

a.da

P.S.
By the way, as a side note, my security software flagged the following files included in SDK Toolchain v3.0.0-preview1.
I hope this is just a false positive.

  • arm-zephyr-eabi-objcopy.exe
  • arm-zephyr-eabi-readelf.exe
Parents Reply Children
  •  

    Hi,

    I just pressed the Flash button in VS Code, but is there anything suspicious about the operation?

    The contents of the "board.cmake" file are as follows. It's the same as the file included in sdk-zephyr.
    Since I only flashed the sample program to the DK, there are no custom files of my own.

    # SPDX-License-Identifier: Apache-2.0
    
    if(CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP_NS)
      set(TFM_PUBLIC_KEY_FORMAT "full")
    endif()
    
    if(CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP OR CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP_NS)
    board_runner_args(jlink "--device=nrf5340_xxaa_app" "--speed=4000")
    endif()
    
    if(CONFIG_TFM_FLASH_MERGED_BINARY)
      set_property(TARGET runners_yaml_props_target PROPERTY hex_file tfm_merged.hex)
    endif()
    
    if(CONFIG_BOARD_NRF5340DK_NRF5340_CPUNET)
    board_runner_args(jlink "--device=nrf5340_xxaa_net" "--speed=4000")
    endif()
    
    include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/nrfutil.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)

    Kind regards,

    a.da

  • Thanks for the info. I assume you are building for the nRF5340 DK, correct?

Related