HEX2BIN(1)

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

SYNOPSIS
hex2bin [options] file

Option list:
    [-c]
    [-C Poly Init RefIn RefOut XorOut]
    [-e extension]
    [-E 0|1]
    [-f address]
    [-F address value]
    [-k checksum type]
    [-l length]
    [-m minimum block size]
    [-p pad byte]
    [-r start end]
    [-s address]
    [-w]

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
Options can be specified in any order, with the file name at the end. Options are now case sensitive. All option values are specified in hexadecimal.

-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.

-C Poly Init RefIn RefOut XorOut

CRC parameters. See the doc/CRC list.txt file for a description of common CRCs. See also the test/Makefile for examples of command lines. Needs -k and -f option. RefIn and RefOut parameters are specified by t or f for true or false.

-d

Display the list of available check methods and sizes.

-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

-E 0|1

Endianness for writing the check result or forcing a 16-bit value.
    0: little, 1: big.

By default, little endian is used.

-f address

Address in hexadecimal for inserting the check value in the binary file. Needs -k option to specify the check method. A range can be specified with option -r.

-F address value

Address and value of checksum to insert (force) in the binary file. Needs -k option to specify the size. The value is written as is.

-k 0-4

In many cases, someone needs to insert a check value in the binary file. For example, a boot rom is programmed with a checksum which is verified at power-up. This feature uses also options -r, -C and -f. Display the list with -d.

Select the checksum type to insert into the binary file
 0: Checksum 8-bit
 1: Checksum 16-bit
 2: CRC8
 3: CRC16
 4: CRC32

-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)

-m minimum_block_size

File Size Dimension will be a multiple of Minimum block size. File will be filled with Pattern. Length must be a power of 2 in hexadecimal [see -l option] Attention this option is STRONGER than Maximal Length

-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

-r [start] [end]

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

-s address

Specify the starting address of the binary file.

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 records_start_at_0100.hex

The bytes will be stored in the binary file with a padding from 0000 to the lowest address (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.

-w

Swap wordwise (low <-> high). Used by Microchip's MPLAB IDE

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

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