2022-01-24 12:54:09 +01:00
|
|
|
# Examples using bootloader
|
|
|
|
|
2023-01-04 13:35:01 +01:00
|
|
|
Example for nRF demonstrating the bootloader. The example consists of application binaries, 'a'
|
2022-01-24 12:54:09 +01:00
|
|
|
which allows you to press a button to start the DFU process, and 'b' which is the updated
|
|
|
|
application.
|
|
|
|
|
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
* `cargo-binutils`
|
|
|
|
* `cargo-flash`
|
|
|
|
* `embassy-boot-nrf`
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
2022-04-28 14:08:33 +02:00
|
|
|
# Use bare metal linker script
|
2022-06-24 19:56:15 +02:00
|
|
|
cp memory-bl.x ../../bootloader/nrf/memory.x
|
2022-04-28 14:08:33 +02:00
|
|
|
|
2022-01-24 12:54:09 +01:00
|
|
|
# Flash bootloader
|
2023-01-04 13:35:01 +01:00
|
|
|
cargo flash --manifest-path ../../bootloader/nrf/Cargo.toml --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi --release --chip nRF52840_xxAA
|
2022-01-24 12:54:09 +01:00
|
|
|
# Build 'b'
|
2023-01-06 12:21:39 +01:00
|
|
|
cargo build --release --bin b --features embassy-nrf/nrf52840
|
2022-01-24 12:54:09 +01:00
|
|
|
# Generate binary for 'b'
|
2023-01-04 13:35:01 +01:00
|
|
|
cargo objcopy --release --bin b --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi -- -O binary b.bin
|
2022-01-24 12:54:09 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
# Flash `a` (which includes b.bin)
|
|
|
|
|
|
|
|
```
|
2023-01-04 13:35:01 +01:00
|
|
|
cargo flash --release --bin a --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi --chip nRF52840_xxAA
|
2022-01-24 12:54:09 +01:00
|
|
|
```
|
2023-01-04 00:27:16 +01:00
|
|
|
|
|
|
|
You should then see a solid LED. Pressing button 1 will cause the DFU to be loaded by the bootloader. Upon
|
|
|
|
successfully loading, you'll see the LED flash. After 5 seconds, because there is no petting of the watchdog,
|
2023-01-04 13:35:01 +01:00
|
|
|
you'll see the LED go solid again. This indicates that the bootloader has reverted the update.
|