본문 바로가기
카테고리 없음

Motorola S-record file format

by "″‡╀º Black bull ªο‡╆″"˛ 2022. 2. 23.

S-ecord is a file format developed by Motorola in the 1970s, and is a hexadecimal ASCII (ASCII) code. It is commonly used together with Intel-Hex format to transmit data to Flash memory, EEPROM, etc.

This file format is called SRecord, SRecord19, SREC, S19, S28, S37, etc., and the extension is usually S19 or SREC.
Here, S19 refers to a data format with a 16-bit address.

 

* S-Record format

The basic format of the file is as follows.

S19 file format
S-Record format

 

All formats except header express Hex as ASCII.

The header is entered as a fixed value with the first S character at the beginning. The letter S is ASCII 0x53.

All characters other than S are in ASCII-Hex format. For example, it is expressed as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, and in ASCII, 0x30, 0x31, 0x32, 0x33 , 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46.

 

Let's look at the following S-record file example.

S00A000001020304050607D9
S1137AF00A0A0D0000000000000000000000000061
S11300004D5A90000300000004000000FFFF0000B0
S1130010B8000000000000004000000000000000E4
S9030000FC

In ASCII, hex data is expressed in ASCII as 0x53 0x30 0x30 ~. This is very similar to Intel-Hex.

Intel-Hex has the following format.

:100000004D5A90000300000004000000FFFF0000B4
:10001000B8000000000000004000000000000000E8
:1000200000000000000000000000000000000000D0

 

 

* Header & Record type

Record type is expressed as S0 ~ S9. Each type has the following meaning.

 

  Header type :

The header type of a file is usually expressed as S0.

S0 : file header.  Address is always 0 as a 16-bit address (4 bytes).

 

  Data type :

The data type is expressed as S1, S2, or S3 according to the number of bytes of the address where the data is to be located.

S1 : Data with 16-bit address (ASCII 4 bytes)
S2 : Data with 24-bit address (ASCII 6 bytes)
S3 : Data with 32-bit address (ASCII 8 bytes)

 

  Termination type :

If S1 consists of data, S9 is used as the termination type.

S9 : paired with S1. Count is always 0x0003, and there is no data area.
S8 : paired with S2. Count is always 0x0004, and there is no data area.
S7 : paired with S3. Count is always 0x0005, and there is no data area.

For this reason, files with the extension S19 usually contain data with an address of 16 bits.

 

< Optional type >

This is an optional record type that can be omitted.

S5 : Displays how many data records have been written so far. Count is always 0x0003, there is no address area, and the data area is 16 bits and expresses the number of records written so far.

 

< other types >

S4 and S6 are not used.

 

 

* Count, Address, Data, Checksum

Let's take a look at the actual data structure.

 

< Count >

Count Count is the number of bytes of Address + Data + Checksum. Regardless of record type, all are equally expressed in 2 bytes (8 bits). Usually, 16 bytes, 24 bytes, or 32 bytes of data are written in one line, so 8 bits can be sufficient.

 

< Address >

Depending on the target, there will be binaries with addresses of 16 bytes, 24 bytes, 32 bytes, etc. Based on this, the record type is determined, and the number of address bytes is determined accordingly.

S10A1234FFFFFFFFFFFFFFB6
S20B123456FFFFFFFFFFFFFF5F
S31212345678FFFFFFFFFFFFFFFFFFFFFFFFFFE6

 

< Data >

Data The actual data is expressed in Hex-ASCII. For example, the hex value 0x19 is expressed as ASCII values ​​1 and 9.

 

< Checksum >

Checksum is the 1's complement of count + address + data. For example, suppose we have the following data:

S10A1234FFFFFFFFFFFFFFB6

0x0A + 0x12 + 0x34 + 0xFF + 0xFF + 0xFF + 0xFF + 0xFF + 0xFF + 0xFF = 0x749. If this is calculated in 1's complement, 0xFF - 0x49 = 0xB6.

 

< Last character >

0x0D, 0x0A

Last The last character is '\r\n', which is often used as the last character. Carriage Return + Line Feed.
Since the hex value is 0x0D 0x0A, it is not visible when viewing the S-Record file with a notepad, etc.

댓글