Shelling The Intel 8-bit Hex File Format

Intel 8-bit Hex File Format is the most common hex file format used globally, as far as I know. There is also Motorola Hex file format and maybe others. Creating applications with AVR-GCC, we usually select ihex output file format what means Intel hex file format. Let’s go through it and see what’s inside. It is simple as 6 and 6 (six and six) because each Hex file line consists of six parts. And there can be 6 record types in the hex file.

Lets go through all six parts of each line:

  • Start code is always character ‘:’;
  • Byte count takes one byte (hex pair), indicating many bytes in the lin’s data field. Usually, there are 16 or 32 bytes of data in each line;
  • The address takes two bytes (16 bits – four hex digits). The address shows the beginning of the memory position for the data. 16 bits gives a limit of 64kilobytes. This is worked around by specifying higher bits via other record types;
  • Record type takes one byte (two hex digits). It defines the type of data field;
  • Data is a sequence of n bytes (2*n hex digits);
  • The checksum is one byte (two hex digits). It is the last byte in a line. It is calculated from fields: byte count, Address, record type, and data and taking its Two’s complement. Start code and checksum itself isn’t included. Checksum calculation example: :040F40009F4F089522

In Intel Hex File Format there are six types of record types:

  • 00 – data record;
  • 01 – End of file record. Usually, it is 00000001FF;
  • 02 – Extended Segment address record. This indicates segment base address when 16 bits is not enough for addressing memory;
  • 03 – Start segment address record. Indicates initial segment base address.
  • 04 – Extended Linear Address Record – allows 32 bit addressing.
  • 05 – Start Linear Address Record.

By concluding all of this:

Sample hex file:


One Comment:

Leave a Reply