I've developing an application for the nRF52833 that uses the v7.2.0 s140 Soft Device and the secure BLE DFU bootloader.
- I'm able to compile the bootloader (taken from examples\dfu\secure_bootloader\pca10100_s140_ble)
- I'm able to compile my application (starting at flash address 0x2700 to allow room for the MBR/Soft Device)
- I'm able to build a dfu zip package of my application using nrfutil
- I'm able to build a combined firmware image that merges the Soft Device, Application, Bootloader, and Bootloader Settings File
My application works if flashed independently (combined with s140 Soft Device as part of the project).
If I erase the target and flash the bootloader, I'm able to deploy the dfu package using the BLE DFU app on my phone and boot into my application.
If I flash the combined firmware image, the target successfully boots into my custom application. If I then send it a recognized command message (via Bluetooth Mesh), it reboots into the bootloader (GPREGRET). At this point I can discover the device using the BLE DFU phone app and execute an update, but the device fails to load into my updated application after "successfully" completing the update.
As a final test, if I erase and flash the bootloader, deploy the dfu package, then instruct the application to return to the bootloader (GPREGRET), it behaves as above successfully deploying the update OTA, but failing to load into the updated application once finished.
My application primarily uses BLE Mesh, and I know there are important pages of settings and things stored in flash, and my guess is that region is being messed up during the update process, and not recognized and unwritten memory by the mesh stack. Is there a way to manually require those pages are reset on boot, and what would be the best way for the bootloader to signal to the application that this is a "first boot" the needs to reset those pages?
Since this only happens after a DFU update, it's difficult to debug and any insight would be appreciated.
Thanks,
Jeremy
I'm including my generation scripts in case they are useful or something is wrong with them, but they are pretty much copy/paste from the guide and appear to be working independently, just not if "re-deploying" the application.
DFU Update Package Generation Script:
#!/bin/bash # nRF Util (https://www.nordicsemi.com/Products/Development-tools/nrf-util) NRFUTIL="/usr/local/bin/nrfutil" # SDK 7.2.0 SoftDevice Lookups # s113_nrf52_7.2.0 = 0x102 # s132_nrf52_7.2.0 = 0x101 # s140_nrf52_7.2.0 = 0x100 SOFT_DEVICE=0x100 APPLICATION_VERSION=00010000 APPLICATION_FILE="../../build/scanner_nrf52833_xxAA_s140_7.2.0\_Release/scanner_nrf52833_xxAA_s140_7.2.0.hex" eval "$NRFUTIL pkg generate --application $APPLICATION_FILE \\ --application-version $APPLICATION_VERSION \\ --hw-version 52 \\ --sd-req $SOFT_DEVICE \\ --key-file ../../dfuKeys/private.pem \\ ../dfu_package_v$APPLICATION_VERSION.zip"
Combined Firmware File Generation Script:
#!/bin/bash # nRF Util (https://www.nordicsemi.com/Products/Development-tools/nrf-util) NRFUTIL="/usr/local/bin/nrfutil" # Part of Command Line Tools (https://www.nordicsemi.com/Products/Development-tools/nRF-Command-Line-Tools) MERGEHEX="/usr/local/bin/mergehex" # Secure UART bootloader BOOTLOADER_VERSION=00010000 BOOTLOADER_FILE="../../Bootloader/Output/Release/Exe/secure_bootloader_ble_nrf52833_xxAA_s140.hex" # Application APPLICATION_VERSION=00010000 APPLICATION_FILE="../../build/scanner_nrf52833_xxAA_s140_7.2.0\_Release/scanner_nrf52833_xxAA_s140_7.2.0.hex" # Copied from the nRF52 7.2.0 SDK locally for convenience SOFT_DEVICE_FILE="../bin/softdevice/s140_nrf52_7.2.0_softdevice.hex" # Generate bootloader settings file. BOOTLOADER_SETTINGS_FILE="../bin/bootloader_settings_nRF52833.hex" eval "$NRFUTIL settings generate --family NRF52 \\ --softdevice $SOFT_DEVICE_FILE \\ --application $APPLICATION_FILE \\ --application-version $APPLICATION_VERSION \\ --bootloader-version $BOOTLOADER_VERSION \\ --bl-settings-version 2 \\ $BOOTLOADER_SETTINGS_FILE" # Combine hex files for combined output eval "$MERGEHEX --merge $SOFT_DEVICE_FILE $APPLICATION_FILE $BOOTLOADER_FILE $BOOTLOADER_SETTINGS_FILE \\ --output ../bin/combined.hex"