Command Line Interface#

hexrec#

A set of command line utilities for common operations with record files.

Being built with Click, all the commands follow POSIX-like syntax rules, as well as reserving the virtual file path - for command chaining via standard output/input buffering.

hexrec [OPTIONS] COMMAND [ARGS]...

align#

Pads blocks to align their boundaries.

INFILE is the path of the input file. Set to - to read from standard input; input format required.

OUTFILE is the path of the output file. Set to - to write to standard output. Leave empty to overwrite INFILE.

hexrec align [OPTIONS] [INFILE] [OUTFILE]

Options

-i, --input-format <input_format>#

Forces the input file format. Required for the standard input.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-o, --output-format <output_format>#

Forces the output file format. By default it is that of the input file.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-m, --modulo <modulo>#

Alignment modulo.

Default:

4

-s, --start <start>#

Inclusive start address. Negative values are referred to the end of the data. By default it applies from the start of the data contents.

-e, --endex <endex>#

Exclusive end address. Negative values are referred to the end of the data. By default it applies till the end of the data contents.

-v, --value <value>#

Byte value used to flood alignment padding.

Default:

0

-w, --width <width>#

Sets the length of the record data field, in bytes. By default it is that of the input file.

Arguments

INFILE#

Optional argument

OUTFILE#

Optional argument

clear#

Clears an address range.

INFILE is the path of the input file. Set to - to read from standard input; input format required.

OUTFILE is the path of the output file. Set to - to write to standard output. Leave empty to overwrite INFILE.

hexrec clear [OPTIONS] [INFILE] [OUTFILE]

Options

-i, --input-format <input_format>#

Forces the input file format. Required for the standard input.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-o, --output-format <output_format>#

Forces the output file format. By default it is that of the input file.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-s, --start <start>#

Inclusive start address. Negative values are referred to the end of the data. By default it applies from the start of the data contents.

-e, --endex <endex>#

Exclusive end address. Negative values are referred to the end of the data. By default it applies till the end of the data contents.

-w, --width <width>#

Sets the length of the record data field, in bytes. By default it is that of the input file.

Arguments

INFILE#

Optional argument

OUTFILE#

Optional argument

convert#

Converts a file to another format.

INFILE is the list of paths of the input files. Set to - to read from standard input; input format required.

OUTFILE is the path of the output file. Set to - to write to standard output. Leave empty to overwrite INFILE.

hexrec convert [OPTIONS] [INFILE] [OUTFILE]

Options

-i, --input-format <input_format>#

Forces the input file format. Required for the standard input.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-o, --output-format <output_format>#

Forces the output file format. By default it is that of the input file.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-w, --width <width>#

Sets the length of the record data field, in bytes. By default it is that of the input file.

Arguments

INFILE#

Optional argument

OUTFILE#

Optional argument

crop#

Selects data from an address range.

INFILE is the path of the input file. Set to - to read from standard input; input format required.

OUTFILE is the path of the output file. Set to - to write to standard output. Leave empty to overwrite INFILE.

hexrec crop [OPTIONS] [INFILE] [OUTFILE]

Options

-i, --input-format <input_format>#

Forces the input file format. Required for the standard input.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-o, --output-format <output_format>#

Forces the output file format. By default it is that of the input file.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-s, --start <start>#

Inclusive start address. Negative values are referred to the end of the data. By default it applies from the start of the data contents.

-e, --endex <endex>#

Exclusive end address. Negative values are referred to the end of the data. By default it applies till the end of the data contents.

-v, --value <value>#

Byte value used to flood the address range. By default, no flood is performed.

-w, --width <width>#

Sets the length of the record data field, in bytes. By default it is that of the input file.

Arguments

INFILE#

Optional argument

OUTFILE#

Optional argument

delete#

Deletes an address range.

INFILE is the path of the input file. Set to - to read from standard input; input format required.

OUTFILE is the path of the output file. Set to - to write to standard output. Leave empty to overwrite INFILE.

hexrec delete [OPTIONS] [INFILE] [OUTFILE]

Options

-i, --input-format <input_format>#

Forces the input file format. Required for the standard input.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-o, --output-format <output_format>#

Forces the output file format. By default it is that of the input file.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-s, --start <start>#

Inclusive start address. Negative values are referred to the end of the data. By default it applies from the start of the data contents.

-e, --endex <endex>#

Exclusive end address. Negative values are referred to the end of the data. By default it applies till the end of the data contents.

-w, --width <width>#

Sets the length of the record data field, in bytes. By default it is that of the input file.

