您的位置:首页 > 其它

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

2016-08-25 21:25 393 查看
演示的工程是

[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/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: