BLE-NRF51822教程17-DFU使用手机升级

演示的工程是

[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脚本如下:

  View Code

将这个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/

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值