Skip to main content

Python package for OTA updating the bootloader on nrf chips

Project description

Tests PyPI Python Version

nrf-ota

Flash firmware to Nordic nRF5x devices over BLE from Python. Implements the Nordic Legacy DFU protocol (nRF5 SDK ≤ 15.x) and works on Linux, macOS, and Windows.

Installation

pip install nrf-ota

CLI

No install required — run directly with uvx:

uvx nrf-ota firmware.zip                             # interactive device picker
uvx nrf-ota firmware.zip --device OD216205           # select by name (non-interactive)
uvx nrf-ota firmware.zip --device FC:06:1C:C8:DE:47  # select by address

Scans for nearby BLE devices, lets you pick one, and flashes the firmware. If the device is running application firmware the bootloader is triggered automatically.

Library

import asyncio
from nrf_ota import perform_dfu, scan_for_devices

async def main():
    devices = await scan_for_devices(timeout=5.0)

    await perform_dfu(
        "firmware.zip",
        devices[0],
        on_progress=lambda pct: print(f"\r{pct:.0f}%", end=""),
        on_log=print,
    )

asyncio.run(main())

API

perform_dfu(zip_path, device, *, on_progress=None, on_log=None, packets_per_notification=...)

Performs a full OTA update — triggers the bootloader if needed, waits for the device to reboot into DFU mode, transfers the firmware, and activates it.

Parameter Type Description
zip_path str Path to the Nordic DFU ZIP file
device BLEDevice | str Device from scan_for_devices, or a raw Bluetooth address
on_progress Callable[[float], None] Called with percentage (0–100) as firmware is sent
on_log Callable[[str], None] Called with status messages
packets_per_notification int Packets sent per receipt notification. Default: 8 on macOS, 10 elsewhere.

Raises DFUError on failure, DeviceNotFoundError if the bootloader can't be found after reboot.

scan_for_devices(timeout=5.0) -> list[BLEDevice]

Scans for nearby named BLE devices and returns a list of bleak.BLEDevice objects.

Exceptions

Exception Description
DFUError Base exception for all DFU failures
DeviceNotFoundError Bootloader not found after reboot

Platform notes

Works on Linux, macOS, and Windows via bleak. On macOS, the default packets_per_notification is lowered to 8 (from 10) to stay within CoreBluetooth's write-without-response flow control limits.

Development

git clone https://github.com/OpenDisplay-org/nrf-ota.git
cd nrf-ota
uv sync --all-extras

uv run pytest tests/ -v
uv run ruff check .
uv run mypy src/nrf_ota

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nrf_ota-0.2.0.tar.gz (73.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nrf_ota-0.2.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file nrf_ota-0.2.0.tar.gz.

File metadata

  • Download URL: nrf_ota-0.2.0.tar.gz
  • Upload date:
  • Size: 73.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nrf_ota-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2d759d35591a15f395b55c926f9fba7fd4c48473f77c5fe58f39c8995bf53831
MD5 f57839603d77ade424ac7b7e32ff4101
BLAKE2b-256 c721898646a7b8208e5fb91705e089e90803ceb93e345d35640d4876a47b188e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nrf_ota-0.2.0.tar.gz:

Publisher: release.yml on OpenDisplay-org/nrf-ota

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nrf_ota-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: nrf_ota-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nrf_ota-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4bdf44c84e65ed34fb3c05c64ae10ec0c627fde5e84997a234c3358eebd3e6e
MD5 4692ec0b1bd90fc54f389b41d0055a60
BLAKE2b-256 6410c6637235cfaa5c491995fcaf031c77dd5b92820e44333a12a78f21dbdbdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for nrf_ota-0.2.0-py3-none-any.whl:

Publisher: release.yml on OpenDisplay-org/nrf-ota

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page