SREC (file format)

From Wikipedia, the free encyclopedia

S19 redirects here. For the former British postal district, see S postcode area.

The Motorola S-record format is an ASCII encoding for binary data. It is also known as the SREC or S19 format. The format has several advantages over binary formats. The ASCII encoding allows the files to be edited with a text editor. Also, each record contains a checksum to identify data that has been corrupted during transmission.[1]

The format was created in the 1970s for the Motorola 6800 processor. It is used by software development tools to encode binary data, especially executable code, for embedded processors.

A similar encoding, with slightly different ASCII formatting, termed Intel HEX, is used with Intel processors.

Contents

[edit] 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 position for the data.
  5. Data, a sequence of 2n hex digits, for n bytes of the data.
  6. Checksum, two hex digits - the one's complement of the least significant byte sum of the values of byte count, address (on a byte-by-byte basis), and data fields (also on a byte-by-byte basis).

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
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. The record count in the S5 record is stored in the 2-byte address field. The address field of the S7, S8, or S9 records may contain a starting address for the program.[2]

[edit] Example

S00F000068656C6C6F202020202000003C
S11F00007C0802A6900100049421FFF07C6C1B787C8C23783C6000003863000026
S11F001C4BFFFFE5398000007D83637880010014382100107C0803A64E800020E9
S111003848656C6C6F20776F726C642E0A0042
S5030003F9
S9030000FC

     Start code      Record type      Byte count      Address      Data      Checksum

[edit] References

  1. ^ srec - Linux man page
  2. ^ MC68000 Family Programmer’s Reference Manual Appendix C

[edit] External links

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