[Finishing] S-Record data format parsing

S-Reord is a file format created by Motorola. S-Record basic character of ASCII characters to indicate corresponding hexadecimal data. The data format has the following several name or initials SRECORD, SREC, S19, S28, S37. S-Record format is used in chip-based memory, Flash, EPROMs, EEPROMs and the like.

This paper describes the S-Record format and the meaning of each part represents more detailed description can watch the main source of information in this article, Wikipedia - SREC (File format) .

S-Record format Comments

See on this picture to Wikipedia S-Record format is perfect expression in this cite.
Motorola S-record format ready reckoner

Note :

  • This figure each grid represents one character, two characters in the middle of which represents a primary format below 2 Bytes, which is true when stored as two characters (ASCII code of one character is one byte).
  • In the parentheses below the red portion of the powder, 16 bits is represented by a block in the binary number corresponding to the symbols. Example, 'F' to the corresponding 0xF (1111).

S-Record data is stored in rows. It is divided into the following sections:

  • type : type, mainly S0-S3, S5, S7- S9 and other types of mode.
  • COUNT : the length of the main data indicates how many bytes in length (a two byte character) after the portion.
  • address : the start address data is written, according to the main types have different lengths of address, which is the big endian mode using big endian (MSB first) storage.
  • Data : data, data of one line in the S-Record, determined by the length and type count. Can be calculated (unit Byte) as follows: <count> - <address> ( 2,3,4 value) --1 (length <checksum> field)
  • Checksum : Checksum, for checking whether the entire row of data correctly.

The lower left portion of FIG address field indicates the length of the different types and different types of data formats. Note: Throughout the whole image, the data contained in several formats for S0-S3, S5, other modes no data exists.

Examples

Data: S1137AF00A0A0D0000000000000000000000000061
dismantling: Sl - 13 is - 7AF0 - 0A0A0D00000000000000000000000000 - 61 is

  1. Type S1
  2. A length of 0x13 =. 19
  3. According to S1 data format, you can know the count 2 Bytes of address data ( 7AF0 )
  4. The last byte is the parity bit ( 61 )
  5. The remaining portion of the data bits ( 0A0A0D00000000000000000000000000 )

For verify the checksum is calculated, or the above-described example,

  1. Adding, 0x13 + 0x7A + 0xF0 + ... + 0x00 = 0x19E
  2. Taking two bytes 0x9E
  3. 0xFF - 0x9E 0x61 check value to obtain

Guess you like

Origin www.cnblogs.com/airbird/p/11455227.html