Errors when attempting to flash target from nRF Connect

I've been having problems getting nRF Connect to flash a target through my J-Link programmer lately, even though it has historically worked fine. I suspected the issue might be related to network-enforced security settings, and my IT department created an exemption for my computer. It may be that I need to make sure certain executables run with administrator rights, and I've been going around flagging everything I think might be relevant with "Run as administrator," but I haven't had any luck so far. I'll paste the full text from the build attempt below.

Do I need to set some particular executables to run as administrator, and I've just not hit the correct one yet? What program is being referenced here that needs elevated priveleges?

My first thought was python.exe, but there are different instances of it so maybe I did the wrong ones. I did these:

C:\Program Files\Python311\python.exe
C:\Users\scase\AppData\Local\Programs\Python\Python311\python.exe
C:\Users\scase\AppData\Local\Programs\Python\Python314\python.exe
C:\sandbox\nRF_Connect\toolchains\v2.2.0\opt\bin\python.exe

Thanks!

Scott

Flashing build to J-Link Ultra+
west flash -d c:\gitRepos\GR3_Firmware\build -i 504500724

-- west flash: rebuilding
[0/4] Performing build step for 'mcuboot_subimage'
ninja: no work to do.
-- west flash: using runner jlink
-- runners.jlink: JLink version: 7.96i
-- runners.jlink: Flashing file: C:\gitRepos\GR3_Firmware\build\zephyr\merged.hex
Traceback (most recent call last):
File "runpy.py", line 197, in _run_module_as_main
File "runpy.py", line 87, in _run_code
File "C:\ncs\toolchains\cf2149caf2\opt\bin\Scripts\west.exe\__main__.py", line 7, in <module>
File "C:\ncs\toolchains\cf2149caf2\opt\bin\Lib\site-packages\west\app\main.py", line 1085, in main
app.run(argv or sys.argv[1:])
File "C:\ncs\toolchains\cf2149caf2\opt\bin\Lib\site-packages\west\app\main.py", line 244, in run
self.run_command(argv, early_args)
File "C:\ncs\toolchains\cf2149caf2\opt\bin\Lib\site-packages\west\app\main.py", line 505, in run_command
self.run_extension(args.command, argv)
File "C:\ncs\toolchains\cf2149caf2\opt\bin\Lib\site-packages\west\app\main.py", line 654, in run_extension
self.cmd.run(args, unknown, self.topdir, manifest=self.manifest,
File "C:\ncs\toolchains\cf2149caf2\opt\bin\Lib\site-packages\west\commands.py", line 194, in run
self.do_run(args, unknown)
File "C:\sandbox\nRF_Connect\v2.2.0\zephyr\scripts\west_commands\flash.py", line 32, in do_run
do_run_common(self, my_args, runner_args, domains=domains)
File "c:\sandbox\nRF_Connect\v2.2.0\zephyr\scripts/west_commands\run_common.py", line 178, in do_run_common
do_run_common_image(command, user_args, user_runner_args, d.build_dir)
File "c:\sandbox\nRF_Connect\v2.2.0\zephyr\scripts/west_commands\run_common.py", line 254, in do_run_common_image
runner.run(command_name)
File "c:\sandbox\nRF_Connect\v2.2.0\zephyr\scripts/west_commands\runners\core.py", line 551, in run
self.do_run(command, **kwargs)
File "c:\sandbox\nRF_Connect\v2.2.0\zephyr\scripts/west_commands\runners\jlink.py", line 244, in do_run
self.flash(**kwargs)
File "c:\sandbox\nRF_Connect\v2.2.0\zephyr\scripts/west_commands\runners\jlink.py", line 345, in flash
self.check_call(cmd, **kwargs)
File "c:\sandbox\nRF_Connect\v2.2.0\zephyr\scripts/west_commands\runners\core.py", line 662, in check_call
subprocess.check_call(cmd, **kwargs)
File "subprocess.py", line 368, in check_call
File "subprocess.py", line 349, in call
File "subprocess.py", line 951, in __init__
File "subprocess.py", line 1420, in _execute_child
OSError: [WinError 740] The requested operation requires elevation

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

Parents Reply
  • Thank you, Vidar.

    I found that any time jlink.exe is called, I get a UAC prompt. This was because in troubleshooting problems, I had set it to run as admin. If I remove that "Run as Administrator" flag on jlink.exe, the Python error goes away and I'm back to the original error I had before. So I suspect then that this error message is one that I myself created in trying to troubleshoot the original problem.

    The original error is:

    FATAL ERROR: command exited with status 1: 'C:\Program Files\SEGGER\JLink_V796i\JLink.exe' -USB 504500724 -nogui 1 -if swd -speed 4000 -device nRF52840_xxAA -CommanderScript 'C:\Users\scase\AppData\Lo
    cal\Temp\tmp2p100s21jlink\runner.jlink' -nogui 1

    Do you think it would be productive for me to try nrfjprog? Previously, I could select it via dropdown in the settings for the nrf Connect plugin in VSCode, but I don't see that option now. How can I force the plugin to use nrfjprog? (If you think this would be a productive path to try).

    Also, if it would be better for me to create a new post for the second error message, just to keep things clear and organized, I can do that.

    Thank you for any help or advice you can provide.

    Scott

Children
  • Hi Scott,

    Thanks, that explains the initial error. Unfortunately the generic error you are seeing now isn't as helpful and I don't see anything obviously wrong with the command either. Have you tried checking if the file  in this path: C:\Users\scase\AppData\Local\Temp\tmp2p100s21jlink\runner.jlink actually exits, and if so, tried to see if you are able to run the same command directly from the command prompt? If the command fails, maybe it will give a more descriptive error at least.

    cscase said:
    Do you think it would be productive for me to try nrfjprog? Previously, I could select it via dropdown in the settings for the nrf Connect plugin in VSCode, but I don't see that option now. How can I force the plugin to use nrfjprog? (If you think this would be a productive path to try).

    The extension was using nrfjprog for board discovery (discovering connected Jlink debug probes). Now it is using nrfutil for the same, but this still does not control what "west flash" uses as this is defined by your board target (e.g., here for the nrf52840 DK: https://github.com/nrfconnect/sdk-zephyr/blob/c0689b16ff127d1b71a4cc20310d476e1807e26e/boards/arm/nrf52840dk_nrf52840/board.cmake#L5C7-L5C39 )

    I do think it's worth trying with nrfjprog. I doesn't look like it's using the temp folder for any temporary storage, maybe that will make a difference. You can do this by opening the terminal from VS code in your project as shown below (this ensures the toolchain environment and everything else needed to build project is set):

    Then run the following command to flash the device with the "nrfjprog" runner instead of "jlink" which seems to be the default for the board you are targeting:

    west flash --runner nrfjprog

    Best regards,

    Vidar

  • Vidar,

    Many thanks for your kind help!  I had to add the line like shown in your link to the board.cmake file:

    include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)

    And then I had to untick the "Run as administrator" that I had added to binaries in C:\Program Files\Nordic Semiconductor\nrf-command-line-tools\bin.

    And now after running the command you have above, it does build and flash successfully. I suspect there was something going on that I don't fully understand, but for the moment things are good and I can resume work and I am very grateful for your help.

    Scott

Related