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
  • Hi,

    Thank you for reporting the issue. We are looking into it. A suggested workaround for now is to replace line 32 in zephyr/scripts/west_commands/runners/jlink.py so that it looks like this:

        for root in [os.environ.get("ProgramFiles", ""), os.environ.get("ProgramFiles(x86)", ""), str(Path.home())]:

    Regarding the false positivies, which security software is reporting it?

Related