演示的工程是
[application] nRF51_SDK_10.0.0_dc26b5e\examples\ble_peripheral\ble_app_hrs\pca10028\s110_with_dfu
[bootload] nRF51_SDK_10.0.0_dc26b5e\examples\dfu\bootloader\pca10028\dual_bank_ble_s110
[softdevice] nRF51_SDK_10.0.0_dc26b5e\components\softdevice\s110\hex\s110_nrf51_8.0.0_softdevice.hex
1、先檫除
2、下载softdevice
3、打开bootload工程并编译下载
需要注意的地方修改BootLoader
如果使用NRF51822_XXAC(256KB-FLASH,32KB-RAM )
如果使用 NRF51822_XXAA(256KB-FLASH,16KB-RAM )
来自官方论坛
接上述步骤,在options ...窗口中点击"Utilities"选项卡,Arguments一栏 --family nRF51 --program "#H"
4、现在回到我们ble_app_hrs\pca10028\s110_with_dfu编译下载
5、在手机app中可以看到
6、使用脚本生成升级使用的ZIP
这个使用hex文件为ble_app_hrs工程的hex
generate_application_bin.Bat脚本如下:

@echo off set /p file_name=hex文件名,可以拖拽,回车键结束: echo %file_name% copy %file_name% application.hex nrfutil.exe dfu genpkg %file_name%.zip --application application.hex --application-version 0xFFFFFFFF --dev-revision 0xffff --dev-type 0xffff --sd-req 0xfffe del application.hex pause
将这个ZIP文件发送给手机,然后在手机端进行升级
在烧录完程序后,产品默认是DFU模式,要令产品进入正常模式,方法之一是执行一次UPDATE。方法之二是修改BOOTLODER工程。
现在我们将讲解方法二:
在bootload的工程中修改
1 #if defined ( __CC_ARM ) 2 uint8_t m_boot_settings[CODE_PAGE_SIZE] __attribute__((at(BOOTLOADER_SETTINGS_ADDRESS))) __attribute__((used)); /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */ 3 uint32_t m_uicr_bootloader_start_address __attribute__((at(NRF_UICR_BOOT_START_ADDRESS))) = BOOTLOADER_REGION_START; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */ 4 #elif defined ( __GNUC__ ) 5 __attribute__ ((section(".bootloaderSettings"))) uint8_t m_boot_settings[CODE_PAGE_SIZE]; /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */ 6 __attribute__ ((section(".uicrBootStartAddress"))) volatile uint32_t m_uicr_bootloader_start_address = BOOTLOADER_REGION_START; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */ 7 #elif defined ( __ICCARM__ ) 8 __no_init uint8_t m_boot_settings[CODE_PAGE_SIZE] @ 0x0003FC00; /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */ 9 __root const uint32_t m_uicr_bootloader_start_address @ 0x10001014 = BOOTLOADER_REGION_START; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */ 10 #endif
将第2行修改为
uint8_t m_boot_settings[CODE_PAGE_SIZE] __attribute__((at(BOOTLOADER_SETTINGS_ADDRESS))) __attribute__((used)) = {BANK_VALID_APP};
官方论坛
https://devzone.nordicsemi.com/question/60745/nrfgo-studio-and-bootloader-programming/
修改后编译下载
为了和之前的app区别我们将名字修改,编译下载
这次我们看到在手机中设备名为
更多信息可以参考
https://devzone.nordicsemi.com/blogs/685/common-faq-on-dfu/
https://devzone.nordicsemi.com/tutorials/9/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)