码迷,mamicode.com
首页 > 移动开发 > 详细

NRF51822之DFU使用手机升级

时间:2016-04-13 11:00:12      阅读:988      评论:0      收藏:0      [点我收藏+]

标签:

演示的工程是

[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
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/

 

NRF51822之DFU使用手机升级

标签:

原文地址:http://www.cnblogs.com/libra13179/p/5386176.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!