Arguments

INFILE#

Optional argument

OUTFILE#

Optional argument

fill#

Fills an address range with a byte value.

INFILE is the path of the input file. Set to - to read from standard input; input format required.

OUTFILE is the path of the output file. Set to - to write to standard output. Leave empty to overwrite INFILE.

hexrec fill [OPTIONS] [INFILE] [OUTFILE]

Options

-i, --input-format <input_format>#

Forces the input file format. Required for the standard input.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-o, --output-format <output_format>#

Forces the output file format. By default it is that of the input file.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-v, --value <value>#

Byte value used to fill the address range.

Default:

0

-s, --start <start>#

Inclusive start address. Negative values are referred to the end of the data. By default it applies from the start of the data contents.

-e, --endex <endex>#

Exclusive end address. Negative values are referred to the end of the data. By default it applies till the end of the data contents.

-w, --width <width>#

Sets the length of the record data field, in bytes. By default it is that of the input file.

Arguments

INFILE#

Optional argument

OUTFILE#

Optional argument

flood#

Fills emptiness of an address range with a byte value.

INFILE is the path of the input file. Set to - to read from standard input; input format required.

OUTFILE is the path of the output file. Set to - to write to standard output. Leave empty to overwrite INFILE.

hexrec flood [OPTIONS] [INFILE] [OUTFILE]

Options

-i, --input-format <input_format>#

Forces the input file format. Required for the standard input.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-o, --output-format <output_format>#

Forces the output file format. By default it is that of the input file.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-v, --value <value>#

Byte value used to flood the address range.

Default:

0

-s, --start <start>#

Inclusive start address. Negative values are referred to the end of the data. By default it applies from the start of the data contents.

-e, --endex <endex>#

Exclusive end address. Negative values are referred to the end of the data. By default it applies till the end of the data contents.

-w, --width <width>#

Sets the length of the record data field, in bytes. By default it is that of the input file.

Arguments

INFILE#

Optional argument

OUTFILE#

Optional argument

hd#

Display file contents in hexadecimal, decimal, octal, or ascii.

The hexdump utility is a filter which displays the specified files, or standard input if no files are specified, in a user-specified format.

Below, the length and offset arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the “iB” is optional, e.g., “K” has the same meaning as “KiB”), or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.

For each input file, hexdump sequentially copies the input to standard output, transforming the data according to the format strings specified by the -e and -f options, in the order that they were specified.

hexrec hd [OPTIONS] [INFILE]

Options

-b, --one-byte-octal#

One-byte octal display. Display the input offset in hexadecimal, followed by sixteen space-separated, three-column, zero-filled bytes of input data, in octal, per line.

-X, --one-byte-hex#

One-byte hexadecimal display. Display the input offset in hexadecimal, followed by sixteen space-separated, two-column, zero-filled bytes of input data, in hexadecimal, per line.

-c, --one-byte-char#

One-byte character display. Display the input offset in hexadecimal, followed by sixteen space-separated, three-column, space-filled characters of input data per line.

-d, --two-bytes-decimal#

Two-byte decimal display. Display the input offset in hexadecimal, followed by eight space-separated, five-column, zero-filled, two-byte units of input data, in unsigned decimal, per line.

-o, --two-bytes-octal#

Two-byte octal display. Display the input offset in hexadecimal, followed by eight space-separated, six-column, zero-filled, two-byte quantities of input data, in octal, per line.

-x, --two-bytes-hex#

Two-byte hexadecimal display. Display the input offset in hexadecimal, followed by eight space-separated, four-column, zero-filled, two-byte quantities of input data, in hexadecimal, per line.

-n, --length <length>#

Interpret only length bytes of input.

-s, --skip <skip>#

Skip offset bytes from the beginning of the input.

-v, --no_squeezing#

The -v option causes hexdump to display all input data. Without the -v option, any number of groups of output lines which would be identical to the immediately preceding group of output lines (except for the input offsets), are replaced with a line comprised of a single asterisk.

-U, --upper#

Uses upper case hex letters on address and data.

-I, --input-format <input_format>#

Forces the input file format.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-V, --version#

Print version and exit.

Arguments

INFILE#

Optional argument

hexdump#

Display file contents in hexadecimal, decimal, octal, or ascii.

The hexdump utility is a filter which displays the specified files, or standard input if no files are specified, in a user-specified format.

Below, the length and offset arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the “iB” is optional, e.g., “K” has the same meaning as “KiB”), or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.

