bl_commands.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. //*****************************************************************************
  2. //
  3. // bl_commands.h - The list of commands and return messages supported by the
  4. // boot loader.
  5. //
  6. // Copyright (c) 2006-2017 Texas Instruments Incorporated. All rights reserved.
  7. // Software License Agreement
  8. //
  9. // Texas Instruments (TI) is supplying this software for use solely and
  10. // exclusively on TI's microcontroller products. The software is owned by
  11. // TI and/or its suppliers, and is protected under applicable copyright
  12. // laws. You may not combine this software with "viral" open-source
  13. // software in order to form a larger program.
  14. //
  15. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  16. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  17. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  19. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  20. // DAMAGES, FOR ANY REASON WHATSOEVER.
  21. //
  22. // This is part of revision 2.1.4.178 of the Tiva Firmware Development Package.
  23. //
  24. //*****************************************************************************
  25. #ifndef __BL_COMMANDS_H__
  26. #define __BL_COMMANDS_H__
  27. //*****************************************************************************
  28. //
  29. // This command is used to receive an acknowledge from the the boot loader
  30. // proving that communication has been established. This command is a single
  31. // byte.
  32. //
  33. // The format of the command is as follows:
  34. //
  35. // uint8_t ui8Command[1];
  36. //
  37. // ui8Command[0] = COMMAND_PING;
  38. //
  39. //*****************************************************************************
  40. #define COMMAND_PING 0x20
  41. //*****************************************************************************
  42. //
  43. // This command is sent to the boot loader to indicate where to store data and
  44. // how many bytes will be sent by the COMMAND_SEND_DATA commands that follow.
  45. // The command consists of two 32-bit values that are both transferred MSB
  46. // first. The first 32-bit value is the address to start programming data
  47. // into, while the second is the 32-bit size of the data that will be sent.
  48. // This command also triggers an erasure of the full application area in the
  49. // flash or possibly the entire flash depending on the address used. This
  50. // causes the command to take longer to send the ACK/NAK in response to the
  51. // command. This command should be followed by a COMMAND_GET_STATUS to ensure
  52. // that the program address and program size were valid for the microcontroller
  53. // running the boot loader.
  54. //
  55. // The format of the command is as follows:
  56. //
  57. // uint8_t ui8Command[9];
  58. //
  59. // ui8Command[0] = COMMAND_DOWNLOAD;
  60. // ui8Command[1] = Program Address [31:24];
  61. // ui8Command[2] = Program Address [23:16];
  62. // ui8Command[3] = Program Address [15:8];
  63. // ui8Command[4] = Program Address [7:0];
  64. // ui8Command[5] = Program Size [31:24];
  65. // ui8Command[6] = Program Size [23:16];
  66. // ui8Command[7] = Program Size [15:8];
  67. // ui8Command[8] = Program Size [7:0];
  68. //
  69. //*****************************************************************************
  70. #define COMMAND_DOWNLOAD 0x21
  71. //*****************************************************************************
  72. //
  73. // This command is sent to the boot loader to transfer execution control to the
  74. // specified address. The command is followed by a 32-bit value, transferred
  75. // MSB first, that is the address to which execution control is transferred.
  76. //
  77. // The format of the command is as follows:
  78. //
  79. // uint8_t ui8Command[5];
  80. //
  81. // ui8Command[0] = COMMAND_RUN;
  82. // ui8Command[1] = Run Address [31:24];
  83. // ui8Command[2] = Run Address [23:16];
  84. // ui8Command[3] = Run Address [15:8];
  85. // ui8Command[4] = Run Address [7:0];
  86. //
  87. //*****************************************************************************
  88. #define COMMAND_RUN 0x22
  89. //*****************************************************************************
  90. //
  91. // This command returns the status of the last command that was issued.
  92. // Typically this command should be received after every command is sent to
  93. // ensure that the previous command was successful or, if unsuccessful, to
  94. // properly respond to a failure. The command requires one byte in the data of
  95. // the packet and the boot loader should respond by sending a packet with one
  96. // byte of data that contains the current status code.
  97. //
  98. // The format of the command is as follows:
  99. //
  100. // uint8_t ui8Command[1];
  101. //
  102. // ui8Command[0] = COMMAND_GET_STATUS;
  103. //
  104. // The following are the definitions for the possible status values that can be
  105. // returned from the boot loader when <tt>COMMAND_GET_STATUS</tt> is sent to
  106. // the microcontroller.
  107. //
  108. // COMMAND_RET_SUCCESS
  109. // COMMAND_RET_UNKNOWN_CMD
  110. // COMMAND_RET_INVALID_CMD
  111. // COMMAND_RET_INVALID_ADD
  112. // COMMAND_RET_FLASH_FAIL
  113. // COMMAND_RET_CRC_FAIL
  114. //
  115. //*****************************************************************************
  116. #define COMMAND_GET_STATUS 0x23
  117. //*****************************************************************************
  118. //
  119. // This command should only follow a COMMAND_DOWNLOAD command or another
  120. // COMMAND_SEND_DATA command, if more data is needed. Consecutive send data
  121. // commands automatically increment the address and continue programming from
  122. // the previous location. The transfer size is limited by the size of the
  123. // receive buffer in the boot loader (as configured by the BUFFER_SIZE
  124. // parameter). The command terminates programming once the number of bytes
  125. // indicated by the COMMAND_DOWNLOAD command has been received. Each time this
  126. // function is called, it should be followed by a COMMAND_GET_STATUS command to
  127. // ensure that the data was successfully programmed into the flash. If the
  128. // boot loader sends a NAK to this command, the boot loader will not increment
  129. // the current address to allow retransmission of the previous data.
  130. //
  131. // The format of the command is as follows:
  132. //
  133. // uint8_t ui8Command[9];
  134. //
  135. // ui8Command[0] = COMMAND_SEND_DATA;
  136. // ui8Command[1] = Data[0];
  137. // ui8Command[2] = Data[1];
  138. // ui8Command[3] = Data[2];
  139. // ui8Command[4] = Data[3];
  140. // ui8Command[5] = Data[4];
  141. // ui8Command[6] = Data[5];
  142. // ui8Command[7] = Data[6];
  143. // ui8Command[8] = Data[7];
  144. //
  145. //*****************************************************************************
  146. #define COMMAND_SEND_DATA 0x24
  147. //*****************************************************************************
  148. //
  149. // This command is used to tell the boot loader to reset. This is used after
  150. // downloading a new image to the microcontroller to cause the new application
  151. // or the new boot loader to start from a reset. The normal boot sequence
  152. // occurs and the image runs as if from a hardware reset. It can also be used
  153. // to reset the boot loader if a critical error occurs and the host device
  154. // wants to restart communication with the boot loader.
  155. //
  156. // The format of the command is as follows:
  157. //
  158. // uint8_t ui8Command[1];
  159. //
  160. // ui8Command[0] = COMMAND_RESET;
  161. //
  162. // The boot loader responds with an ACK signal to the host device before
  163. // actually executing the software reset on the microcontroller running the
  164. // boot loader. This informs the updater application that the command was
  165. // received successfully and the part will be reset.
  166. //
  167. //*****************************************************************************
  168. #define COMMAND_RESET 0x25
  169. //*****************************************************************************
  170. //
  171. // This is returned in response to a COMMAND_GET_STATUS command and indicates
  172. // that the previous command completed successful.
  173. //
  174. //*****************************************************************************
  175. #define COMMAND_RET_SUCCESS 0x40
  176. //*****************************************************************************
  177. //
  178. // This is returned in response to a COMMAND_GET_STATUS command and indicates
  179. // that the command sent was an unknown command.
  180. //
  181. //*****************************************************************************
  182. #define COMMAND_RET_UNKNOWN_CMD 0x41
  183. //*****************************************************************************
  184. //
  185. // This is returned in response to a COMMAND_GET_STATUS command and indicates
  186. // that the previous command was formatted incorrectly.
  187. //
  188. //*****************************************************************************
  189. #define COMMAND_RET_INVALID_CMD 0x42
  190. //*****************************************************************************
  191. //
  192. // This is returned in response to a COMMAND_GET_STATUS command and indicates
  193. // that the previous download command contained an invalid address value.
  194. //
  195. //*****************************************************************************
  196. #define COMMAND_RET_INVALID_ADR 0x43
  197. //*****************************************************************************
  198. //
  199. // This is returned in response to a COMMAND_GET_STATUS command and indicates
  200. // that an attempt to program or erase the flash has failed.
  201. //
  202. //*****************************************************************************
  203. #define COMMAND_RET_FLASH_FAIL 0x44
  204. //*****************************************************************************
  205. //
  206. // This is returned in response to a COMMAND_GET_STATUS command and indicates
  207. // that the boot loader is configured to check the embedded CRC32 in the
  208. // downloaded image but the check failed. This status can only be returned
  209. // after the last COMMAND_SEND_DATA has been received and processed, and only
  210. // if CHECK_CRC is defined in the boot loader configuration.
  211. //
  212. //*****************************************************************************
  213. #define COMMAND_RET_CRC_FAIL 0x45
  214. //*****************************************************************************
  215. //
  216. // This is the value that is sent to acknowledge a packet.
  217. //
  218. //*****************************************************************************
  219. #define COMMAND_ACK 0xcc
  220. //*****************************************************************************
  221. //
  222. // This is the value that is sent to not-acknowledge a packet.
  223. //
  224. //*****************************************************************************
  225. #define COMMAND_NAK 0x33
  226. #endif // __BL_COMMANDS_H__