DFU V2 BLE User Application Example
Source code path: example/dfu_v2/ble/app
Supported Platforms
sf32lb52-lcd_n16r8_hcpu— SF32LB52X, 16MB NOR Flash + 8MB PSRAM.
Overview
This example is a standard BLE peripheral application that integrates the DFU V2 middleware. It can update non-self images (resources, fonts, loader, etc.) live while running, and when its own HCPU application needs updating it switches into the separate DFU loader subprogram to finish the job.
Usage Instructions
After power-up the device starts BLE advertising. A phone / host connects over BLE and pushes firmware. When pushing non-HCPU images (resources, fonts, loader, etc.), the device writes them into their partitions live while running.
To update the HCPU application itself, since a running application cannot erase itself, run
cmd_diss ota_rebootfrom the serial console to switch into the loader and finish the upgrade.The phone App is unchanged from legacy BLE DFU, so no App-side changes are required.
Hardware Requirements
Before running this example, prepare:
One development board supported by this example (Supported Platforms).
A phone or host (acting as the BLE host to push firmware).
Compilation and Flashing
Switch to the example project directory and run the scons command to compile:
> scons --board=sf32lb52-lcd_n16r8_hcpu -j8
When building the user application, the companion same-channel loader subprogram is built automatically as a child project via AddDFU_BLE().
For detailed compilation and download steps, please refer to the Quick Start Guide.
Expected Results
After the example starts:
The serial console prints the startup banner
=== peripheral_with_ota V2 Start ===, then the DFU V2 middleware initializes and BLE advertising starts with a name likeSIFLI_APP-xx-....During init
dfu_mode_host_set_self_img_id(0)tells Host mode to skip the HCPU image (img_id=0), because a running application cannot overwrite itself.When the phone / host pushes non-HCPU images (resources, fonts, loader, etc.) over BLE, the serial console prints OTA progress logs (
OTA progress,OTA image N complete,OTA all complete).To update the HCPU application, after running
cmd_diss ota_rebootthe device reboots and jumps into the loader, which receives and directly writes the new HCPU firmware, then reboots back into the new application version.At any time
cmd_diss ota_infoqueries the current OTA progress, printingOTA: idlewhen idle.
Troubleshooting
Reference Documentation
Update History
Version |
Date |
Release Notes |
|---|---|---|
0.0.1 |
06/2026 |
Initial version |