Introduction and generation tool of the nRF51 DFU initialization package, nrf51dfu
NRF51 DFU initialization package
When upgrading data packets, before the application image is transmitted, You need to initialize the package in DFU to perform image security detection. This initialization package provides a security detection mechanism as part of the upgrade process. Therefore, the upgraded device can only receive compatible applications.
The initialization package includes the following information for security detection (see dfu_init_packet_t)
L Device type: A two-byte value that can be defined by the developer to indicate the Device type, such as Heart Rate Belt.
L Device revision: A two-byte value that is used to restrict a Device from upgrading with only one defined version number.
L Application version: A 4-byte value used to identify the version of the Application for transmission. This value is used to only allow software upgrades but not downgrades. No sample code uses this value.
L Supported SoftDevices: A two-byte list identifies SoftDevices compatible with applications, such as S110 v7.0 and S110 v7.1.
L Checksum: A two-byte cyclic verification code used to verify the image.
SDK provides a templatedfu_init_template.c
Performs security detection for the initialization package. This template is added to enhance the security of DFU.
1 device and version type
The device and version types are stored in the user retention area of the Uyy (0x10001080) Register of the nRF51 chip. If this area is used for other purposes, update the offset in dfu_init.h: UICR_CUSTOMER_DEVICE_INFO_OFFSET.
# Defin UICR_CUSTOMER_DEVICE_INFO_OFFSET 0x0/** <Device info offset inside the customer Uyy reserved area. Customers may change this value to place the device information in a user-preferred location .*/ |
The default value is 0 xFFFF in Uyy. This value means that the DFU data of any device and version information in the initialization data packet will be received.
2 Application version DFU initialization data packets support detecting application versions. This feature is not used in the current bootloader example. However, if necessary, you can implement application Version Detection and add
dfu_init_template.c
.
If the application version check is added, each application must use a version ID for compilation. This version ID must be stored in a pre-defined place in the application image, for example, the starting address of the application + 0x0100 is similar to the nordic SD principle. See
The following code snippet in dfu_init_template.c describes the DFU initialization package.
How to deal with the security detection of an application version.
// In order to support application versioning this check shocould be updated.
// This template allows for any application to be installed however customer cocould place
// Revision number at bottom of application to be verified by bootloader. This cocould be done
// A relative location to this papplication for example Application start address + 0x0100.
3. The SoftDevice list application is compiled for a certain nRF51 chip with a specific SoftDevice as the target, for example, S110 v7.1.0. If the API is backward compatible, some applications may run on multiple SoftDevice versions. For example, an application is compiled for SoftDevice S110 v7.1.0 but can also run on SoftDevice S110 v7.0.0. You can provide a SoftDevice list that supports applications in the DFU initialization package. DFU checks the list to see if it matches the current SoftDevice version. If the value is 0 xFFFE, it means that any application can be installed regardless of the SoftDevice version. This feature is very useful in development, but not used in products. The FWID of the current SoftDevice is as follows:
SoftDevice S110icS1 |
FWID |
S110 v7.0.0 |
0x004F |
S110 v7.1.0 |
0x005A |
Development/any |
0 xFFFE |
4 DFU initialization package Generation Method
Tan-v provides the DFU initialization package generation tool make_dfu_initpacket.bat. The generated DFU init packet can be directly used for mobile APP upgrade. Usage:
1. Place the compiled hex file "nrf51422_xxac.hex" (the hex file name generated by the official example by default) under the path of the make initpacket folder. Note: The hex file name cannot be changed.
2. Click make_dfu_initpacket.bat to generate the bin file: nrf51422_xxac.bin and DFU Init packet file: bootloader_initpacket.dat.
3. Save bootloader_initpacket.dat and nrf51422_xxac.hex to your mobile phone. You can directly upgrade your mobile phone using the dfu app.
Note: The default configuration of the generated DFU Init packet file is to support any device type, any device version, and S110 V7.0.0 and S110 V7.1.0. to change it, change config. the corresponding fields in the dat file.
DFU initialization package generation tool download link: http://pan.baidu.com/s/1dDgZQMX