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

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.1.0.tar.gz (71.5 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.1.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nrf_ota-0.1.0.tar.gz
  • Upload date:
  • Size: 71.5 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.1.0.tar.gz
Algorithm Hash digest
SHA256 f9f11e61fd3fa90d56c2ccc865731e310220aa835b2c0fad80e4149b67acd7dc
MD5 95cfedc675ea614a596f55754cd52d08
BLAKE2b-256 4e5948f4fb6efa52c8e0103f7e8aabe7bbd7a13319717ecc129a613ac3e52630

See more details on using hashes here.

Provenance

The following attestation bundles were made for nrf_ota-0.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: nrf_ota-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c0ec29084521264d28cadeadbc16cfeaefa564426e935fb96acd68841746997
MD5 c598f2378dc654c27e4d18717ff24a2d
BLAKE2b-256 b3f5caabaa0e4bc4fa7730eb071e504d3b9d31843a300684a76effc11f441d91

See more details on using hashes here.

Provenance

The following attestation bundles were made for nrf_ota-0.1.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