Microbit Bluetooth Low Energy example
This example application runs out of the box on the BBC micro:bit v2.0. It starts a BLE (Bluetooth Low Energy) environment sensing service (as defined by specification) as well as a firmware update service if configured.
The example assumes that the nRF softdevice is installed. With this example, you can use BLE to update your microbit.
Make sure you have the latest versions (
cargo install <tool>) of these tools:
rustup - To compile the example with the correct toolchain.
probe-rs-cli - To flash the BLE protocol stack from Nordic Semiconductor.
probe-run - To run the example.
Flash nRF Softdevice
Download the softdevice version 7.3.0 here.
probe-rs-cli download s113_nrf52_7.3.0_softdevice.hex --chip nRF52833_xxAA --format Hex
cargo flash --release --chip nRF52833_xxAA
When started, the device will blink the letter 'A' on the LED matrix.
Flashing a new revision using firmware update
One change you can do is to set the REVISION environment variable, which will adjust the text that is printed on the LED matrix. We can then rebuild the application and flash it using the
REVISION=myupdate cargo objcopy --release -- -O binary update.bin
Modifying the version in
Cargo.toml or passing a
REVISION environment variable will compile the firmware with a new version identifier. This identifier can be used to decide if a firmware update is needed at all by the
To use the
drgdfu tool to update over BLE, generate a metadata file first:
drgdfu generate --version myupdate --file update.bin > update.json
We can then use refer to the metadata file when running the DFU process (The MAC address can be found from discovering your device using any tool like
bluetoothsctl and the command
drgdfu upload ble-gatt --device F8:56:35:45:1C:3C file update.json
Be patient! The firmware update process on the device takes up to 20-30 seconds.
Once finished, the
drgdfu tool will wait for the device to swap the new firmware and report back the expected version. If not, it will restart the DFU process.