Devuan fork of gpsd
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

309 lines
11 KiB

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!--
  3. This file is Copyright (c) 2010 by the GPSD project
  4. BSD terms apply: see the file COPYING in the distribution root for -details.
  5. -->
  6. <!DOCTYPE refentry PUBLIC
  7. "-//OASIS//DTD DocBook XML V4.1.2//EN"
  8. "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
  9. <refentry id='srec.5'>
  10. <refentryinfo><date>15 Jul 2005</date></refentryinfo>
  11. <refmeta>
  12. <refentrytitle>srec</refentrytitle>
  13. <manvolnum>5</manvolnum>
  14. <refmiscinfo class="source">The GPSD Project</refmiscinfo>
  15. <refmiscinfo class="manual">GPSD Documentation</refmiscinfo>
  16. </refmeta>
  17. <refnamediv id='name'>
  18. <refname>srec</refname>
  19. <refpurpose>Motorola S-record record and file format</refpurpose>
  20. </refnamediv>
  21. <refsect1 id='description'><title>DESCRIPTION</title>
  22. <para>Motorola S-records are a form of simple ASCII encoding for
  23. binary data. This format is commonly used for firmware uploads to
  24. GPSes, industrial robots, and other kinds of microcontroller-driven
  25. hardware. It has several convenient properties, including
  26. inspectability, easy editing with any text editor, and checksumming
  27. for verification of transmission across noisy serial lines.</para>
  28. <para>An S-record file consists of a sequence of specially formatted
  29. ASCII character strings. An S-record will be less than or equal to 78
  30. bytes in length.</para>
  31. <para>The order of S-records within a file is of no significance and
  32. no particular order may be assumed.</para>
  33. <para>The general format of an S-record follows:</para>
  34. <screen>
  35. +-------------------//------------------//-----------------------+
  36. | type | count | address | data | checksum |
  37. +-------------------//------------------//-----------------------+
  38. </screen>
  39. <variablelist>
  40. <varlistentry>
  41. <term>type</term>
  42. <listitem><para>A char[2] field. These characters
  43. describe the type of record (S0, S1, S2, S3, S5, S7, S8, or
  44. S9).</para></listitem>
  45. </varlistentry>
  46. <varlistentry>
  47. <term>count</term>
  48. <listitem><para>A char[2] field. These characters when paired and
  49. interpreted as a big-endian hexadecimal integer, display the count of remaining
  50. character pairs in the record.</para></listitem>
  51. </varlistentry>
  52. <varlistentry>
  53. <term>address</term>
  54. <listitem><para>A char[4,6, or 8] field. These characters grouped and
  55. interpreted as a big-endian hexadecimal integer, display the address
  56. at which the data field is to be loaded into memory. The length of the
  57. field depends on the number of bytes necessary to hold the address. A
  58. 2-byte address uses 4 characters, a 3-byte address uses 6 characters,
  59. and a 4-byte address uses 8 characters.</para></listitem>
  60. </varlistentry>
  61. <varlistentry>
  62. <term>data</term>
  63. <listitem><para>A char [0-64] field. These characters when paired and
  64. interpreted as hexadecimal values represent the memory loadable data
  65. or descriptive information.</para></listitem>
  66. </varlistentry>
  67. <varlistentry>
  68. <term>checksum</term>
  69. <listitem><para>A char[2] field. These characters when paired and
  70. interpreted as a big-endian hexadecimal integer display the least
  71. significant byte of the ones complement of the sum of the byte values
  72. represented by the pairs of characters making up the count, the
  73. address, and the data fields.</para></listitem>
  74. </varlistentry>
  75. </variablelist>
  76. <para>Each record is terminated with a line feed. If any additional or
  77. different record terminator(s) or delay characters are needed during
  78. transmission to the target system it is the responsibility of the
  79. transmitting program to provide them.</para>
  80. <para>There are 9 record types, as follows:</para>
  81. <variablelist>
  82. <varlistentry>
  83. <term>S0</term>
  84. <listitem>
  85. <para>The type of record is 'S0' (0x5330). The address field
  86. is unused and will be filled with zeros (0x0000). The header
  87. information within the data field is divided into the following
  88. subfields.</para>
  89. <orderedlist>
  90. <listitem><para>mname is char[20] and is the module name.</para></listitem>
  91. <listitem><para>ver is char[2] and is the version number.</para></listitem>
  92. <listitem><para>rev is char[2] and is the revision number.</para></listitem>
  93. <listitem><para>description is char[0-36] and is a text comment.</para></listitem>
  94. </orderedlist>
  95. <para>Each of the subfields is composed of ASCII bytes whose
  96. associated characters, when paired, represent one byte hexadecimal
  97. values in the case of the version and revision numbers, or represent
  98. the hexadecimal values of the ASCII characters comprising the module
  99. name and description.</para>
  100. </listitem>
  101. </varlistentry>
  102. <varlistentry>
  103. <term>S1</term>
  104. <listitem><para>The type of record field is 'S1' (0x5331). The address
  105. field is interpreted as a 2-byte big-endian address. The data field is
  106. composed of memory loadable data.</para></listitem>
  107. </varlistentry>
  108. <varlistentry>
  109. <term>S2</term>
  110. <listitem><para>The type of record field is 'S2' (0x5332). The address
  111. field is interpreted as a 3-byte big-endian address. The data field is
  112. composed of memory loadable data.</para></listitem>
  113. </varlistentry>
  114. <varlistentry>
  115. <term>S3</term>
  116. <listitem><para>The type of record field is 'S3' (0x5333). The address
  117. field is interpreted as a 4-byte big-endian address. The data field is
  118. composed of memory loadable data.</para></listitem>
  119. </varlistentry>
  120. <varlistentry>
  121. <term>S5</term>
  122. <listitem><para>The type of record field is 'S5' (0x5335). The address
  123. field is interpreted as a 2-byte big-endian value and contains the
  124. count of S1, S2, and S3 records previously transmitted. There is no
  125. data field.</para></listitem>
  126. </varlistentry>
  127. <varlistentry>
  128. <term>S7</term>
  129. <listitem><para>The type of record field is 'S7' (0x5337). The address
  130. field contains the starting execution address and is interpreted as a
  131. 4-byte big-endian address. There is no data field.</para></listitem>
  132. </varlistentry>
  133. <varlistentry>
  134. <term>S8</term>
  135. <listitem><para>The type of record field is 'S8' (0x5338). The address
  136. field contains the starting execution address and is interpreted as a
  137. 3-byte big-endian address. There is no data field.</para></listitem>
  138. </varlistentry>
  139. <varlistentry>
  140. <term>S9</term>
  141. <listitem><para>The type of record field is 'S9' (0x5339). The address
  142. field contains the starting execution address and is interpreted as a
  143. 2-byte big-endian address. There is no data field.</para></listitem>
  144. </varlistentry>
  145. </variablelist>
  146. </refsect1>
  147. <refsect1 id='example'><title>EXAMPLE</title>
  148. <para>Shown below is a typical S-record format file.</para>
  149. <programlisting>
  150. S00600004844521B
  151. S1130000285F245F2212226A000424290008237C2A
  152. S11300100002000800082629001853812341001813
  153. S113002041E900084E42234300182342000824A952
  154. S107003000144ED492
  155. S5030004F8
  156. S9030000FC
  157. </programlisting>
  158. <para>The file consists of one S0 record, four S1 records, one S5
  159. record and an S9 record.</para>
  160. <para>The S0 record is comprised as follows:</para>
  161. <itemizedlist>
  162. <listitem><para>S0 S-record type S0, indicating it is a header
  163. record.</para></listitem>
  164. <listitem><para>06 Hexadecimal 06 (decimal 6), indicating that six
  165. character pairs (or ASCII bytes) follow.</para></listitem>
  166. <listitem><para>00 00 Four character 2-byte address field, zeroes in
  167. this example.</para></listitem>
  168. <listitem><para>48 44 52 ASCII H, D, and R - "HDR".</para></listitem>
  169. <listitem><para>1B The checksum.</para></listitem>
  170. </itemizedlist>
  171. <para> The first S1 record is comprised as follows:</para>
  172. <itemizedlist>
  173. <listitem><para>S1 S-record type S1, indicating it is a data record to
  174. be loaded at a 2-byte address.</para></listitem>
  175. <listitem><para>13 Hexadecimal 13 (decimal 19), indicating that
  176. nineteen character pairs, representing a 2 byte address, 16 bytes of
  177. binary data, and a 1 byte checksum, follow. </para></listitem>
  178. <listitem><para>00 00 Four character 2-byte address field; hexidecimal
  179. address 0x0000, where the data which follows is to be
  180. loaded.</para></listitem>
  181. <listitem><para>28 5F 24 5F 22 12 22 6A 00 04 24 29 00 08 23 7C
  182. Sixteen character pairs representing the actual binary data.
  183. </para></listitem>
  184. <listitem><para>2A The checksum.</para></listitem>
  185. </itemizedlist>
  186. <para>The second and third S1 records each contain 0x13 (19) character
  187. pairs and are ended with checksums of 13 and 52, respectively. The
  188. fourth S1 record contains 07 character pairs and has a checksum of
  189. 92.</para>
  190. <para>The S5 record is comprised as follows:</para>
  191. <itemizedlist>
  192. <listitem><para>S5 S-record type S5, indicating it is a count record
  193. indicating the number of S1 records </para></listitem>
  194. <listitem><para>03 Hexadecimal 03 (decimal 3), indicating that three
  195. character pairs follow.</para></listitem>
  196. <listitem><para>00 04 Hexadecimal 0004 (decimal 4), indicating that
  197. there are four data records previous to this record.</para></listitem>
  198. <listitem><para>F8 The checksum.</para></listitem>
  199. </itemizedlist>
  200. <para>The S9 record is comprised as follows:</para>
  201. <itemizedlist>
  202. <listitem><para>S9 S-record type S9, indicating it is a termination
  203. record.</para></listitem>
  204. <listitem><para>03 Hexadecimal 03 (decimal 3), indicating that three
  205. character pairs follow. </para></listitem>
  206. <listitem><para>00 00 The address field, hexadecimal 0 (decimal 0)
  207. indicating the starting execution address. </para></listitem>
  208. <listitem><para>FC The checksum.</para></listitem>
  209. </itemizedlist>
  210. </refsect1>
  211. <refsect1 id='notes'><title>NOTES</title>
  212. <itemizedlist>
  213. <listitem><para> There isn't any evidence that Motorola ever
  214. made use of the header information within the data field of the S0
  215. record, as described above. This may have been used by some third
  216. party vendors.</para></listitem>
  217. <listitem><para>The Unix manual page on S-records is the only place that a
  218. 78-byte limit on total record length or 64-byte limit on data
  219. length is documented. These values shouldn't be trusted for the
  220. general case.</para></listitem>
  221. <listitem><para> The count field can have values in the range of 0x3
  222. (2 bytes of address + 1 byte checksum = 3, a not very useful
  223. record) to 0xff; this is the count of remaining character
  224. <emphasis>pairs</emphasis>, including checksum. </para></listitem>
  225. <listitem><para> If you write code to convert S-Records, you should
  226. always assume that a record can be as long as 514 (decimal)
  227. characters in length (255 * 2 = 510, plus 4 characters for the
  228. type and count fields), plus any terminating character(s). That
  229. is, in establishing an input buffer in C, you would declare it to
  230. be an array of 515 chars, thus leaving room for the terminating
  231. null character. </para></listitem>
  232. </itemizedlist>
  233. </refsect1>
  234. <refsect1 id='see_also'><title>SEE ALSO</title>
  235. <para>
  236. <citerefentry><refentrytitle>gpsd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
  237. <citerefentry><refentrytitle>gps</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
  238. <citerefentry><refentrytitle>libgps</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
  239. <citerefentry><refentrytitle>libgpsmm</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
  240. <citerefentry><refentrytitle>gpsfake</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
  241. <citerefentry><refentrytitle>gpsprof</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
  242. </para>
  243. </refsect1>
  244. <refsect1 id='maintainer'><title>AUTHOR</title>
  245. <para>From an anonymous web page, itself claiming to have been derived
  246. from an old Unix manual page. Now maintained by the GPSD
  247. project, which added endianness clarifications.</para>
  248. </refsect1>
  249. </refentry>