演示的工程是
[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/