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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

BootloaderDFU.txt 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. * This bootloader is designed to be started via the HWB mechanism of the USB AVRs; ground the HWB pin (see device
  60. * datasheet) then momentarily ground /RESET to start the bootloader. This assumes the HWBE fuse is set and the BOOTRST
  61. * fuse is cleared.
  62. *
  63. * For board specific exceptions to the above, see below.
  64. *
  65. * \subsection SSec_XPLAIN Atmel Xplain Board
  66. * Ground the USB AVR JTAG's \c TCK pin to ground when powering on the board to start the bootloader. This assumes the
  67. * \c HWBE fuse is cleared and the \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board.
  68. *
  69. * \subsection SSec_Leonardo Arduino Leonardo Board
  70. * Ground \c IO13 when powering the board to start the bootloader. This assumes the \c HWBE fuse is cleared and the
  71. * \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board.
  72. *
  73. * \section Sec_Installation Driver Installation
  74. *
  75. * This bootloader is designed to be compatible with Atmel's provided Windows DFU class drivers. You will need to
  76. * install Atmel's DFU drivers prior to using this bootloader on Windows platforms. If you are using a 64 bit Windows
  77. * OS, you will need to either disable the driver signing requirement (see online tutorials for details) or use a
  78. * digitally signed version of the official Atmel driver provided by a third party AVR user at
  79. * <a>http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_id=2196&item_type=project</a>.
  80. *
  81. * \note This device spoofs Atmel's DFU Bootloader USB VID and PID so that the Atmel DFU bootloader
  82. * drivers included with FLIP will work. If you do not wish to use Atmel's ID codes, please
  83. * manually change them in Descriptors.c and alter your driver's INF file accordingly.
  84. *
  85. * \section Sec_HostApp Host Controller Application
  86. *
  87. * This bootloader is compatible with Atmel's FLIP utility on Windows machines, and dfu-programmer on Linux machines.
  88. *
  89. * \subsection SSec_FLIP FLIP (Windows)
  90. *
  91. * FLIP (Flexible In-System Programmer) is a utility written by Atmel, and distributed for free on the Atmel website.
  92. * The FLIP utility is designed to assist in the bootloader programming of a range of Atmel devices, through several
  93. * popular physical interfaces including USB. It is written in Java, however makes use of native extensions for USB
  94. * support and thus is only offered on Windows.
  95. *
  96. * To program a device using FLIP, refer to the Atmel FLIP documentation.
  97. *
  98. * \subsection SSec_DFUProgrammer dfu-programmer (Linux)
  99. *
  100. * dfu-programmer is an open-source command line solution for the bootloader programming of Atmel devices through a
  101. * USB connection, using the DFU protocol, available for download at <a>http://sourceforge.net/projects/dfu-programmer/</a>.
  102. *
  103. * The following example loads a HEX file into the AVR's FLASH memory using dfu-programmer:
  104. * \code
  105. * dfu-programmer at90usb1287 erase flash Mouse.hex
  106. * \endcode
  107. *
  108. * \section Sec_API User Application API
  109. *
  110. * Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
  111. * allowing the user application to call into the bootloader at runtime to read and write FLASH data.
  112. *
  113. * \warning The APIs exposed by the DFU class bootloader are \b NOT compatible with the API exposed by the official Atmel DFU bootloader.
  114. *
  115. * By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
  116. * following layout:
  117. *
  118. * \code
  119. * #define BOOTLOADER_API_TABLE_SIZE 32
  120. * #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
  121. * #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
  122. *
  123. * void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
  124. * void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
  125. * void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
  126. * uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
  127. * uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
  128. * uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
  129. * void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
  130. *
  131. * #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
  132. * #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
  133. *
  134. * #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
  135. * #define BOOTLOADER_DFU_SIGNATURE 0xDF10
  136. *
  137. * #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
  138. * #define BOOTLOADER_ADDRESS_LENGTH 4
  139. * \endcode
  140. *
  141. * From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
  142. * \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
  143. * can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
  144. * to the value \c BOOTLOADER_DFU_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH
  145. * memory starting from address \c BOOTLOADER_ADDRESS_START.
  146. *
  147. * \subsection SSec_API_MemLayout Device Memory Map
  148. * The following illustration indicates the final memory map of the device when loaded with the bootloader.
  149. *
  150. * \verbatim
  151. * +----------------------------+ 0x0000
  152. * | |
  153. * | |
  154. * | |
  155. * | |
  156. * | |
  157. * | |
  158. * | |
  159. * | |
  160. * | User Application |
  161. * | |
  162. * | |
  163. * | |
  164. * | |
  165. * | |
  166. * | |
  167. * | |
  168. * | |
  169. * +----------------------------+ FLASHEND - BOOT_AUX_SECTION_SIZE
  170. * | Booloader Start Trampoline |
  171. * | (Not User App. Accessible) |
  172. * +----------------------------+ FLASHEND - (BOOT_AUX_SECTION_SIZE - 4)
  173. * | |
  174. * | Auxillery Bootloader |
  175. * | Space for Smaller Devices |
  176. * | (Not User App. Accessible) |
  177. * | |
  178. * +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
  179. * | |
  180. * | Bootloader Application |
  181. * | (Not User App. Accessible) |
  182. * | |
  183. * +----------------------------+ FLASHEND - 96
  184. * | API Table Trampolines |
  185. * | (Not User App. Accessible) |
  186. * +----------------------------+ FLASHEND - 32
  187. * | Bootloader API Table |
  188. * | (User App. Accessible) |
  189. * +----------------------------+ FLASHEND - 8
  190. * | Bootloader ID Constants |
  191. * | (User App. Accessible) |
  192. * +----------------------------+ FLASHEND
  193. * \endverbatim
  194. *
  195. * \subsection SSec_Aux_Space Auxiliary Bootloader Section
  196. * To make the bootloader function on smaller devices (those with a physical
  197. * bootloader section of smaller than 6KB)
  198. *
  199. * \section Sec_KnownIssues Known Issues:
  200. *
  201. * \par On Linux machines, the DFU bootloader is inaccessible.
  202. * On many Linux systems, non-root users do not have automatic access to newly
  203. * inserted DFU devices. Root privileges or a UDEV rule is required to gain
  204. * access.
  205. * See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
  206. *
  207. * \par After loading an application, it is not run automatically on startup.
  208. * Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
  209. * to run automatically when the device is reset. In most cases, the BOOTRST
  210. * fuse should be disabled and the HWBE fuse used instead to run the bootloader
  211. * when needed.
  212. *
  213. * \section Sec_Options Project Options
  214. *
  215. * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
  216. *
  217. * <table>
  218. * <tr>
  219. * <th><b>Define Name:</b></th>
  220. * <th><b>Location:</b></th>
  221. * <th><b>Description:</b></th>
  222. * </tr>
  223. * <tr>
  224. * <td>SECURE_MODE</td>
  225. * <td>AppConfig.h</td>
  226. * <td>If defined to \c true, the bootloader will not accept any memory commands other than a chip erase on start-up, until an
  227. * erase has been performed. This can be used in conjunction with the AVR's lockbits to prevent the AVRs firmware from
  228. * being dumped by unauthorized persons. When false, all memory operations are allowed at any time.</td>
  229. * </tr>
  230. * </table>
  231. */