NRF51822之DFU使用手機升級

來源:互聯網
上載者:User

標籤:

示範的工程是

[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 offset /p file_name=hex檔案名稱,可以拖拽,斷行符號鍵結束:echo %file_name%copy %file_name% application.hexnrfutil.exe dfu genpkg %file_name%.zip --application application.hex --application-version 0xFFFFFFFF --dev-revision 0xffff --dev-type 0xffff --sd-req 0xfffedel application.hexpause
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使用手機升級

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.