Mot file

From SEGGER Wiki
Jump to: navigation, search

Motorola S-Record (SREC) is a file format commonly used to represent binary data in a human-readable ASCII text format. It was originally developed by Motorola for their line of microcontrollers and has since become a widely adopted standard for exchanging binary data between devices in a human-readable form. A Motorola file is ASCII encode and can as such be be opened and even modified in a regular text editor. This can be useful when looking at a particular address range or when eliminating a certain address range manually. Because the data is represented as Hex, 2 bytes describe one byte. Along with the address information, "code density" is only about 40%, meaning that a 100KB Mot file contains about 40KB of actual data.



The S-record format was created in the mid-1970s by Motorola for the Motorola 6800 processor. Software development tools for that and other CPUs would generate executable code and data in this format. PROM and EPROM programmers would then read the S-record format and "burn" the data into the chips used as read-only data in these early day embedded system. The initial version of the S-record format (otherwise know as "Motorola file") had only one type of data records, the S1 data record with 16 bit address field. As processors with larger address space were introduced, there was also a need for larger address fields, so the S2 and S3 data records were introduced.

Similar file types

The only similar file type that comes to mind is the Intel Hex Format. It has been defined by Intel at about the same time and uses a similar Hex / Ascii representation to describe data bytes and their location in address space. Because of Intel's 8086 CPU with Segments, the Intel hex format is not as straight forward as the Motorola format, hence Motorola is generally preferred.

Binary files

Binary files represent data binary, so one byte of data is represented by one byte in the file. They do not contain address information, checksums and can also not contain gaps, due to the lack of address information.

File structure

A Motorola file consists of individual lines, terminated by either LF or CR LF. Every line contains one Record. Typical files have a structure as shown below:

16-bit address records
  1. S0
  2. S1 (one or more records)
  3. S5 (optional record)
  4. S9
24-bit address records
  1. S0
  2. S2 (one or more records)
  3. S5 (optional record)
  4. S8
32-bit address records
  1. S0
  2. S3 (one or more records)
  3. S5 (optional record)
  4. S7

In todays's world of 32-bit CPUs, the 32-bit address records are most common. However, software needs to be able to read and understand the 16 and 24 bit address records as well. Using 16 or 24 bit address records (S1, S2) has the advantage of a smaller file, so there is a benefit of using them where they are sufficient.

Record structure

Each record in the file begins with an 'S' character followed by a record type identifier (S0 through S9), specifying its purpose. An S-record can store actual data, vendor-specific information, and information about the starting address or the number of records.

The structure consists of fields such as record length, memory address, data in hexadecimal format, and a checksum for data integrity. SREC files are generated by development tools, and their human-readable format facilitates debugging and manual editing, while the checksums ensure the accuracy of the transferred data during programming.


The SREC file format frequently finds application in programming memory devices like microcontrollers, EEPROMs, and flash memory. It is used to transfer machine code or firmware updates from a development environment, such as a compiler or assembler, to the target device.

Click here for more information.