Motorola S-record
   HOME

TheInfoList



OR:

Motorola S-record is a file format, created by
Motorola Motorola, Inc. () was an American Multinational corporation, multinational telecommunications company based in Schaumburg, Illinois, United States. After having lost $4.3 billion from 2007 to 2009, the company split into two independent p ...
in the mid-1970s, that conveys binary information as hex values in
ASCII ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because of ...
text form. This file format may also be known as SRECORD, SREC, S19, S28, S37. It is commonly used for programming
flash memory Flash memory is an electronic non-volatile computer memory storage medium that can be electrically erased and reprogrammed. The two main types of flash memory, NOR flash and NAND flash, are named for the NOR and NAND logic gates. Both us ...
in microcontrollers, EPROMs,
EEPROM EEPROM (also called E2PROM) stands for electrically erasable programmable read-only memory and is a type of non-volatile memory used in computers, usually integrated in microcontrollers such as smart cards and remote keyless systems, or as a ...
s, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program's source code (such as C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to "burn" the machine code into non-volatile memory, or is transferred to the target system for loading and execution.


Overview


History

The S-record format was created in the mid-1970s for the Motorola 6800 processor.
Software development tools A programming tool or software development tool is a computer program that software developers use to create, debug, maintain, or otherwise support other programs and applications. The term usually refers to relatively simple programs, that can b ...
for that and other embedded processors would make executable code and data in the S-record format. PROM programmers would then read the S-record format and "burn" the data into the PROMs or EPROMs used in the embedded system.


Other hex formats

There are other ASCII encoding with a similar purpose. BPNF, BHLF, and B10F were early binary formats, but they are neither compact nor flexible. Hexadecimal formats are more compact because they represent 4 bits rather than 1 bit per character. Many, such as S-record, are more flexible because they include address information so they can specify just a portion of a PROM.
Intel HEX Intel hexadecimal object file format, Intel hex format or Intellec Hex is a file format that conveys binary information in ASCII text form. It is commonly used for programming microcontrollers, EPROMs, and other types of programmable logic devi ...
format was often used with Intel processors. TekHex is another hex format that can include a symbol table for debugging.


Format


Record structure

An SREC format file consists of a series of ASCII text records. The records have the following structure from left to right: # ''Record start'' - each record begins with an uppercase letter "S" character (ASCII 0x53) which stands for "Start-of-Record". # ''Record type'' - single numeric digit "0" to "9", defining the type of record. # ''Byte count'' - two hex digits, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (address + data + checksum). This field has a minimum value of 3 for 16-bit address field plus 1 checksum byte, and a maximum value of 255 (0xFF). # ''Address'' - four / six / eight hex digits as determined by the record type. The address bytes are arranged in
big-endian In computing, endianness, also known as byte sex, is the order or sequence of bytes of a word of digital data in computer memory. Endianness is primarily expressed as big-endian (BE) or little-endian (LE). A big-endian system stores the most sig ...
format. # ''Data'' - a sequence of 2''n'' hex digits, for ''n'' bytes of the data. For S1/S2/S3 records, a maximum of 32 bytes per record is typical since it will fit on an 80 character wide terminal screen, though 16 bytes would be easier to visually decode each byte at a specific address. # ''Checksum'' - two hex digits, the
least significant byte In computing, bit numbering is the convention used to identify the bit positions in a binary number. Bit significance and indexing In computing, the least significant bit (LSB) is the bit position in a binary integer representing the binary 1 ...
of ones' complement of the sum of the values represented by the two hex digit pairs for the byte count, address and data fields. See example section for a detailed checksum example.


Text line terminators

SREC records are separated by one or more ASCII line termination characters so that each record appears alone on a text line. This enhances legibility by visually delimiting the records and it also provides padding between records that can be used to improve machine
parsing Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar. The term ''parsing'' comes from Lati ...
efficiency. Programs that create HEX records typically use line termination characters that conform to the conventions of their
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
s. For example, Linux programs use a single LF character (
line feed Newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. This character, or a ...
, 0x0A as ASCII character value) character to terminate lines, whereas Windows programs use a CR character ( carriage return, 0x0D as ASCII character value) followed by a LF character.


Record types

The following table describes 10 possible S-records. S4 is reserved and not currently defined. S6 was originally reserved but was later redefined.


Record order