For each input file, hexdump sequentially copies the input to standard output, transforming the data according to the format strings specified by the -e and -f options, in the order that they were specified.

hexrec hexdump [OPTIONS] [INFILE]

Options

-b, --one-byte-octal#

One-byte octal display. Display the input offset in hexadecimal, followed by sixteen space-separated, three-column, zero-filled bytes of input data, in octal, per line.

-X, --one-byte-hex#

One-byte hexadecimal display. Display the input offset in hexadecimal, followed by sixteen space-separated, two-column, zero-filled bytes of input data, in hexadecimal, per line.

-c, --one-byte-char#

One-byte character display. Display the input offset in hexadecimal, followed by sixteen space-separated, three-column, space-filled characters of input data per line.

-C, --canonical#

Canonical hex+ASCII display. Display the input offset in hexadecimal, followed by sixteen space-separated, two-column, hexadecimal bytes, followed by the same sixteen bytes in %_p format enclosed in | characters. Invoking the program as hd implies this option.

-d, --two-bytes-decimal#

Two-byte decimal display. Display the input offset in hexadecimal, followed by eight space-separated, five-column, zero-filled, two-byte units of input data, in unsigned decimal, per line.

-o, --two-bytes-octal#

Two-byte octal display. Display the input offset in hexadecimal, followed by eight space-separated, six-column, zero-filled, two-byte quantities of input data, in octal, per line.

-x, --two-bytes-hex#

Two-byte hexadecimal display. Display the input offset in hexadecimal, followed by eight space-separated, four-column, zero-filled, two-byte quantities of input data, in hexadecimal, per line.

-n, --length <length>#

Interpret only length bytes of input.

-s, --skip <skip>#

Skip offset bytes from the beginning of the input.

-v, --no_squeezing#

The -v option causes hexdump to display all input data. Without the -v option, any number of groups of output lines which would be identical to the immediately preceding group of output lines (except for the input offsets), are replaced with a line comprised of a single asterisk.

-U, --upper#

Uses upper case hex letters on address and data.

-I, --input-format <input_format>#

Forces the input file format.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-V, --version#

Print version and exit.

Arguments

INFILE#

Optional argument

merge#

Merges multiple files.

INFILES is the list of paths of the input files. Set any to - or none to read from standard input; input format required.

OUTFILE is the path of the output file. Set to - to write to standard output.

Every file of INFILES will overwrite data of previous files of the list where addresses overlap.

hexrec merge [OPTIONS] [INFILES]... OUTFILE

Options

-i, --input-format <input_format>#

Forces the input file format for all input files. Required for the standard input.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-o, --output-format <output_format>#

Forces the output file format. By default it is that of the input file.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-w, --width <width>#

Sets the length of the record data field, in bytes. By default it is that of the input file.

--clear-holes#

Merges memory holes, clearing data at their place.

Arguments

INFILES#

Optional argument(s)

OUTFILE#

Required argument

shift#

Shifts data addresses.

INFILE is the path of the input file. Set to - to read from standard input; input format required.

OUTFILE is the path of the output file. Set to - to write to standard output. Leave empty to overwrite INFILE.

hexrec shift [OPTIONS] [INFILE] [OUTFILE]

Options

-i, --input-format <input_format>#

Forces the input file format. Required for the standard input.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-o, --output-format <output_format>#

Forces the output file format. By default it is that of the input file.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-n, --amount <amount>#

Address shift to apply.

-w, --width <width>#

Sets the length of the record data field, in bytes. By default it is that of the input file.

Arguments

INFILE#

Optional argument

OUTFILE#

Optional argument

srec#

Motorola SREC specific

hexrec srec [OPTIONS] COMMAND [ARGS]...

del-header#

Deletes the header data record.

The header record is expected to be the first. All other records are kept as-is. No file-wise validation occurs.

INFILE is the path of the input file; ‘srec’ record type. Set to - to read from standard input.

OUTFILE is the path of the output file. Set to - to write to standard output. Leave empty to overwrite INFILE.

hexrec srec del-header [OPTIONS] [INFILE] [OUTFILE]

Arguments

INFILE#

Optional argument

OUTFILE#

Optional argument

get-header#

Gets the header data.

INFILE is the path of the input file; ‘srec’ record type. Set to - to read from standard input.

hexrec srec get-header [OPTIONS] [INFILE]

Options

-f, --format <format>#

Header data format.

Default:

ascii

Options:

ascii | hex | HEX | hex. | HEX. | hex- | HEX- | hex: | HEX: | hex_ | HEX_ | hex | HEX

