主題:使用nRF52840架設DFU OTA功能 (以SDK版本17.1.0為例)
DFU:Device Firmware Update;裝置韌體升級
OTA:Over the air;空中升級
IC: nRF52840
DK: PCA10056(對應到nRF52840)
SDK: 17.1.0
SD: s140_nrf52_7.2.0_softdevice.hex
IDE: Keil C
PC: Win 10
接續上一篇 - Part B: Application(文章連結請按此), 本篇會針對
Part C: 產生hex和zip檔以用於 DFU OTA
的主題做介紹。
Part C: 產生hex和zip檔以用於 DFU OTA
步驟1:執行bootloader的combin批次檔
nrf52840_bootloader_setting_merge.bat批次檔如下,
執行後會得到nrf52840_bootloader_secure_combin_settings.hex檔案。
@echo off
title = [ J-Link Tool ] %CD%
set nrfDir=C:\Program Files (x86)\Nordic Semiconductor\nrf5x\bin
set BS= nrf52840_bootloader_secure_settings.hex
set BL= nrf52840_xxaa_s140.hex
set BSBLCombind=nrf52840_bootloader_secure_combin_settings.hex
set path=%nrfDir%;%path%
pause
echo -----------merge image file-------------------
mergehex.exe -m %BS% %BL% -o %BSBLCombind%
pause
步驟2:從三併一批次檔(nrf52840_3in1_merge.bat批次檔)產生Final.hex
※註:Final.hex檔的主要用途為:客製化燒錄 使用。
nrf52840_3in1_merge.bat批次檔如下,執行後會得到Final.hex檔案。
@echo off
title = [ J-Link Tool ] %CD%
set nrfDir=C:\Users\user\Desktop\Nordic BLE\nRF5_merge tools\nRF52 bin
set SD= s140_nrf52_7.2.0_softdevice.hex
set BLT=nrf52840_bootloader_secure_combin_settings.hex
set APP=nrf52840_xxaa.hex
set SD_BLT=SD_BLT.hex
set Finalfile=Final.hex
set path=%nrfDir%;%path%
pause
echo -----------merge image file-------------------
mergehex.exe -m %SD% %BLT% -o %SD_BLT%
pause
mergehex.exe -m %SD_BLT% %APP% -o %Finalfile%
pause

步驟3:產生DFU(OTA) .zip的壓縮檔:nrf52840_xxaa.zip,供終端設備跑DFU(OTA)。
A. 到DOS的下列路徑:..\Python27\Scripts
B. 執行以下指令:
nrfutil pkg generate --hw-version 52 --sd-req 0x100 --application-version 0xFF --application nrf52840_xxaa.hex --key-file private.pem nrf52840_xxaa.zip

如上圖,產生的 nrf52840_xxaa.zip就是用於DFU OTA 的壓縮檔。
註: FWID 0x100 for s140_nrf52_7.2.0_softdevice.hex 使用;可以從Nordic網站上的SoftDevice文件中得到。


步驟4:透過nRF Connect手機APP執行 DFU(OTA)
4-1 先在手機上安裝 nRF Connect for mobile APP (下載連結請按此)
4-2 DFU(OTA) .zip 檔案名稱為:nrf52840_xxaa.zip;
4-2 可以先從電腦上透過電子郵件傳送nrf52840_xxaa.zip的zip檔,再使用手機收信並下載。
4-3 開啟 nRF Connect for mobile APP並連接裝置 (connect device)。

4-4 點擊 ”DFU” 並選擇剛剛下載的nrf52840_xxaa.zip壓縮檔。
4-5 開始跑DFU(OTA) → 等待DFU(OTA) 更新完成 → 關閉應用程式 → 重啟裝置 → 完成DFU(OTA)。

本系列: 如何產生執行DFU(OTA)所需的 hex/zip 檔 – 步驟說明#3 - 產生hex和zip檔以用於 DFU OTA
Part A: Bootloader (文章連結)
Part B: Application (文章連結)
Part C: 產生hex和zip檔以用於 DFU OTA
Technical guidelines provided by R&D Manager: Mr. MW Lee
Edited by Sales Manager: Mr. Tony Yin
Raytac Corporation 勁達國際電子股份有限公司
Bluetooth & WiFi module maker based on Nordic nRF54, nRF53, nRF52, nRF7002 solution
BT5.4 &BT5.3 & BT5.2 & BT5.1 Qualified, FCC/IC/CE/Telec/KC/RCM/SRRC/NCC Pre-Certified.
Bluetooth Solution: nRF54, nRF5340, nRF52840, nRF52833, nRF52832, nRF52820, nRF52811, nRF52810, nRF52805, nRF51822
WiFi Solution: nRF7002
http://www.raytac.com
email: service@raytac.com
Tel: +886-2-3234-0208