SREC (file format)

From Wikipedia, the free encyclopedia
Jump to: navigation, search

The Motorola S-record format is an ASCII hexadecimal ("hex") text encoding for binary data. It is also known as the SREC[1] or S19[2] format. Each record contains a checksum to detect data that has been corrupted during transmission. The first record (S0) may include arbitrary comments such as a program name or version number.[3] The last (termination) record (S7, S8, or S9) may include a starting address.[3]

The S-record format was created in the 1970s for the Motorola 6800 processor. Software development tools for that and other embedded processors would make executable code and data in the S-record format. PROM programmers would then read the S-record format and "burn" the data into the PROMs or EPROMs used in the embedded system.

There are other ASCII encoding with a similar purpose. BPNF, BHLF, and B10F were early binary formats, but they are neither compact nor flexible. Hexadecimal formats are more compact because they represent 4 bits rather than 1 bit per character. Many, such as S-record, are more flexible because they include address information so they can specify just a portion of a PROM. Intel HEX format was often used with Intel processors. Tek Hex is another hex format that can include a symbol table for debugging.


A quick reference chart for the Motorola SREC format

An SREC format file consists of a series of ASCII records. All hexadecimal (hex) numbers are Big Endian. The records have the following structure:

  1. Start code, one character, an S.
  2. Record type, one digit, 0 to 9, defining the type of the data field.
  3. Byte count, two hex digits, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (in the address, data and checksum fields).
  4. Address, four, six, or eight hex digits as determined by the record type for the memory location of the first data byte. The address bytes are arranged in big endian format.
  5. Data, a sequence of 2n hex digits, for n bytes of the data.
  6. Checksum, two hex digits - the least significant byte of ones' complement of the sum of the values represented by the two hex digit pairs for the byte count, address and data fields. For example:

S1137AF0 0A0A0D0000000000000000000000000061

13+7A+F0 +0A+0A+0D+00+00+00+00+00+00+00+00+00+00+00+00+00 = 19E, then take the least significant byte and then take the ones' complement of that byte (9E) which equals 0x61

There are eight record types, listed below:

Record Description Address Bytes Data Sequence
S0 Block header 2 Yes
S1 Data sequence 2 Yes
S2 Data sequence 3 Yes
S3 Data sequence 4 Yes
S5 Record count 2 No
S6 Record count 3 No
S7 End of block 4 No
S8 End of block 3 No
S9 End of block 2 No


The S0 record data sequence contains vendor specific data rather than program data. String with file name and possibly version info.

S1, S2, S3[edit]

Data sequence, depending on size of address needed. A 16-bit/64K system uses S1, 24-bit address uses S2 and full 32-bit uses S3.


Count of S1, S2 and S3 records previously appearing in the file or transmission. The record count is stored in the 2-byte address field. There is no data associated with this record type.[4]


Count of S1, S2 and S3 records previously appearing in the file or transmission. The record count is stored in the 3-byte address field. There is no data associated with this record type.[5]

S7, S8, S9[edit]

The address field of the S7, S8, or S9 records may contain a starting address for the program.[6]


  Start code
  Record type
  Byte count

See also[edit]


  1. ^ SREC is an abbreviation of S-RECord
  2. ^ S19 comes from the initial characters of each record: S1, S2, S3, ... S9. That gives S1-S9 which is shortened to just S19.
  3. ^ a b Motorola (1992, p. C-2)
  4. ^ "Motorola S-records". Retrieved 2011-02-16. 
  5. ^ "Motorola S-records". Retrieved 2014-04-14. 
  6. ^ Motorola (1992, p. Appendix C)

External links[edit]

  • SRecord is a collection of tools for manipulating SREC format files.