FOTA mbed app to NRF52_DK with Nordic DFU boot loader and SDK 14.2
.
Prerequisites
- I assume you have set up mbed-cli and gcc arm toolchain and are able to build mbed projects using mbed-cli. Make sure to use gcc-arm-none-eabi 4.9
- Download and unpack Nordic SDK 14.2
- Install nrfutil
- Install nRF5x Command Line Tools
- Install Android app "nRF Toolbox" or it's analog for iOS.
Process
- Mostly this process is described here: http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v13.0.0%2Fble_sdk_app_dfu_bootloader.html.
- You may want to read that content for deeper understanding of steps described below.
- The only different part is how we prepare our mbed firmware.
Prepare secret key
- Create key and store it somewhere in a safe place:
nrfutil keys generate private.pem
Prepare NRF52_DK
- Generate code view for public key:
nrfutil keys display --key pk --format code private.pem
- Replace content of file {NRF SDK PATH}/examples/dfu/dfu_req_handling/dfu_public_key.c with generated text
- Setup micro-ecc
- Flash SoftDevice. In NRF SDK enter any example requiring BLE and run flash_softdevice target. For example:
cd {NRF SDK PATH}/components/softdevice/s132/hex nrfjprog -f nrf52 --program s132_nrf52_5.0.0_softdevice.hex --sectorerase
- Compile and flash dfu boot loader with generated key.
cd {NRF SDK PATH}/examples/dfu/bootloader_secure_ble/pca10040/armgcc/ make cd _build {path to nrfjprog}/nrfjprog --reset --program nrf52832_xxaa_s132.hex --family NRF52 --sectorerase
Prepare firmware
We will be using mbed-os-example-blinky as exemplar project to do FOTA.
- Create mbed project:
mbed import mbed-os-example-blinky cd mbed-os-example-blinky
- Create or open file mbed_app.json in the root folder of application (If created, don't forget to add root braces {}). Add to it:
"target_overrides": { "*": { "target.mbed_app_start": "0x23000", "target.mbed_app_size": "0x55000", "target.bootloader_img": null } }
target.mbed_app_start and target.mbed_app_size set correct place for our app in device flash memory, target.bootloader_img set to null makes compiler to not embed SoftDevice to our hex since SoftDevice is already flashed onto device.
- Build mbed project and create firmware zip using nrfutil and generated previously private key:
mbed compile -t GCC_ARM -m NRF52_DK cd BUILD/NRF52_DK/GCC_ARM/ nrfutil pkg generate --hw-version 52 --sd-req 0x9D --application-version 1 --application mbed-os-example-blinky.hex --key-file {{path_to_private_key}} package.zip
FOTA
- Upload package.zip to mobile device
- Power on NRF52_DK while holding button 4. It will enter DFU mode
- In nRF Toolbox press DFU button
- Select package.zip as firmware
- Select DfuTarg device (that is name of our device in DFU mode)
- Upload firmware
6 comments on FOTA mbed app to NRF52_DK with Nordic DFU boot loader and SDK 14.2:
Please log in to post comments.
Thanks for the post! However, branch feature-nrf528xx no longer exists as far as I can see.