DFU V2 PAN User Application Example

Source code path: example/dfu_v2/bt_pan/app

Supported Platforms

  • sf32lb52-lcd_n16r8_hcpu

  • sf32lb52-lchspi-ulp_hcpu

  • sf32lb52-nano_a128r16_hcpu

Overview

This example demonstrates the user application side of the PAN (Bluetooth PAN network / HTTP) upgrade channel of DFU V2: the device gets online through a Bluetooth PAN link, actively queries an OTA server for the version, writes the pending firmware info to flash, then reboots and hands off to the loader subprogram for the actual download and installation.

Usage Instructions

  1. After flashing, the application brings up the Bluetooth stack, sets the local name to sifli_pan (or BT_DEVICE_NAME), and enables HID/PAN auto-reconnect. First pair the device with a phone so the device can get online through the phone’s PAN network sharing; once HID is connected the application automatically initiates the PAN connection, and the serial log line PAN connected indicates the network channel is ready.

  2. Drive the upgrade flow from the serial finsh console:

    1. ota_version — Show the current firmware version.

    2. ota_check — Register the device with the OTA server (https://ota.sifli.com) and query the latest version. If the server reports a newer version, the firmware list is parsed and written to flash.

    3. ota_print — Optional; print the firmware info stored in flash (name, URL, address, size, CRC32, etc.).

    4. ota_go — After confirming pending entries exist in flash, write the update flags, wait 2 seconds, then reboot.

  3. Helper commands: ota_clear wipes the firmware info from flash; pan_cmd provides PAN debug subcommands such as del_bond, conn_pan, and autoconnect.

Hardware Requirements

Before running this example, prepare:

  • One development board supported by this example (Supported Platforms).

  • A phone that can provide PAN network sharing.

Compilation and Flashing

Switch to the example project directory and run the scons command to compile (<board> is one of the three boards above):

> scons --board=<board> -j8

For example:

> scons --board=sf32lb52-lcd_n16r8_hcpu -j8

Building the user application automatically pulls in the sibling loader subprogram as a child project via AddDFU_PAN_V2. For detailed compilation and download steps, please refer to the Quick Start Guide.

Expected Results

After the example starts:

  1. The application sets the local name to sifli_pan; after pairing with a phone it automatically initiates the PAN connection, the serial log shows PAN connected, and the network channel is ready.

  2. Run ota_check; if the server has a newer version, the firmware info is written to flash.

  3. After running ota_go the device reboots and hands off to the loader, which downloads the firmware over the PAN network, writes it directly to the target partition, then reboots back into the new user application.

  4. Run ota_version again and see the version change to confirm a successful upgrade.

Troubleshooting

Reference Documentation

Update History

Version

Date

Release Notes

0.0.1

06/2026

Initial version