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.
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
Links
Software
- SRecord, which converts, merges and checks them (Windows, macOS, Linux)
- GNU Binutils, whose
objcopyconverts to and from binary (Windows, macOS, Linux) - STM32CubeProgrammer (Windows, macOS, Linux)
Developers
- bincopy, Python library that reads and writes S-record and Intel HEX files