How to use Nrfutil for BLE DFU on Raspberry Pi

Morning Everyone,

We use raspberry pis as part of our test equipment. The final stage of our CI/CD pipeline downloads the build dfu packages to a Pi and then does an OTA update onto our hardware.

However, out of the box, nrfutil cannot do a bluetooth DFU update. This is because the pc-ble-driver library that interfaces with the bluetooth dongle does not work on arm64 architectures. Here is what i did to get it working. I thought it would be useful to some of you!

Please treat these intructions with a pinch of salt, they worked for me, but they may need some adjustment to work for you! (they may also work for new Mac machines with the arm64 architecture too)

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /bin/bash
# script to rebuild pc-ble-drivers package for raspberry pi
# based on this: https://devzone.nordicsemi.com/f/nordic-q-a/47329/connection-3b-armv8-and-nrf-52840-dongle/188449#188449
# and this: https://github.com/NordicSemiconductor/pc-ble-driver-py/issues/202#issuecomment-1043871397
sudo apt-get update
sudo apt-get -y install build-essential git autoconf libudev-dev ninja-build libboost-dev cmake libspdlog-dev software-properties-common zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
# Download, build and install Python 3.8 as nrfutil doesn't work with the default version of python installed with Raspbian (Currently 3.9)
# https://krystof.io/installing-alternative-python-versions-on-raspberry-pi/
# https://linuxize.com/post/how-to-install-python-3-8-on-debian-10/
# https://www.linuxcapable.com/how-to-install-python-3-8-on-debian-11-bullseye/
# Please, please, please Nordic, update nrfutil so it will work with the current releases of Python. (sobs on floor)
# Or open source it so the community can fix it!
sudo apt-get remove --purge python3
wget https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tar.xz
tar -xvf Python-3.8.13.tar.xz
cd Python-3.8.13
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fingers Crossed, you will now be able to use nrfutil to do a ble dfu from your pi! Good Luck!