Introduction
S-record is Motorola’s text format for binary data that is to be written into memory, such as the firmware for a microcontroller. Like Intel HEX, each line is one record holding a run of bytes as hexadecimal digits, the address they belong at and a checksum. It is common with NXP (formerly Motorola and Freescale) chips and is one of the output formats of most embedded toolchains.
Files are named .srec, .mot, or after the record types
they use: .s19 for 16-bit addresses, .s28 for 24-bit and
.s37 for 32-bit.
Structure
Every record is one line that starts with S and a digit giving the record
type. After it come pairs of hexadecimal digits: a count of the bytes that follow, the
address (2, 3 or 4 bytes depending on the type), the data and a checksum. The checksum
is the ones’ complement of the lowest byte of the sum of the count, address and data
bytes.
Type S0 is a header, usually holding a name. S1,
S2 and S3 are data records with 16, 24 and 32-bit addresses.
S5 and S6 give the number of data records, and
S9, S8 and S7 end the file with a start address
of 16, 24 or 32 bits. Every field and record type, with a checksum worked for each, is
on the records page.
S00F000068656C6C6F202020202000003C
S111003848656C6C6F20776F726C642E0A0042
S5030001FB
S9030000FC
0startSand the record type 0 to 92 characters2byte count of the address, data and checksum2 digits4address4, 6 or 8 digits…data2 digits per byte…checksum2 digits
In the explorer
Drop a .srec, .s19, .s28, .s37, .mot or .sre file on the explorer (an S-record file named .hex is also read as one) to see:
- the tree: every line with its fields (type, byte count, address, data, checksum and the line ending), blank lines and lines that are not records marked;
- the file: the records by type, the address size (S19, S28 or S37 style), the header text, the checksums, the start address, gaps and overlaps in the memory image, and the problems found;
- the memory image built from the data records as regions of consecutive addresses, and sixteen bytes to a row;
- a CPU choice in the options bar: the file does not say which processor the code is for, so by default the bytes are shown, and any CPU of the site’s general CPU list (the same decoders as Read as raw machine code) can be chosen to disassemble every region, starting at the start address when it lies in one;
- the problems found: a wrong checksum, a byte count that does not fit the line, an odd number of digits or a character that is not hexadecimal, a count below 3, record type S4, an S5 or S6 count that disagrees with the data records, data after the end record, a second end record, a missing end record, an end record of the wrong kind, mixed address sizes, overlapping writes, data past the end of the address space, a lowercase “s”, mixed line endings.
A file is recognised as an S-record file when its first records (up to 8) are well formed and at least two have the right checksum (one, when the file has one record). A file with one of the six extensions whose first records are well formed except for their checksums is also taken, and shown with the checksums marked.
Not described
Known, not yet covered
- Viewer: the S0 header’s subfields (module name, version, revision, description: the Unix man page splits it so) are shown only as text; no CPU is chosen automatically (an S-record has nothing to choose it by); no labels are shown in the disassembly; the S4 record has no layout in the sources, so it is shown as bytes; a byte-order, word-size or 16-bit-address unit of a CPU (the CP1610’s decles) is not applied to the addresses of the file, which are byte addresses.
- Reference: other extensions in use (
.s,.s1–.s3,.sx,.exo,.mxt) are described but not opened by extension. - Viewer: checked against the real SRecord 1.65 (built from source, 26 November 2026;
parser-test/test-srecord-differential.mjs): 60 files written bysrec_cat -motorola(S1, S2 and S3 records, line lengths 20, 32 and 70 characters, with and without an execution start address, 1 to 3 regions at addresses up to 4 GiB, some adjacent) show the image that went in, and the viewer reports no problem where an end record is written. Measured: SRecord writes no end record (S7, S8, S9) unless an execution start address is given, so on those files (37 of the 60) the viewer’s one problem “There is no end record” is right. 20 files with one hex digit changed: SRecord stops with “checksum mismatch” and the viewer reports the checksum on every one. Only the S-record reader of SRecord’s many formats is compared; the other formats SRecord writes (Tektronix, TI-TXT, MOS Technology, VHDL and the rest) have no reader here.
Unknown
- Reference: Motorola’s own specification is not public. The records page rests on a copy of an old Unix
srec(5)manual page, the SRecord manual and Wikipedia. Whether a file may hold several count records, and how S5 and S6 mix, is left open by those sources. - Reference: whether lowercase hexadecimal digits are allowed is not said by the sources read; the viewer accepts them without a problem. The
.sreextension was asked for and none of the sources read lists it. - Viewer: no S-record file from a vendor tool was found: the six real S-record files on the machine that built this site are SAGE-II ROM images (named
.hex), whose S0 header checksum is not the format’s (see seen in real files); the others are written by GNUobjcopyand read back with it. The disassembly of a region was compared withobjdumpfor one Motorola 68000 file only; the other CPUs are the site’s decoders, checked on their own pages.
Links
Software
- SRecord – converts, merges and checks S-record and other firmware files (Windows, macOS, Linux)
- GNU Binutils – its
objcopyconverts S-records to and from binary and ELF (Windows, macOS, Linux) - STM32CubeProgrammer – ST’s tool for programming STM32 chips (Windows, macOS, Linux)
Developers
- bincopy – library that reads and writes S-record and Intel HEX files (Python)