BootloaderDFU.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /** \file
  2. *
  3. * This file contains special DoxyGen information for the generation of the main page and other special
  4. * documentation pages. It is not a project source file.
  5. */
  6. /** \mainpage DFU Class USB AVR Bootloader
  7. *
  8. * \section Sec_Compat Demo Compatibility:
  9. *
  10. * The following list indicates what microcontrollers are compatible with this demo.
  11. *
  12. * \li Series 7 USB AVRs (AT90USBxxx7)
  13. * \li Series 6 USB AVRs (AT90USBxxx6)
  14. * \li Series 4 USB AVRs (ATMEGAxxU4) - <i>See \ref SSec_Aux_Space</i>
  15. * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) - <i>See \ref SSec_Aux_Space</i>
  16. *
  17. * \section Sec_Info USB Information:
  18. *
  19. * The following table gives a rundown of the USB utilization of this demo.
  20. *
  21. * <table>
  22. * <tr>
  23. * <td><b>USB Mode:</b></td>
  24. * <td>Device</td>
  25. * </tr>
  26. * <tr>
  27. * <td><b>USB Class:</b></td>
  28. * <td>Device Firmware Update Class (DFU)</td>
  29. * </tr>
  30. * <tr>
  31. * <td><b>USB Subclass:</b></td>
  32. * <td>None</td>
  33. * </tr>
  34. * <tr>
  35. * <td><b>Relevant Standards:</b></td>
  36. * <td>USBIF DFU Class Standard, Atmel USB Bootloader Datasheet</td>
  37. * </tr>
  38. * <tr>
  39. * <td><b>Supported USB Speeds:</b></td>
  40. * <td>Low Speed Mode \n
  41. * Full Speed Mode</td>
  42. * </tr>
  43. * </table>
  44. *
  45. * \section Sec_Description Project Description:
  46. *
  47. * This bootloader enumerates to the host as a DFU Class device, allowing for DFU-compatible programming
  48. * software to load firmware onto the AVR.
  49. *
  50. * Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
  51. * into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
  52. * edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
  53. *
  54. * When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
  55. * bootloader from the normal user application.
  56. *
  57. * \section Sec_Running Running the Bootloader
  58. *
  59. * On the USB AVR8 devices, setting the \c HWBE device fuse will cause the bootloader to run if the \c HWB pin of
  60. * the AVR is grounded when the device is reset.
  61. *
  62. * The are two behaviours of this bootloader, depending on the device's fuses:
  63. *
  64. * <b>If the device's BOOTRST fuse is set</b>, the bootloader will run any time the system is reset from
  65. * the external reset pin, unless no valid user application has been loaded. To initiate the bootloader, the
  66. * device's external reset pin should be grounded momentarily.
  67. *
  68. * <b>If the device's BOOTRST fuse is not set</b>, the bootloader will run only if initiated via a software
  69. * jump, or if the \c HWB pin was low during the last device reset (if the \c HWBE fuse is set).
  70. *
  71. * For board specific exceptions to the above, see below.
  72. *
  73. * \subsection SSec_XPLAIN Atmel Xplain Board
  74. * Ground the USB AVR JTAG's \c TCK pin to ground when powering on the board to start the bootloader. This assumes the
  75. * \c HWBE fuse is cleared and the \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board.
  76. *
  77. * \subsection SSec_Leonardo Arduino Leonardo Board
  78. * Ground \c IO13 when powering the board to start the bootloader. This assumes the \c HWBE fuse is cleared and the
  79. * \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board.
  80. *
  81. * \section Sec_Installation Driver Installation
  82. *
  83. * This bootloader is designed to be compatible with Atmel's provided Windows DFU class drivers. You will need to
  84. * install Atmel's DFU drivers prior to using this bootloader on Windows platforms. If you are using a 64 bit Windows
  85. * OS, you will need to either disable the driver signing requirement (see online tutorials for details) or use a
  86. * digitally signed version of the official Atmel driver provided by a third party AVR user at
  87. * <a>http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_id=2196&item_type=project</a>.
  88. *
  89. * \note This device spoofs Atmel's DFU Bootloader USB VID and PID so that the Atmel DFU bootloader
  90. * drivers included with FLIP will work. If you do not wish to use Atmel's ID codes, please
  91. * manually change them in Descriptors.c and alter your driver's INF file accordingly.
  92. *
  93. * \section Sec_HostApp Host Controller Application
  94. *
  95. * This bootloader is compatible with Atmel's FLIP utility on Windows machines, and dfu-programmer on Linux machines.
  96. *
  97. * \subsection SSec_FLIP FLIP (Windows)
  98. *
  99. * FLIP (Flexible In-System Programmer) is a utility written by Atmel, and distributed for free on the Atmel website.
  100. * The FLIP utility is designed to assist in the bootloader programming of a range of Atmel devices, through several
  101. * popular physical interfaces including USB. It is written in Java, however makes use of native extensions for USB
  102. * support and thus is only offered on Windows.
  103. *
  104. * To program a device using FLIP, refer to the Atmel FLIP documentation.
  105. *
  106. * \subsection SSec_DFUProgrammer dfu-programmer (Linux)
  107. *
  108. * dfu-programmer is an open-source command line solution for the bootloader programming of Atmel devices through a
  109. * USB connection, using the DFU protocol, available for download at <a>http://sourceforge.net/projects/dfu-programmer/</a>.
  110. *
  111. * The following example loads a HEX file into the AVR's FLASH memory using dfu-programmer:
  112. * \code
  113. * dfu-programmer at90usb1287 erase flash Mouse.hex
  114. * \endcode
  115. *
  116. * \section Sec_API User Application API
  117. *
  118. * Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
  119. * allowing the user application to call into the bootloader at runtime to read and write FLASH data.
  120. *
  121. * \warning The APIs exposed by the DFU class bootloader are \b NOT compatible with the API exposed by the official Atmel DFU bootloader.
  122. *
  123. * By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
  124. * following layout:
  125. *
  126. * \code
  127. * #define BOOTLOADER_API_TABLE_SIZE 32
  128. * #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
  129. * #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
  130. *
  131. * void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
  132. * void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
  133. * void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
  134. * uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
  135. * uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
  136. * uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
  137. * void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
  138. *
  139. * #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
  140. * #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
  141. *
  142. * #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
  143. * #define BOOTLOADER_DFU_SIGNATURE 0xDF10
  144. *
  145. * #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
  146. * #define BOOTLOADER_ADDRESS_LENGTH 4
  147. * \endcode
  148. *
  149. * From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
  150. * \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
  151. * can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
  152. * to the value \c BOOTLOADER_DFU_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH
  153. * memory starting from address \c BOOTLOADER_ADDRESS_START.
  154. *
  155. * \subsection SSec_API_MemLayout Device Memory Map
  156. * The following illustration indicates the final memory map of the device when loaded with the bootloader.
  157. *
  158. * \verbatim
  159. * +----------------------------+ 0x0000
  160. * | |
  161. * | |
  162. * | |
  163. * | |
  164. * | |
  165. * | |
  166. * | |
  167. * | |
  168. * | User Application |
  169. * | |
  170. * | |
  171. * | |
  172. * | |
  173. * | |
  174. * | |
  175. * | |
  176. * | |
  177. * +----------------------------+ FLASHEND - BOOT_AUX_SECTION_SIZE
  178. * | Booloader Start Trampoline |
  179. * | (Not User App. Accessible) |
  180. * +----------------------------+ FLASHEND - (BOOT_AUX_SECTION_SIZE - 4)
  181. * | |
  182. * | Auxillery Bootloader |
  183. * | Space for Smaller Devices |
  184. * | (Not User App. Accessible) |
  185. * | |
  186. * +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
  187. * | |
  188. * | Bootloader Application |
  189. * | (Not User App. Accessible) |
  190. * | |
  191. * +----------------------------+ FLASHEND - 96
  192. * | API Table Trampolines |
  193. * | (Not User App. Accessible) |
  194. * +----------------------------+ FLASHEND - 32
  195. * | Bootloader API Table |
  196. * | (User App. Accessible) |
  197. * +----------------------------+ FLASHEND - 8
  198. * | Bootloader ID Constants |
  199. * | (User App. Accessible) |
  200. * +----------------------------+ FLASHEND
  201. * \endverbatim
  202. *
  203. * \subsection SSec_Aux_Space Auxiliary Bootloader Section
  204. * To make the bootloader function on smaller devices (those with a physical
  205. * bootloader section of smaller than 6KB)
  206. *
  207. * \section Sec_KnownIssues Known Issues:
  208. *
  209. * \par On Linux machines, the DFU bootloader is inaccessible.
  210. * On many Linux systems, non-root users do not have automatic access to newly
  211. * inserted DFU devices. Root privileges or a UDEV rule is required to gain
  212. * access.
  213. * See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
  214. *
  215. * \section Sec_Options Project Options
  216. *
  217. * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
  218. *
  219. * <table>
  220. * <tr>
  221. * <th><b>Define Name:</b></th>
  222. * <th><b>Location:</b></th>
  223. * <th><b>Description:</b></th>
  224. * </tr>
  225. * <tr>
  226. * <td>SECURE_MODE</td>
  227. * <td>AppConfig.h</td>
  228. * <td>If defined to \c true, the bootloader will not accept any memory commands other than a chip erase on start-up, until an
  229. * erase has been performed. This can be used in conjunction with the AVR's lockbits to prevent the AVRs firmware from
  230. * being dumped by unauthorized persons. When false, all memory operations are allowed at any time.</td>
  231. * </tr>
  232. * </table>
  233. */