This is my fork of mdxs's fork of astronomer80's fork of foldedtoad's Python OTA DFU utility. The goal of this fork is to achieve:
- Python3 support
- Work with the secure bootloader of nRF SDK15+
This is a Python program that uses gatttool (provided with the Linux BlueZ driver) to achieve Over The Air (OTA) Device Firmware Updates (DFU) to a Nordic Semiconductor nRF52 device via Bluetooth Low Energy (BLE).
- Perform OTA DFU to an nRF5 peripheral without an external USB BLE dongle.
- Ability to detect if the peripheral is running in application mode or bootloader, and automatically switch if needed (buttonless).
- Support for Secure bootloader.
- BlueZ 5.4 or above
- Python 3 (tested with 3.9)
- Python
pexpectmodule (available via pip) - Python
intelhexmodule (available via pip)
Generate your DFU package using nrfutil and run the dfu script.
$ python3 dfu.py firmware.zip CD:E3:4A:47:1C:E4
You can use the hcitool lescan to figure out the address of a DFU target, for example:
$ sudo hcitool -i hci0 lescan
LE Scan ...
CD:E3:4A:47:1C:E4 <TARGET_NAME>
CD:E3:4A:47:1C:E4 (unknown)
$ python3 dfu.py firmware.zip CD:E3:4A:47:1C:E4
================================
== ==
== DFU Server ==
== Jurpp Fork ==
== ==
================================
Sending file firmware.bin to CD:E3:4A:47:1C:E4
Binary imge size: 177280
Binary CRC32: 2822816268
Connecting to CD:E3:4A:47:1C:E4
Checking DFU State...
Init packet successfully transfered
Max object size: 4096, num objects: 44, offset: 0, total size: 177280
Progress: |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| 100.0% Complete (177280 of 177280 bytes)
Upload complete in 2 minutes and 42 seconds
DFU Server done
- Fix switching to bootloader using buttonless DFU
- Remove unused legacy mode