File format · .s19

Motorola S-Record (SREC/S19) File Format and Repair Guide

Motorola S-record (SREC, S19, S28, S37) files encode binary data as ASCII hex for microcontroller and EPROM programming. Learn their structure and how to repair corrupted files.


Motorola S-records—also widely known as SREC, S19, S28, or S37 files—are a family of ASCII text formats used to convey binary information, most commonly executable machine code, to embedded systems. Created by Motorola in the mid-1970s for the Motorola 6800 processor, the format encodes compiled assembly-language or C code into hexadecimal text so it can be easily transferred to device programmers and written into non-volatile memory such as EPROMs, EEPROMs, and flash memory. Because they are plain text, S-record files can be transmitted over serial interfaces, displayed on text terminals, or edited manually, but they are also susceptible to text-level corruption that can render the embedded payload unprogrammable.

What the S-Record Format Is and Where It Is Used

An S-record file bridges the gap between a software development toolchain and physical hardware. In a standard embedded workflow, a compiler or assembler translates source code into machine code. Rather than outputting a raw binary file, the toolchain generates an S-record file that contains both the data and the precise memory addresses where that data must be stored. A separate device programmer or flashing utility then reads this text file and "burns" the contents into the target microcontroller or programmable logic device.

The format was originally designed for 8-bit and 16-bit processors but was subsequently extended to support 24-bit and 32-bit memory addresses. This extension was necessary to maintain compatibility with more advanced architectures, such as the Motorola MC68000 series of microprocessors. Today, while the format has deep historical roots in Motorola ecosystems, it is supported by a vast array of cross-platform tools used for modern microcontrollers and embedded Linux bootloaders (such as U-Boot).

Internal Structure and Technical Facts

An S-record file is not a single contiguous block of data; rather, it is a sequential list of ASCII text records, each typically terminated by a carriage return and line feed (CRLF). Every line follows a strict, predictable structure that allows parsing tools to verify data integrity byte-by-byte.

From left to right, a standard S-record line consists of:

  • Record Start: Every line begins with an uppercase "S" (ASCII 0x53), standing for "Start-of-Record".
  • Record Type: A single numeric digit from "0" to "9" that defines the specific function of the line (e.g., header, data block, or end-of-file).
  • Byte Count: Two hexadecimal digits indicating the number of bytes that follow in the rest of the record. This count encompasses the address field, the data payload, and the final checksum byte. The minimum legal value is 3, and the maximum is 255 (0xFF).
  • Address: A field of 4, 6, or 8 hexadecimal digits (representing 16, 24, or 32 bits) that specifies the absolute memory location where the data payload should be written.
  • Data: The actual binary payload, represented as pairs of hexadecimal digits.
  • Checksum: A single byte (two hex digits) calculated as the least significant byte of the one's complement of the sum of all bytes in the byte count, address, and data fields. This is critical for error detection.

The record type digit dictates the address length and the purpose of the line. The most common record types include:

  • S0: The header record. It contains metadata about the file rather than executable data, and its address field is typically 0000.
  • S1, S2, S3: Data records carrying 16-bit, 24-bit, and 32-bit addresses, respectively. These are the lines that hold the actual machine code.
  • S5: A record containing the total count of S1, S2, or S3 data records previously transmitted.
  • S7, S8, S9: Termination records that mark the end of the file. They correspond to 32-bit, 24-bit, and 16-bit addressing, respectively, and often contain the execution start address.

The common file extensions—S19, S28, and S37—refer to files that specifically utilize S1/S9, S2/S8, and S3/S7 record types, respectively.

The Motorola S-record is one of several ASCII-encoded formats developed during the early era of computing to safely move binary data across non-binary media (such as paper tape or punch cards). Early binary formats like BPNF, BHLF, and B10F fell out of favor because they were neither compact nor flexible. Hexadecimal formats proved superior because they represent 4 bits per character rather than 1 bit, and they include address information, allowing developers to program only specific portions of a memory chip.

