II.2.5 The HEXBIN Utility

Most EPROM programmers are accepting the Intel-HEX object file format that is output by ASEM-51. However, for dumb EPROM burners and special purposes it might be useful to convert the HEX file to a pure binary image file. For this the conversion utility hexbin is provided. It is invoked as follows:

    hexbin [<options>] <hexfile> [<binary>]

where <hexfile> is the input file in Intel-HEX format, and <binary> is the binary output file. All file names that are specified explicitly, are left unchanged. The parameter <binary> is optional. When omitted, the file name is derived from the <hexfile>, but with the extension ".bin".
The maximum length of a file parameter is limited to 255 characters!

Instead of file names you may also specify device names to redirect the input or output to I/O devices. Device names are assumed to start with "/dev/". Of course no extensions will be added to device names!
It is not checked, whether the device is existing or suitable for the task.

hexbin recognizes the following options:

short optionslong options
-o <offset>--offset=<offset>
-l <length>--length=<length>
-f <fillbyte>--fill=<fillbyte>
-v--verbose

The short and long options in the same row are equivalent.
Long options may be abbreviated as long as they remain unique.
All option names are case-sensitive!

The binary file output can be controlled with the options --offset, --fill and --length.

Normally the first byte in the binary file is the first byte of the HEX record with the lowest load address. If a number of dummy bytes is to be inserted on top of the file (e.g. for alignment in an EPROM image), this can be performed with the --offset option:

--offset=1000
would insert 4096 dummy bytes before the first byte of the first HEX record loaded. The offset must always be specified as a hex number. The default offset is 0.

Since there may be peepholes between the HEX records, a fill byte value can be defined with the --fill option:

--fill=0
would fill all peepholes between the HEX records with zero bytes as well as all the dummy bytes that might have been inserted with the --offset or --length option. The fill byte value must always be specified as a hex number. The default fill byte is the EPROM-friendly FFH.

By default the last byte in the binary file is the last byte of the HEX record with the highest load address. If the binary file should have a well defined length, then a number of dummy bytes can be appended to the file (e.g. for exactly matching an EPROM length), this can be performed with the --length option:

--length=8000
would append as many dummy bytes behind the last byte of the file, that the total file length becomes exactly 32768 bytes. The file length must always be specified as a hex number.

By default, hexbin is totally "quiet", if no errors are detected. If the --verbose option is specified, additional product and version information, and a file conversion report is written to standard output:

        Hex File Converter HEXBIN V2.3

                     offset:      FF0H bytes
              first address:     7FF0H
               last address:     8255H
        fill peepholes with:       A5H
        binary image length:     2000H bytes


Examples:

0.)    hexbin
When invoked without parameters, hexbin displays a help screen:
       Hex File Converter HEXBIN V2.3

       usage:      hexbin [options] <hexfile> [<binary>]

       options:   -o   --offset=<offset>
                  -l   --length=<length>
                  -f   --fill=<fillbyte>
                  -v   --verbose
1.)    hexbin program.hex
will convert the Intel-HEX file program.hex to a pure binary image file program.bin.
2.)    hexbin -f E5 tarzan.obj jungle.bin
will convert the Intel-HEX file tarzan.obj to a binary image file jungle.bin and fill all peepholes between the HEX file records with the binary value E5H.
3.)    hexbin --off=8000 -l10000 --fill=0 project.hex eprom
will convert the Intel-HEX file project.hex to a binary image file eprom, insert 32K dummy bytes on top of file, fill all peepholes and the dummy bytes with nulls, and extend the file to exactly 64K.

When terminating hexbin returns an exit code to the calling process:

situationexit code
no errors0
conversion errors detected1
fatal runtime error2



[contents] [up] [back] [next]