Although some Unix documentation states "the order of S-records within a file is of no significance and no particular order may be assumed", in practice most software has ordered the SREC records. The typical record order starts with a (sometimes optional) S0 header record, continues with a sequence of one or more S1/S2/S3 data records, may have one optional S5/S6 count record, and ends with one appropriate S7/S8/S9 termination record. ; S19-style 16-bit address records # S0 # S1 (one or more records) # S5 (optional record) # S9 ; S28-style 24-bit address records # S0 # S2 (one or more records) # S5 (optional record) # S8 ; S37-style 32-bit address records # S0 # S3 (one or more records) # S5 (optional record) # S7


Limitations

''Record length'' - Unix manual page documentation states, "An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length". The manual page further limits the number of characters in the data field to 64 (or 32 data bytes). A record with an 8-hex-character address and 64 data characters would be 78 (2 + 2 + 8 + 64 + 2) characters long (this count ignores possible end-of-line or string termination characters). The file could be printed on an 80-character wide teleprinter. A note at the bottom of the manual page states, "This anual pageis the only place that a 78-byte limit on total record length or 64-byte limit on data length is documented. These values shouldn't be trusted for the general case". If that limitation is ignored, the maximum length of an S-record is 514 characters, thus assuming a Byte Count of 0xFF (255), it would be 2 for Record Type field + 2 for Byte Count field + (2 * 255) for Address / Data / Checksum fields. Additional buffer space may be required for the line and string terminators. Using long line lengths has problems: "The Motorola S-record format definition permits up to 255 bytes of payload, or lines of 514 characters, plus the line termination. All EPROM programmers should have sufficiently large line buffers to cope with records this big. Few do." ''Data field'' - Some documentation recommends a maximum of 32 bytes of data (64 hex characters) in this field. The minimum amount of data for S0/S1/S2/S3 records is zero. The maximum amount of data varies depending on the size of the address field. Since the Byte Count field can't be higher than 255 (0xFF), then the maximum number of bytes of data is calculated by 255 minus (1 byte for checksum field) minus (number of bytes in the address field). S0/S1 records support up to 252 bytes of data. S2 record supports up to 251 bytes of data. S3 record supports up to 250 bytes of data. ''Comments'' - The SREC file format does not support comments. Some software ignores all text lines that do not start with "S" and ignores all text after the checksum field; that extra text is sometimes used (incompatibly) for comments. For example, the CCS PIC compiler supports placing a ";" comment line at the top or bottom of an
Intel HEX Intel hexadecimal object file format, Intel hex format or Intellec Hex is a file format that conveys binary information in ASCII text form. It is commonly used for programming microcontrollers, EPROMs, and other types of programmable logic devi ...
file, and its manuals states "some programmers (MPLAB in particular) do not like comments at the top of the hex file", which is why the compiler has the option of placing the comment at the bottom of the hex file.


Examples

; Color legend


Checksum calculation

The following example record: is decoded to show how the checksum value is calculated. The following example uses a dollar sign ($) to indicate a hexadecimal value (a Motorola convention): # Add: Add each byte $13 + $7A + $F0 + $0A + $0A + $0D + $00 + ... + $00 = $019E. # Mask: Discard the most significant byte ($01) of the sum and retain the least significant byte (LSB), which is $9E. # Complement: Compute the ones' complement of the LSB, which is $61. Typically this is accomplished on the Motorola 6800 microprocessor with the COM instruction or by exclusive-ORing the accumulator with $FF.


16-bit memory address


See also

* Binary-to-text encoding, a survey and comparison of encoding algorithms *
Intel hex format Intel hexadecimal object file format, Intel hex format or Intellec Hex is a file format that conveys binary information in ASCII text form. It is commonly used for programming microcontrollers, EPROMs, and other types of programmable logic de ...
*
MOS Technology file format The MOS Technology file format is a file format that conveys binary information in ASCII text form. History The KIM-1 single-board computer specified a file format for magnetic tape and a format for paper tape. The paper tape format was ada ...
*
Tektronix hex format Tektronix hex format (TEK HEX) and Extended Tektronix hex format (EXT TEK HEX or XTEK) / Extended Tektronix Object Format are ASCII-based hexadecimal file formats, created by Tektronix, for conveying binary information for applications li ...


References


Further reading

* *

https://archive.org/download/bitsavers_motorola68ionModuleUsersManualDec83_3216374/M146805EVM_Evaluation_Module_Users_Manual_Dec83.pdf] *

(56 pages) * * * * *


External links


SRecord
is a collection of tools for manipulating SREC format files.
BIN2MOT
BINARY to Motorola S-Record file converter utility.
SRecordizer
is a tool for viewing, editing, and error checking S19 format files.
bincopy
is a Python package for manipulating SREC format files.
kk_srec
is a C library and program for reading the SREC format. {{DEFAULTSORT:Srec (File Format) Binary-to-text encoding formats Embedded systems Computer file formats