The most prominent alternative is the Intel HEX format (often using the .HEX or .H86 extension), which was developed in 1973 for Intel's Intellec Microcomputer Development Systems and is heavily used in Intel architecture ecosystems. Another related format is TekHex, which has the added capability of including a symbol table for debugging purposes.

Why S-Record Files Become Corrupt or Unreadable

Because S-record files are plain ASCII text, they are frequently damaged by systems and processes that assume they are handling raw binary data. The most common causes of corruption include:

  • Character Encoding Conversions: If an S-record file is opened and saved by a standard text editor or transferred through a system that automatically converts ASCII to UTF-8, invisible Byte Order Marks (BOMs) or altered line endings can invalidate the file for strict device programmers.
  • Line Truncation: Email clients, terminal emulators, or older serial transfer protocols may impose character-per-line limits, silently splitting or truncating long S-record lines, which destroys the checksum alignment.
  • Manual Editing Errors: Engineers frequently attempt to manually patch memory addresses or data payloads in a text editor. Failing to recalculate the final checksum byte after altering the data or address is the most common cause of an invalid file.
  • Incomplete Transfers: A dropped serial connection during a file transfer can result in a missing S7, S8, or S9 termination record, causing the programming utility to reject the file outright.

What Data Can Be Recovered

In nearly all cases of S-record corruption, the underlying machine code and memory address mappings remain intact. Because the format is line-based and highly structured, damage to one line does not necessarily affect the others. We can typically recover:

  • The memory address mappings for the programmable logic device.
  • The raw machine code payload (the binary data itself).
  • File metadata stored in the S0 header record.
  • The overall execution start address stored in the termination record.

How Recovery Works

Recovering a damaged Motorola S-record file requires parsing the text and restoring it to a state that satisfies strict device programmers. Our recovery process involves several stages:

  1. Sanitization: We strip out non-ASCII characters, errant BOMs, and invalid whitespace that interfere with hex parsing.
  2. Line Rebuilding: If lines have been improperly wrapped or truncated by terminal limitations, we stitch them back together based on the expected byte count field.
  3. Checksum Recalculation: For any line where the data or address has been modified, lost, or patched, we recalculate the one's complement checksum and append the correct byte.
  4. Structural Repair: If the file is missing its termination record (S7, S8, or S9), we synthesize the correct end-of-file line based on the addressing scheme used by the preceding data records.

Once these steps are completed, the S-record file can be validated and safely imported into your hardware programming tool.

Frequently Asked Questions

What is the difference between S19, S28, and S37 files?

The numbers refer to the specific Motorola S-record types used inside the file. S19 files use S1 data records (16-bit addresses) and S9 termination records. S28 files use S2 and S8 records (24-bit addresses). S37 files use S3 and S7 records (32-bit addresses). As microcontrollers grew in memory size, S28 and S37 became necessary to address the larger memory spaces.

Can I edit an S-record file in a standard text editor?

Yes, you can open and edit S-record files in any plain-text editor (like Notepad or vi). However, if you change any part of the address or data payload, you must manually recalculate and update the checksum byte at the end of that specific line, or the device programmer will reject it.

How is an S-record different from an Intel HEX file?

Both formats serve the exact same purpose—encoding binary data as ASCII text with address and checksum information. S-records were developed by Motorola and begin lines with an "S", while Intel HEX was developed by Intel and begins lines with a colon (":"). The mathematical methods used to calculate their respective checksums also differ.

What does a "checksum error" mean when programming a device?

A checksum error means that the final byte of a specific line in your file does not mathematically match the rest of the data on that line. This usually indicates that the file was corrupted during transfer, improperly edited, or saved with text-encoding artifacts.


If you have a corrupted, truncated, or unreadable Motorola S-record, SREC, S19, S28, or S37 file, we can help. Send us your file for a free evaluation, and our engineers will analyze the structure and provide a clear plan for recovering your vital machine code.

Send us your .s19 file for a free evaluation

Our recovery engineers will tell you exactly what can be recovered — at no cost. There is no charge if we cannot recover your data.

Start a free evaluation