Secure DFU OTA for nRF52832 solution modules: Guide to create hex/zip file for implementation – Part 1(Bootloader & Application)

Below are the guidelines to implement Secure DFU OTA by using Raytac’s nRF52832 modules, SDK16.0.0.
It consists of 2 parts:

Part 1: Bootloader & Application


Part 2: Combining and merging built files (Article link)

In this article, we will be focusing on Part 1: Bootloader & Application.



Path: ..\nRF5_SDK_16.0.0_98a08e2\examples\dfu\secure_bootloader\pca10040_s132_ble\arm5_no_packs
Specifically for nRF52832, programmers need to embed ECC(Elliptic Curve Cryptography) into the bootloader.


Step 1. ’micro_ecc_lib_nrf52.lib’ library can be found in the path below, but we need to boot it up first.


Step 2. Unzip ’micro-ecc-master.zip’ to the below path(create a new “micro-ecc” file first).


Step 3. Run ’gcc-arm-none-eabi-7-2018-q2-update-win32.exe’.


Step 4. Make sure the Environment variables in Win10 are set as below. (Follow the steps 1 to 6)


Step 5. Open DOS → run the “make” command under armgcc path → generate’micro_ecc_lib_nrf52.lib’


Step 6. Add ’micro_ecc_lib_nrf52.lib’ into folder: nRF_micro-ecc


Step 7. An error may occur while building bootloader without a public key:
(Shown in red frames in below screenshot)


Step 8. How to generate the public key file in Bootloader?
A. Visit DOS at path: ..\Python27\Scripts
B. Then execute:

nrfutil keys generate private.pem
nrfutil keys display --key pk --format code private.pem --out_file public_key.c


Step 9. Copy the pk[64] code from (public_key.c) into (dfu_public_key.c)
(Shown in red frames in below screenshot)

※Note: Make sure to save the 3 generated files:
private.pem
public_key.c
dfu_public_key.c


Step 10. Generate the bootloader file: nrf52832_xxaa_s132.hex after re-compiling the code files.


Application


Path:
..\nRF5_SDK_16.0.0_98a08e2\examples\ble_peripheral\ble_app_uart\pca10040\s132\arm5_no_packs
Before building Application code , some amendments need to be made regarding DFU-related settings and code inside Application:


Step 1. Add code in definition in C/C++ :
BL_SETTINGS_ACCESS_ONLY NRF_DFU_SVCI_ENABLED NRF_DFU_TRANSPORT_BLE=1
(Total 3 steps definitions need to be set up)


Step 2. Add the 3 paths shown below in C/C++ to make DFU work.


Step 3. Add the .c files inside red frame in (Screenshots 1 & 2)
and add the 2 groups of (nRF_DFU & nRF_SVC)(Screenshot 4) under Project(Screenshot 3)


Step 4. Add code into main.c file in Application (..\examples\ble_peripheral\ble_app_uart\main.c)
(Please refer to: main.c file at: ..\examples\ble_peripheral\ ble_app_buttonless_dfu)


Step 5.
The code of file: sdk_config.h (..\examples\ble_peripheral\ble_app_uart\pca10040\s132\config\sdk_config.h)

inside Application needs to be modified.


Step 6. Adjust the IRAM1 value in Target after implementing DFU service:
Make sure the IRAM1 Value of *p_app_ram_start is modified from default: 0x20002AD8 0xD528 to
0x20002AE8 0xD518, as shown in the red frame in the bottom right corner.
In this case, the program should run/advertise successfully.


Step 7. Create a file of: nrf52832_xxaa.hex after building application code files.



Step 8. Create a bootloader setting file of nrf52832_bootloader_secure_settings.hex via DOS.
nrfutil settings generate –family NRF52 –application nrf52832_xxaa.hex –application-version 3 —
bootloader-version 2 –bl-settings-version 1 nrf52832_bootloader_secure_settings.hex –no-backup

※Stay tuned for Part 2: Combining and merging built files in the next article, scheduled release in next week(04-Sep-2024).


Technical guidelines provided by R&D Manager: Mr. MW Lee
Edited by Sales Manager: Ms. Mandy Chao



Raytac Corporation 勁達國際電子股份有限公司 
Raytac Corporation: A Bluetooth, Wi-Fi, and LoRa Module Maker based on
Nordic nRF54; nRF53: nRF52; nRF51; nRF7002
Semtech Specification: SX1262

