Intel HEX Record Parser

Parse one Intel HEX record and verify its byte count, two-complement checksum, record type, and control-record shape.

Description

Intel HEX represents binary data as ASCII records with a byte count, address, type, payload and checksum.

Intel HEX represents binary data as ASCII records with a byte count, address, type, payload and checksum. Control records give addressing or entry-point information distinct from data records.1, 2

The returned values include Record type from 0 through 5, Sixteen-bit record address, Record payload bytes, Record checksum byte. The How section below explains the calculation, input rules and interpretation.

When to use Intel HEX Record Parser

Use Intel HEX Record Parser when you need to evaluate the supplied records under the calculation and evidence rules below. No whole-file EOF order, extended-address accumulation, firmware authenticity or programming operation is checked.

Prepare one complete ASCII record from the firmware source, preserving its hexadecimal digits and colon prefix.

How to use Intel HEX Record Parser and understand its results

  1. Prepare one complete ASCII record from the firmware source, preserving its hexadecimal digits and colon prefix.
  2. Enter line using the field table and calculation rules, then run the tool.
  3. Read recordType, address, data, checksum. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
Input fieldMeaningValue type; see rules belowRequirement
lineOne Intel HEX record.string; maximum length: 1000000Required

Paste one record. Trim its outer whitespace; require colon-prefixed hexadecimal byte pairs totaling5–260 bytes. Require payload count to match, modulo256 checksum zero and type0–5. Type0 accepts any address/payload length; types1/2/3/4/5 require address0 and payload lengths0/2/4/2/4. Return type, 16-bit address, payload byte list and checksum.

sum(all record bytes) mod256=0

Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.

Output fieldMeaningValue type
recordTypeRecord type from 0 through 5.integer; minimum: 0; maximum: 5
addressSixteen-bit record address.integer; minimum: 0; maximum: 65535
dataRecord payload bytes.list of integer; minimum: 0; maximum: 255; minimum entries: 0; maximum entries: 255
checksumRecord checksum byte.integer; minimum: 0; maximum: 255
json
{
  "input": {
    "line": ":0401000001020304F1"
  },
  "output": {
    "recordType": 0,
    "address": 256,
    "data": [
      1,
      2,
      3,
      4
    ],
    "checksum": 241
  }
}

Limitations and assumptions

No whole-file EOF order, extended-address accumulation, firmware authenticity or programming operation is checked.

Numeric inputs, where present, must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing fields without a declared default, extra fields, wrong value types and violations of the calculation rules are input errors.

Alternative or Complementary methods

Use Intel HEX Record Generator: Serialize explicit bytes as one Intel HEX record with a computed byte count and checksum, enforcing control-record shapes. For a complementary task, use Motorola S-Record Parser: Parse a Motorola S-record, checking its count, address width, ones-complement checksum, and record-type payload constraints.

Further background: Intel HEX File Format.

References

  1. Intel HEX Record Parser — tool.io

  2. Intel HEX File Format — Arm Keil

Similar or alternative tools

  • Intel HEX Record Generator

    Serialize explicit bytes as one Intel HEX record with a computed byte count and checksum, enforcing control-record shapes.

  • Motorola S-Record Parser

    Parse a Motorola S-record, checking its count, address width, ones-complement checksum, and record-type payload constraints.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies