adafruit / Adafruit_nRF52_Arduino

Adafruit code for the Nordic nRF52 BLE SoC on Arduino
Other
610 stars 494 forks source link

Flashing bootloader with J-Link fails. #639

Closed pearson closed 3 years ago

pearson commented 3 years ago

Using the current Arduino IDE (v.1.8.15) and the current Adafruit nRF52 boards package (v0.21.0) under Windows 10, attempts to flash the bootloader to the Adafruit Bluefruit nRF52 feather fail with java.io.IOException: Cannot run program "nrfjprog.exe": CreateProcess error=2, The system cannot find the file specified.

The problem seems to be quite simple: the path to nrfjprog.exe is not being used, as seen in the verbose error log below. Adding the path to nrfjprog.exe to that command results in a successful flash.

This problem was previously mentioned 3 years ago in issue #127 . While the replies to issue #127 directed the user to the forums for help, this does appear to be a bug. Installing the Adafruit nRF52 boards package does not put nrfprog.exe onto the user's path, and so the flashing will fail.

Steps to repeat the process

  1. Install the Arduino IDE. This was tested with the Windows Store version followed by the portable ZIP file version.
  2. Follow nRF setup steps as outlined at BSP Installation.
    1. Add https://www.adafruit.com/package_adafruit_index.json as an 'Additional Board Manager URL',
    2. Restart the Arduino IDE.
    3. Open the Boards Manager option from the Tools -> Board menu and install 'Adafruit nRF52 by Adafruit', as outlined in BSP Installation.
  3. Follow the flashing steps outlined at Updating the Bootloader with a Segger J-Link and Arduino IDE.
    1. Select the Adafruit Bluefruit nRF52832 Feather in Tools -> Board -> Adafruit nRF52 Boards -> Adafruit Feather nRF52832
    2. Select the J-Link as programmer in Tools -> Programmer -> J-Link for Feather52
    3. Burn the bootloader using Tools -> Burn Bootloader

The result is the error:

Arduino: 1.8.15 (Windows 10), Board: "Adafruit Feather nRF52832, 0.3.2 SoftDevice s132 6.1.1, Level 0 (Release)"

nrfjprog.exe --program C:\Users\Chris\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0/bootloader/feather_nrf52832/feather_nrf52832_bootloader-0.3.2_s132_6.1.1.hex -f nrf52 --chiperase --reset 
java.io.IOException: Cannot run program "nrfjprog.exe": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at processing.app.helpers.ProcessUtils.exec(ProcessUtils.java:26)
    at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:129)
    at cc.arduino.packages.uploaders.SerialUploader.runCommand(SerialUploader.java:383)
    at cc.arduino.packages.uploaders.SerialUploader.burnBootloader(SerialUploader.java:375)
    at processing.app.Editor.lambda$handleBurnBootloader$61(Editor.java:2379)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
    at java.lang.ProcessImpl.start(ProcessImpl.java:137)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 6 more

Error while burning bootloader.

Solution

As mentioned above, adding the path to nrfjprog.exe results in a correct flashing.

hathach commented 3 years ago

Yeah, it is indeed as intended, please download and install nrfjprog from nordic site and make sure its location is added to PATH

https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Command-Line-Tools/Download#infotabs

UPDATE: I just realized, we did included nrfjprog v9.4 as depency tools, will update to get its path correctly. This will be resolved in the next release.