Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczmarczyck authored Dec 15, 2023
2 parents a3967bb + 5fdc6e0 commit 55adb37
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
26 changes: 14 additions & 12 deletions deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import collections
import copy
import os
from serial.tools import list_ports
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -202,6 +203,12 @@ def assert_python_library(module: str):
f"Try to run: pip3 install {module}"))


def list_serials(vid: int, pid: int) -> List[str]:
ports = list_ports.comports()
ports = filter(lambda p: p.vid == vid and p.pid == pid, ports)
return list(map(lambda p: p.serial_number, ports))


class RemoveConstAction(argparse.Action):

# pylint: disable=redefined-builtin
Expand Down Expand Up @@ -703,10 +710,10 @@ def check_prerequisites(self):
fatal("This board doesn't seem to support flashing through pyocd.")

if self.args.programmer == "nordicdfu":
assert_mandatory_binary("nrfutil")
assert_python_library("intelhex")
assert_python_library("nordicsemi.lister")
nrfutil_version = __import__("nordicsemi.version").version.NRFUTIL_VERSION
assert_mandatory_binary("nrfutil")
nrfutil_version = self.checked_command_output(["nrfutil", "version"])
nrfutil_version = nrfutil_version.removeprefix("nrfutil version ")
if not nrfutil_version.startswith("6."):
fatal(("You need to install nrfutil python3 package v6.0 or above. "
f"Found: v{nrfutil_version}. If you use Python >= 3.11, please "
Expand Down Expand Up @@ -812,22 +819,17 @@ def run(self) -> int:
info("Press [ENTER] when ready.")
_ = input()
# Search for the DFU devices
serial_number = []
# pylint: disable=g-import-not-at-top,import-outside-toplevel
from nordicsemi.lister import device_lister
for device in device_lister.DeviceLister().enumerate():
if device.vendor_id == "1915" and device.product_id == "521F":
serial_number.append(device.serial_number)
if not serial_number:
serial_numbers = list_serials(0x1915, 0x521F)
if not serial_numbers:
fatal("Couldn't find any DFU device on your system.")
if len(serial_number) > 1:
if len(serial_numbers) > 1:
fatal("Multiple DFU devices are detected. Please only connect one.")
# Run the command without capturing stdout so that we show progress
info("Flashing device using DFU...")
dfu_return_code = subprocess.run(
[
"nrfutil", "dfu", "usb-serial", f"--package={dfu_pkg_file}",
f"--serial-number={serial_number[0]}"
f"--serial-number={serial_numbers[0]}"
],
check=False,
timeout=None,
Expand Down
3 changes: 3 additions & 0 deletions docs/boards/nrf52840_dongle.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ customize it.

### Flashing using DFU (preferred method)

You need `nrfutil` version 6. The [install manual](../install.md) has
setup instructions.

To flash the firmware, run:

```shell
Expand Down
13 changes: 7 additions & 6 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ following:
* python3 and pip (can be installed with the `python3-pip` package on Debian)
* the OpenSSL command line tool (can be installed and configured with the
`libssl-dev` and `pkg-config` packages on Debian)
* `nrfutil` (can be installed using `pip3 install nrfutil`) if you want to flash
a device with DFU
* `nrfutil` (pip package of the same name), if you want to flash
a device with DFU. Read the disclaimer below.
* `uuid-runtime` if you are missing the `uuidgen` command.
* `llvm` and `gcc-arm-none-eabi` if you want to use the upgradability feature.

Expand All @@ -37,10 +37,11 @@ instructions to appropriate binaries for your system.
The scripts provided in this project have been tested under Linux and OS X. We
haven't tested them on Windows and other platforms.

If you use Python newer than 3.10, then nrfutil for flashing over DFU is
currently not supported. Please use Python 3.10, or play around with [Nordic's
new tool](https://www.nordicsemi.com/Products/Development-tools/nrf-util)
instead.
You need `nrfutil` version 6, if you want to flash over DFU.
The tool doesn't support Python newer than 3.10. Therefore, we don't officially
support DFU for other versions. If you want to try regardless,
[Nordic's new tool](https://www.nordicsemi.com/Products/Development-tools/nrf-util)
might work for you.

### Compiling the firmware

Expand Down

0 comments on commit 55adb37

Please sign in to comment.