summaryrefslogtreecommitdiff
path: root/tools/hex2bin-2.0/src/hex2bin.pod
blob: a8eb2386026e82b49057d482c31cb9eefa866e9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
HEX2BIN 1 "2015 february 22nd" "Hex2bin Version 2.0"
=head1 NAME

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

=head1 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]

=head1 DESCRIPTION

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

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

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

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

B<Ex.: hex2bin -c example.hex>

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

B<-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 B<-k> and B<-f> option.
RefIn and RefOut parameters are specified by B<t> or B<f> for true or false.

B<-d>

Display the list of available check methods and sizes.

B<-e extension>

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

B<Ex.: hex2bin -e com example.hex>

The output file will be example.com

B<-E 0|1>

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

By default, little endian is used.

B<-f address>

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

B<-F address value>

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

B<-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 B<-r>, B<-C> and B<-f>. Display the list with B<-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

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

B<-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 B<-l> option]
Attention this option is STRONGER than Maximal Length

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

B<Ex.: hex2bin -p 3E example.hex>

B<-r [start] [end]>

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

B<-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:

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

B<-w>

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

=head1 NOTES

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

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