nRF Command Line Tools v10.11.1

Merging files with mergehex

To combine up to three HEX files into a single file, use the mergehex executable.

Since the Nordic Semiconductor SoftDevices come as precompiled HEX files, you will have at least two HEX files to program into an nRF5 SoC when adding your own application. mergehex allows you to combine the HEX files into a single file before programming it onto the SoC.

The mergehex utility can make developing more efficient when flashing and testing applications. In production programming, it can significantly reduce the complexity of programming the firmware to Nordic Semiconductor SoCs - especially when there is a bootloader, SoftDevice, and application.

The following table shows the commands that are available for mergehex.
Table 1. mergehex commands
Shortcut Command Description
-h --help Displays the help.
-v --version Displays the mergehex version.
-q --quiet Reduces the stdout text info. Must be combined with another command.
-m --merge <hex.file> <hex.file> [<hex.file>] HEX files to be merged. Must be combined with the --output command.
-o --output <hex.file> HEX file with the result of the merge. Must be combined with the --merge command.

To see all the return codes that the mergehex executable can return, refer to the mergehex.h file that is included in the nRF Command Line Tools installation.

The following example shows how to use mergehex to merge three HEX files, file1.hex, file2.hex, file3.hex, into one, output_file.hex:
mergehex -m file1.hex file2.hex file3.hex -o output_file.hex