nRFutil

generate setting

mergehex

nrfutil pkg generate --hw-version 52                 \
--sd-req 0x91                                         \
--debug-mode                                         \
--key-file ../../keys/ruuvi_open_private.pem         \
--application ruuvitag_b/s132/armgcc/_build/ruuvi_firmware.hex \
                                                                    $zipname.zip 

nrfutil version 3.5.0 
  -v
 --verbose            Increase verbosity of output. Can be specified more than once (up to -v -v -v -v).
  -o
 --output   Log output to file

  dfu       Perform a DeviceFirmwareUpdate over, BLE, Thread, or serial transport
                        given a DFU package (zip file).
  keys      Generate and display private and public keys.
  pkg       Display or generate a DFU package (zip file).
  settings  Generate and display Bootloader DFU settings.
  version   Display nrfutil version.

generate Generate a .hex file with Bootloader DFU settings.

bootloader settings settings generate and display a bootloader settings page.

A DFU bootloader requires a bootloader settings page that contains information about the current DFU process.
It can contain information about the installed application and the firmware version.


nrfutil settings generate [options] file.hex

--family NRF51|NRF52|NRF52QFAB|NRF52810|NRF52840
--application file.hex can be omitted if the target IC does not contain an application in flash. Requires --application-version or --application-version-string.
--application-version INTEGER
--application-version-string TEXT string, e.g "2.7.31"
--bootloader-version INTEGER The bootloader version.
--bl-settings-version INTEGER The Bootloader settings version.Defined in nrf_dfu_types.h, the following apply to released SDKs: |SDK12|1|
--start-address INTEGER Custom start address for the settings page.
Default: last page of the flash

nrfutil settings display 
Contents of a bootloader settings page that is present in a HEX file.

To read the bootloader settings page from a programmed IC,
use nrfjprog to dump the flash memory of the IC (where HEX_file is the name of the resulting HEX file):
nrfjprog --readcode HEX_file

 nrfjprog --readcode t.hex
Reading flash.
Storing data in 't.hex'.

  1,474,709        20:48 t.hex
 

ruuvi/firmware/180711/ruuvi_examples../ruuvi_firmware > nrfutil settings display t.hex

Bootloader DFU Settings:
* File:                 t.hex
* Family:               nRF52
* Start Address:        0x00000000
* CRC:                  0x58DF607A
* Settings Version:     0x00000001 (1)
* App Version:          0x00000000 (0)
* Bootloader Version:   0x00000000 (0)
* Bank Layout:          0x00000000
* Current Bank:         0x00000000
* Application Size:     0x00017278 (94840 bytes)
* Application CRC:      0x3D23365A
* Bank0 Bank Code:      0x00000001
After generating the bootloader settings page,
use mergehex and nrfjprog to program it to the device.

Example, application app.hex installed in the IC

    nrfutil settings generate --family NRF52840 --application app.hex 
            --application-version 3 --bootloader-version 2 --bl-settings-version 1    settings.hex

Enter the following command to display the contents of the generated HEX file:
nrfutil settings display settings.hex


Actual code is at: cd /Library/Python/2.7/site-packages/nordicsemi
   138 Jul 21 20:42 ruuvi_firmware.dat
 13652 Jul 21 20:42 ruuvi_firmware.bin
   153 Jul 21 20:42 manifest.json


