Removes the nordicsemi pip dependency (#669)
Tested on Linux, should work on Mac. We leave the responsibility to install `nrfutil` in version 6 to the user.
This commit is contained in:
26
deploy.py
26
deploy.py
@@ -23,6 +23,7 @@ import argparse
|
|||||||
import collections
|
import collections
|
||||||
import copy
|
import copy
|
||||||
import os
|
import os
|
||||||
|
from serial.tools import list_ports
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@@ -202,6 +203,12 @@ def assert_python_library(module: str):
|
|||||||
f"Try to run: pip3 install {module}"))
|
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):
|
class RemoveConstAction(argparse.Action):
|
||||||
|
|
||||||
# pylint: disable=redefined-builtin
|
# pylint: disable=redefined-builtin
|
||||||
@@ -703,10 +710,10 @@ class OpenSKInstaller:
|
|||||||
fatal("This board doesn't seem to support flashing through pyocd.")
|
fatal("This board doesn't seem to support flashing through pyocd.")
|
||||||
|
|
||||||
if self.args.programmer == "nordicdfu":
|
if self.args.programmer == "nordicdfu":
|
||||||
assert_mandatory_binary("nrfutil")
|
|
||||||
assert_python_library("intelhex")
|
assert_python_library("intelhex")
|
||||||
assert_python_library("nordicsemi.lister")
|
assert_mandatory_binary("nrfutil")
|
||||||
nrfutil_version = __import__("nordicsemi.version").version.NRFUTIL_VERSION
|
nrfutil_version = self.checked_command_output(["nrfutil", "version"])
|
||||||
|
nrfutil_version = nrfutil_version.removeprefix("nrfutil version ")
|
||||||
if not nrfutil_version.startswith("6."):
|
if not nrfutil_version.startswith("6."):
|
||||||
fatal(("You need to install nrfutil python3 package v6.0 or above. "
|
fatal(("You need to install nrfutil python3 package v6.0 or above. "
|
||||||
f"Found: v{nrfutil_version}. If you use Python >= 3.11, please "
|
f"Found: v{nrfutil_version}. If you use Python >= 3.11, please "
|
||||||
@@ -812,22 +819,17 @@ class OpenSKInstaller:
|
|||||||
info("Press [ENTER] when ready.")
|
info("Press [ENTER] when ready.")
|
||||||
_ = input()
|
_ = input()
|
||||||
# Search for the DFU devices
|
# Search for the DFU devices
|
||||||
serial_number = []
|
serial_numbers = list_serials(0x1915, 0x521F)
|
||||||
# pylint: disable=g-import-not-at-top,import-outside-toplevel
|
if not serial_numbers:
|
||||||
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:
|
|
||||||
fatal("Couldn't find any DFU device on your system.")
|
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.")
|
fatal("Multiple DFU devices are detected. Please only connect one.")
|
||||||
# Run the command without capturing stdout so that we show progress
|
# Run the command without capturing stdout so that we show progress
|
||||||
info("Flashing device using DFU...")
|
info("Flashing device using DFU...")
|
||||||
dfu_return_code = subprocess.run(
|
dfu_return_code = subprocess.run(
|
||||||
[
|
[
|
||||||
"nrfutil", "dfu", "usb-serial", f"--package={dfu_pkg_file}",
|
"nrfutil", "dfu", "usb-serial", f"--package={dfu_pkg_file}",
|
||||||
f"--serial-number={serial_number[0]}"
|
f"--serial-number={serial_numbers[0]}"
|
||||||
],
|
],
|
||||||
check=False,
|
check=False,
|
||||||
timeout=None,
|
timeout=None,
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ customize it.
|
|||||||
|
|
||||||
### Flashing using DFU (preferred method)
|
### Flashing using DFU (preferred method)
|
||||||
|
|
||||||
|
You need `nrfutil` version 6. The [install manual](../install.md) has
|
||||||
|
setup instructions.
|
||||||
|
|
||||||
To flash the firmware, run:
|
To flash the firmware, run:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ following:
|
|||||||
* python3 and pip (can be installed with the `python3-pip` package on Debian)
|
* 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
|
* the OpenSSL command line tool (can be installed and configured with the
|
||||||
`libssl-dev` and `pkg-config` packages on Debian)
|
`libssl-dev` and `pkg-config` packages on Debian)
|
||||||
* `nrfutil` (can be installed using `pip3 install nrfutil`) if you want to flash
|
* `nrfutil` (pip package of the same name), if you want to flash
|
||||||
a device with DFU
|
a device with DFU. Read the disclaimer below.
|
||||||
* `uuid-runtime` if you are missing the `uuidgen` command.
|
* `uuid-runtime` if you are missing the `uuidgen` command.
|
||||||
* `llvm` and `gcc-arm-none-eabi` if you want to use the upgradability feature.
|
* `llvm` and `gcc-arm-none-eabi` if you want to use the upgradability feature.
|
||||||
|
|
||||||
@@ -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
|
The scripts provided in this project have been tested under Linux and OS X. We
|
||||||
haven't tested them on Windows and other platforms.
|
haven't tested them on Windows and other platforms.
|
||||||
|
|
||||||
If you use Python newer than 3.10, then nrfutil for flashing over DFU is
|
You need `nrfutil` version 6, if you want to flash over DFU.
|
||||||
currently not supported. Please use Python 3.10, or play around with [Nordic's
|
The tool doesn't support Python newer than 3.10. Therefore, we don't officially
|
||||||
new tool](https://www.nordicsemi.com/Products/Development-tools/nrf-util)
|
support DFU for other versions. If you want to try regardless,
|
||||||
instead.
|
[Nordic's new tool](https://www.nordicsemi.com/Products/Development-tools/nrf-util)
|
||||||
|
might work for you.
|
||||||
|
|
||||||
### Compiling the firmware
|
### Compiling the firmware
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user