Bluetooth Specification: BT5.4 ; BT5.3; BT5.2.
Wi-Fi Specification: Wi-Fi 6
LoRa Specification: LoRaWAN

All products are FCC/IC/CE/Telec/KC/RCM/SRRC/NCC Pre-Certified.
http://www.raytac.com
email: sales@raytac.com
Tel: +886-2-3234-0208

Secure DFU OTA for nRF52840 solution modules: Guide to create hex/zip file for implementation – #2(Application)

Following up-Part A: Bootloader (Click for article link)

We will be focusing on:

in this article.

IC: nRF52840
DK: PCA10056 (for nRF52840)
SDK: 17.1.0
Softdevice: s140_nrf52_7.2.0_softdevice.hex
IDE: Keil C
PC: Win 10


Path: nRF5_SDK_17.1.0_ddde560\examples\ble_peripheral\ble_app_uart\pca10056\s140\arm5_no_packs

Before building Application code , some amendments need to be made regarding DFU-related settings and code inside Application:

Step 1.


1A. Add code in definition in C/C++ :
BL_SETTINGS_ACCESS_ONLY NRF_DFU_SVCI_ENABLED NRF_DFU_TRANSPORT_BLE=1
(Total 3 steps definitions need to be set up)


1B. Add “include path” in C/C++


1C. Add the .c files inside red frame in (Screenshots 1 & 2)
and the 2 groups of (nRF_DFU & nRF_SVC)(Screenshot 3) under Project(Screenshot 4)



1D. Add code into main.c file in Application (..\examples\ble_peripheral\ble_app_uart\main.c)
(Please refer to: main.c file at: ..\examples\ble_peripheral\ ble_app_buttonless_dfu)


1E. The code of file: sdk_config.h (..\examples\ble_peripheral\ble_app_uart\pca10056\s140\config\
sdk_config.h) inside Application needs to be modified.


1F. Adjust the IRAM1 value in Target after implementing DFU service:
Check on the IRAM1 Value of *p_app_ram_start to be modified from default: 0x20002AE8 0x3D518 to 0x20002AF8 0x3D508, as shown in the red frame in the bottom right corner.
In this case, the program should run successfully.


1G: Create a file of: nrf52840_xxaa.hex after building application code files.


Step 2. Create a bootloader setting file of nrf52840_bootloader_secure_settings.hex : (via DOS)

nrfutil settings generate –family NRF52840 –application nrf52840_xxaa.hex –application-version 3 — bootloader-version 2 –bl-settings-version 1 nrf52840_bootloader_secure_settings.hex –no-backup


※Stay tuned for #3 – Part C: Combining and merging built files in the next article,

scheduled release in next week(05/06/2024).


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

Secure DFU OTA for nRF52840 solution modules: Guide to create hex/zip file for implementation – #1(Bootloader)

Below are the following steps to implement Secure DFU OTA by using nRF52840 chip set, SDK17.1.0.
It consists of 3 parts:

Part A: Bootloader

Part B: Application (Click for article link)

Part C: Combining and merging built files (Click for article link)

In this article, we will be focusing on Part A: Bootloader.

Path: nRF5_SDK_17.1.0_ddde560\examples\dfu\secure_bootloader\pca10056_s140_ble\arm5_no_packs


Step 1. An error may occur while building bootloader without a public key:
(Shown in red frames in below screenshot)


Step 2. How to generate the public key file in Bootloader?
A. Visit DOS at path: ..\Python27\Scripts
B. Then execute:

nrfutil keys generate private.pem
nrfutil keys display --key pk --format code private.pem --out_file public_key.c


Step 3. Copy the pk[64] code from (public_key.c) into (dfu_public_key.c)
(Shown in red frames in below screenshot)

※Note: Make sure to save the 3 generated files:
private.pem
public_key.c
dfu_public_key.c


Step 4. Generate the bootloader file: nrf52840_xxaa_s140.hex after re-compiling the code files.


※Stay tuned for #2 – Part B: Application in the next article, scheduled release in next week(29/05/2024).



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

How to update nRF DeviceFamilyPack version to 8.27.1

From the article “Change to nRF52833 module? What the Hardware & Firmware Setting Need To Review?“, Raytac has highlighted Keil users need to update nRF Device Family Pack version to 8.27.1 for SDK16

Here introduced how to change the nRF DeviceFamilyPack version.

Modify nRF DeviceFamilyPack version to V8.27.1
Modify nRF DeviceFamilyPack version to V8.27.1