manifest.json 
{
    "manifest": {
        "application": {
            "bin_file": "ruuvi_firmware.bin",
            "dat_file": "ruuvi_firmware.dat"
        }
    }

hexdump -C ruuvi_firmware.dat 00000000 12 87 01 0a 41 08 01 12 3d 08 ff ff ff ff 0f 10 00000010 34 1a 02 91 01 20 00 28 00 30 00 38 d4 6a 42 24 00000020 08 03 12 20 6b b8 e1 02 f1 fc f4 55 11 c2 6f ad 00000030 45 55 bb 35 b1 dc f6 8a 04 a9 17 ab 2d f6 1e 1a 00000040 6b 49 aa 3e 48 01 10 00 1a 40 41 63 f4 72 fe a6 00000050 c0 13 a3 d2 62 cd af d9 b0 1e e0 18 c6 d0 ef 20 00000060 da eb e9 86 68 69 cf b5 d6 b5 8d d8 3d 09 07 92 00000070 19 1c 20 98 54 28 bb fc 08 47 d5 eb b0 36 81 c0 00000080 3c b7 71 fa 6e 12 3c bb 4b 7d 0000008a hexdump -C ruuvi_firmware.bin 00000000 00 00 01 20 dd 20 02 00 05 21 02 00 07 21 02 00 00000010 09 21 02 00 0b 21 02 00 0d 21 02 00 00 00 00 00 00000020 00 00 00 00 00 00 00 00 00 00 00 00 0f 21 02 00 00000030 11 21 02 00 00 00 00 00 13 21 02 00 15 21 02 00 00000040 29 fa 01 00 17 21 02 00 17 21 02 00 35 01 02 00 00000050 17 21 02 00 e5 1d 02 00 c9 fa 01 00 39 03 02 00 00000060 d9 01 02 00 31 02 02 00 89 02 02 00 17 21 02 00 00000070 17 21 02 00 11 00 02 00 17 21 02 00 17 21 02 00 00000080 39 f5 01 00 79 15 02 00 17 21 02 00 17 21 02 00 00000090 3d 16 02 00 17 21 02 00 ad 20 02 00 17 21 02 00 000000a0 17 21 02 00 17 21 02 00 e1 02 02 00 0d 1d 02 00 000000b0 17 21 02 00 17 21 02 00 00 00 00 00 00 00 00 00 000000c0 17 21 02 00 17 21 02 00 17 21 02 00 17 21 02 00 000000d0 81 00 02 00 17 21 02 00 17 21 02 00 00 00 00 00 000000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 00000400 10 b5 05 4c 23 78 33 b9 04 4b 13 b1 04 48 af f3 … … … 00003420 f8 bc 08 bc 9e 46 70 47 38 2c 00 20 3a 49 4e 46 |.....FpG8,. :INF| 00003430 4f 3a 47 65 6e 65 72 61 74 69 6e 67 20 66 61 69 |O:Generating fai| 00003440 6c 75 72 65 0d 0a 00 00 4d 41 49 4e 3a 49 4e 46 |lure....MAIN:INF| 00003450 4f 3a 4c 45 44 73 20 69 6e 69 74 0d 0a 00 00 00 |O:LEDs init.....| 00003460 78 2d 00 20 54 2d 00 20 20 00 00 00 01 00 00 00 |x-. T-. .......| 00003470 00 00 00 00 00 00 ff ff de c0 ad de fe 01 1e f1 00003480 de c0 ad de ff 01 1e f1 41 50 50 5f 45 52 52 4f |........APP_ERRO| 00003490 52 3a 45 52 52 4f 52 3a 46 61 74 61 6c 0d 0a 00 |R:ERROR:Fatal...| 000034a0 48 41 4c 5f 4e 46 43 3a 49 4e 46 4f 3a 52 65 69 |HAL_NFC:INFO:Rei| 000034b0 6e 69 74 69 61 6c 69 7a 65 0d 0a 00 00 00 00 00 |nitialize.......| 000034c0 80 cf ff 7f 01 00 00 00 00 00 00 00 00 00 00 00 000034d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 00003520 00 00 00 00 00 00 00 00 00 90 d0 03 25 f4 01 00 00003530 01 f4 01 00 00 10 00 00 00 30 08 00 69 f5 01 00 00003540 00 00 00 00 00 00 00 00 00 00 00 00 e9 11 02 00 00003550 0a ff 00 00 00003554

MergeHex

Nordic/nRF5x-CL-Tools_973/mergehex/mergehex

-m
--merge hex.file hex.file [hex.file]
Must be combined with --output (max 3 files!)
-o
--output hex.file>
Hex file result of the merge.
-q
--quiet
Reduces the stdout text info.
-h
--help
-v
--version

This small application is used to merge two or three hex files.

Example : mergehex -m file1.hex file2.hex file3.hex -o out.hex