Arguments

INFILE#

Optional argument

set-header#

Sets the header data record.

The header record is expected to be the first. All other records are kept as-is. No file-wise validation occurs.

INFILE is the path of the input file; ‘srec’ record type. Set to - to read from standard input.

OUTFILE is the path of the output file. Set to - to write to standard output. Leave empty to overwrite INFILE.

hexrec srec set-header [OPTIONS] HEADER [INFILE] [OUTFILE]

Options

-f, --format <format>#

Header data format.

Default:

ascii

Options:

ascii | hex | HEX | hex. | HEX. | hex- | HEX- | hex: | HEX: | hex_ | HEX_ | hex | HEX

Arguments

HEADER#

Required argument

INFILE#

Optional argument

OUTFILE#

Optional argument

validate#

Validates a record file.

INFILE is the path of the input file. Set to - to read from standard input; input format required.

hexrec validate [OPTIONS] [INFILE]

Options

-i, --input-format <input_format>#

Forces the input file format. Required for the standard input.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

Arguments

INFILE#

Optional argument

xxd#

Emulates the xxd command.

Please refer to the xxd manual page to know its features and caveats.

Some parameters were changed to satisfy the POSIX-like command line parser.

hexrec xxd [OPTIONS] [INFILE] [OUTFILE]

Options

-a, --autoskip#

Toggles autoskip.

A single ‘*’ replaces null lines.

-b, --bits#

Binary digits.

Switches to bits (binary digits) dump, rather than hexdump. This option writes octets as eight digits of ‘1’ and ‘0’ instead of a normal hexadecimal dump. Each line is preceded by a line number in hexadecimal and followed by an ASCII (or EBCDIC) representation. The argument switches -r, -p, -i do not work with this mode.

-c, --cols <cols>#

Formats <cols> octets per line. Max 256.

Defaults: normal 16, -i 12, -p 30, -b 6.

-E, --ebcdic, --EBCDIC#

Uses EBCDIC charset.

Changes the character encoding in the right-hand column from ASCII to EBCDIC. This does not change the hexadecimal representation. The option is meaningless in combinations with -r, -p or -i.

-e, --endian#

Switches to little-endian hexdump.

This option treats byte groups as words in little-endian byte order. The default grouping of 4 bytes may be changed using -g. This option only applies to hexdump, leaving the ASCII (or EBCDIC) representation unchanged. The switches -r, -p, -i do not work with this mode.

-g, --groupsize <groupsize>#

Byte group size.

Separates the output of every <groupsize> bytes (two hex characters or eight bit-digits each) by a whitespace. Specify <groupsize> 0 to suppress grouping. <groupsize> defaults to 2 in normal mode, 4 in little-endian mode and 1 in bits mode. Grouping does not apply to -p or -i.

-i, --include#

Output in C include file style.

A complete static array definition is written (named after the input file), unless reading from standard input.

-l, --length, --len <length>#

Stops after writing <length> octets.

-o, --offset <offset>#

Adds <offset> to the displayed file position.

-p, --postscript, --plain, --ps#

Outputs in postscript continuous hexdump style.

Also known as plain hexdump style.

-q, --quadword#

Uses 64-bit addressing.

-r, --revert#

Reverse operation.

Convert (or patch) hexdump into binary. If not writing to standard output, it writes into its output file without truncating it. Use the combination -r and -p to read plain hexadecimal dumps without line number information and without a particular column layout. Additional Whitespace and line breaks are allowed anywhere.

-k, --seek <oseek>#

Output seeking.

When used after -r reverts with -o added to file positions found in hexdump.

-s <iseek>#

Input seeking.

Starts at <s> bytes absolute (or relative) input offset. Without -s option, it starts at the current file position. The prefix is used to compute the offset. ‘+’ indicates that the seek is relative to the current input position. ‘-’ indicates that the seek should be that many characters from the end of the input. ‘+-’ indicates that the seek should be that many characters before the current stdin file position.

-U, --upper-all#

Uses upper case hex letters on address and data.

-u, --upper#

Uses upper case hex letters on data only.

-I, --input-format <input_format>#

Forces the input file format.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

-O, --output-format <output_format>#

Forces the output file format.

Options:

asciihex | avr | ihex | mos | raw | srec | titxt | xtek

--seek-zeroes, --no-seek-zeroes#

Output seeking writes zeroes while seeking.

Default:

True

-v, --version#

Prints the package version number.

Arguments

INFILE#

Optional argument

OUTFILE#

Optional argument