HEX2BIN(1)

NAME
hex2bin/mot2bin \- converts Intel/Motorola hex files into binary

SYNOPSIS
hex2bin [-s address] [-e extension] [-c] [-l length] [-p pad byte] [-k checksum type]
    [-r start end] [-f address [value]] file

DESCRIPTION
Hex2bin is a program that converts an Intel hex format into binary. It can handle the extended Intel hex format. Both the segmented and linear address records are supported. Records need not be sorted and there can be gaps between records. Records are assumed to be non-overlapping. Padding bytes may be specified and a checksum may be inserted in the binary file.

Mot2bin does the same with Motorola hex files. It has the same features and command line options. 24 bit and 32 bit records are supported.

OPTIONS
-s [address]

Normally, hex2bin will generate a binary file starting at the lowest address in the hex file. If the lowest address isn't 0000, ex: 0100, the first byte that should be at 0100 will be stored at address 0000 in the binary file. This may cause problems when using the binary file to program an EPROM. If you can't specify the starting address (or offset) to your EPROM programmer, you can specify a starting address on the command line:

Ex.: hex2bin -s 0000 start_at_0100.hex

The bytes will be stored in the binary file with a padding from 0000 to the lowest addess (00FF in this case). Padding bytes are all FF by default so an EPROM programmer can skip these bytes when programming. The padding value can be changed with the -p option.

-e [extension]

By default, the output file will have an extension filename.bin. Another extension may be specified with this command:

Ex.: hex2bin -e com example.hex

The output file will be example.com

-c

Enables checksum verification.

By default, it ignores checksum errors in the hex file, so that someone can change by hand some bytes with a text editor, allowing quick fixes without recompiling a source code all over again. This is useful when tweaking constants directly in the code or something similar. If you want checksum error reporting, specify the option -c.

Ex.: hex2bin -c example.hex

If there is a checksum error somewhere, the program will continue the conversion anyway.

-l [length]

The binary file will be padded with FF or pad bytes as specified by the option below, up to a maximal Length (Starting address + Length -1 is Max Address)

-p [pad_byte]

Pads unused locations with the specified byte.

By default, this byte is FF, which is the unprogrammed value for most EPROM/EEPROM/Flash.

Ex.: hex2bin -p 3E example.hex

-k [0|1|2]

In many cases, someone needs to insert a checksum in the binary file. For example, a boot rom is programmed with a checksum which is verified at power-up. This checksum is not the same as the one above for the hex file. This feature uses also options -r and -f described below.

Select the checksum type to insert into the binary file
  0 : 8-bit
  1 : 16-bit little endian
  2 : 16-bit big endian

-r [start] [end]

Range to compute binary checksum over (default is min and max addresses)

-f [address] [value]

Address and value of checksum to insert (force) in the binary file

NOTES
This program does minimal error checking since many hex files are generated by known good assemblers.

AUTHOR Jacques Pelletier (jpelletier@ieee.org) - version 1.0.10