The basic strategy of DFU developed by nrf52832

First, DFU essential tools
1. The micro-ecc source code
Nordic DFU uses micro-ecc to implement the ECDSA algorithm, you need to use micro-ecc source code
2.gcc-arm-none-eabi-6-2017-q2-update-win32
Compile the micro-ecc source code
3.
Implement the Makefile under Cygwin Windows, prepare for the subsequent compilation of micro_ecc_lib_nrf52.lib
4.nRF5x-Command line tools
mainly need to use two commands of
mergehex and
nrfjprog
5. ARM 5.23
Keil MDK integrated development environment, compile Bootloader and application program
7.nRF Connect for Mobile_v4.11.0.apk
Mobile debugging app released by Nordic can be used to execute DFU

Second, tool download
Baidu cloud link: https://pan.baidu.com/s/1ygd9giSs7InIgmVgk_lF8A

3. Tool installation
1.
micro-ecc source code Copy the micro-ecc source code to the SDK source path: nRF5_SDK_15.2.0_9412b96 \ external \ micro-ecc
2.gcc-arm-none-eabi-6-2017-q2- Update-win32
This cross-compilation software can be installed directly by double-clicking according to the prompt. Remember to use
3.Cygwin behind the installation path.

Double-click the software, and then click Next, the following interface pops up

Select the first one, download and install the components online, click Next

Set the installation path, click Next

Set the local path to save the downloaded components, click Next

Select the network connection method, select the second one, and click Next

Add domestic mirror, here add Alibaba Cloud mirror http://mirrors.aliyun.com, click next

Here we switch Pending to Full, then enter make in the Search field, as follows

Click Next to complete the installation of the make component, and this is the basic installation process of Cygwin.

4.nRF5x-Command line tools

Double-click this software and click install as prompted

5.python2.7

The installation process of python2.7 is very simple, click install according to the prompt, there are two main points to note:

1) Add the installation path to the system environment variables

C: \ installPath \ python2.7.14; C: \ installPath \ python2.7.14 \ Scripts This is the path I need to add

2) After the installation of python and the configuration of environment variables are completed, open the cmd window and enter python -V. The following prompt appears indicating that the installation was successful

Finally, we need to type pip install nrfutil to install the nrfutil tool. After the installation is complete, type nrfutil and the following prompt appears to indicate that the nrfutil installation was successful

6. For the installation of MDK-ARM 5.23, please go to https://blog.csdn.net/qq_33575901/article/details/89643818

7.nRF Connect for Mobile_v4.11.0.apk can be installed to Android phone

Fourth, DFU related project compilation and wireless DFU operation

1. Compile the bootloader program

Take the official routine nRF5_SDK_15.2.0_9412b96 \ examples \ dfu \ secure_bootloader \ pca10040_ble \ arm5_no_packs as an example:

The following error will occur the first time you compile this routine

Prompt for the lack of micro_ecc_lib_nrf52.lib file, so the Cygwin we downloaded came in handy and solved in two steps:

1) Modify the Makefile about the use of cross-compilation software, my modifications are as follows

2) Open the Cygwin terminal cd to nRF5_SDK_15.2.0_9412b96 / external / micro-ecc / nrf52hf_keil / armgcc and execute make to solve the error report

Next, we need to generate our public and private key pair, that is, the public key used by the bootloader program and the private key used by the application, and execute the following command:

nrfutil keys generate priv.pem // Generate private key
nrfutil keys display --key pk --format code priv.pem --out_file dfu_public_key.c // Generate public key

Then replace the following files in the project with dfu_public_key.c, recompile the project, download the protocol stack and project hex files to the nordic development board

The development board downloaded the bootloader program scanned by the nRF Connect app on the mobile terminal is as follows

2. Compile the application

Take the official routine D: \ bluetooth_dogChain \ sdk \ nRF5_SDK_15.2.0_9412b96 \ examples \ ble_peripheral \ ble_app_buttonless_dfu \ pca10040 \ s132 \ arm5_no_packs as an example

Just compile directly

3. Start the DFU phase

1) Create a DFU directory

2) Rename the hex file generated by the compiled bootloader to bootloader.hex, rename the hex file generated by the compiled application to app.hex, and the protocol stack hex file s132_nrf52_6.1.0_softdevice.hex (nRF5_SDK_15.2.0_9412b96 \ components \ softdevice \ s132 \ hex directory), the key file priv.pem is placed in this directory

3) Execute the following commands to package applications that need to be updated through DFU

nrfutil pkg generate --hw-version 52 --application-version 1 --application app.hex --sd-req 0xAF --key-file priv.pem dfufile.zip

4) Send dfufile.zip to mobile phone via QQ or WeChat

5) Open the nRF Connect app on your mobile phone and connect to the development board named DfuTarg

6) As shown in the screenshot below, click 1 pop-up menu, then enable CCCDs, and finally click 3 DFU icons to select the dfufile.zip file we downloaded to upgrade

Screenshot of an upgrade progress chart

Upgrade to completion (the whole process is about 20 seconds or so), and finally reopen the nrf Connect app to see that the development board has run into the application, as shown in the screenshot below

Finally, to offer development board nordic DFU basic operation command script in the package Cygwin, interested Pickup: https://pan.baidu.com/s/1Z95EbqnUHszbWXk4xZdCXA

At this point, the basic introduction to DFU in this article has been introduced, everything is difficult at the beginning, it is not easy, old iron, click praise, everyone.

Published 81 original articles · 21 praises · 30,000+ views

Guess you like

Origin blog.csdn.net/qq_33575901/article/details/102595886