BootloaderCDC.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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 CDC 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)
  15. * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
  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>Communications Device Class (CDC)</td>
  29. * </tr>
  30. * <tr>
  31. * <td><b>USB Subclass:</b></td>
  32. * <td>Abstract Control Model (ACM)</td>
  33. * </tr>
  34. * <tr>
  35. * <td><b>Relevant Standards:</b></td>
  36. * <td>USBIF CDC Class Standard</td>
  37. * </tr>
  38. * <tr>
  39. * <td><b>Supported USB Speeds:</b></td>
  40. * <td>Full Speed Mode</td>
  41. * </tr>
  42. * </table>
  43. *
  44. * \section Sec_Description Project Description:
  45. *
  46. * This bootloader enumerates to the host as a CDC Class device (virtual serial port), allowing for AVR109
  47. * protocol compatible programming software to load firmware onto the AVR.
  48. *
  49. * Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
  50. * into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
  51. * edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
  52. *
  53. * When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
  54. * bootloader from the normal user application.
  55. *
  56. * \warning <b>THIS BOOTLOADER IS NOT SECURE.</b> Malicious entities can recover written data, even if the device
  57. * lockbits are set.
  58. *
  59. * \section Sec_Running Running the Bootloader
  60. *
  61. * On the USB AVR8 devices, setting the \c HWBE device fuse will cause the bootloader to run if the \c HWB pin of
  62. * the AVR is grounded when the device is reset.
  63. *
  64. * The are two behaviours of this bootloader, depending on the device's fuses:
  65. *
  66. * <b>If the device's BOOTRST fuse is set</b>, the bootloader will run any time the system is reset from
  67. * the external reset pin, unless no valid user application has been loaded. To initiate the bootloader, the
  68. * device's external reset pin should be grounded momentarily.
  69. *
  70. * <b>If the device's BOOTRST fuse is not set</b>, the bootloader will run only if initiated via a software
  71. * jump, or if the \c HWB pin was low during the last device reset (if the \c HWBE fuse is set).
  72. *
  73. * For board specific exceptions to the above, see below.
  74. *
  75. * \subsection SSec_XPLAIN Atmel Xplain Board
  76. * Ground the USB AVR JTAG's \c TCK pin to ground when powering on the board to start the bootloader. This assumes the
  77. * \c HWBE fuse is cleared and the \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board.
  78. *
  79. * \subsection SSec_Leonardo Arduino Leonardo Board
  80. * Ground \c IO13 when powering the board to start the bootloader. This assumes the \c HWBE fuse is cleared and the
  81. * \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board.
  82. *
  83. * \section Sec_Installation Driver Installation
  84. *
  85. * After running this bootloader for the first time on a new computer, you will need to supply the .INF
  86. * file located in this bootloader project's directory as the device's driver when running under Windows.
  87. * This will enable Windows to use its inbuilt CDC drivers, negating the need for custom drivers for the
  88. * device. Other Operating Systems should automatically use their own inbuilt CDC-ACM drivers.
  89. *
  90. * \section Sec_HostApp Host Controller Application
  91. *
  92. * This bootloader is compatible with the open source application AVRDUDE, Atmel's AVRPROG, or other
  93. * applications implementing the AVR109 protocol, which is documented on the Atmel website as an application
  94. * note.
  95. *
  96. * \subsection SSec_AVRDude AVRDUDE (Windows, Mac, Linux)
  97. *
  98. * AVRDude is a free, cross-platform and open source command line programmer for Atmel and third party AVR
  99. * programmers. It is available on the the Windows platform as part of the "WinAVR" package, or on other systems
  100. * either from a build from the official source code, or in many distributions as a precompiled binary package.
  101. *
  102. * To load a new HEX file with AVRDude, specify "AVR109" as the programmer, with the allocated COM port. On Windows
  103. * platforms this will be a COMx port name:
  104. * \code
  105. * avrdude -c AVR109 -p at90usb1287 -P COM0 -U flash:w:Mouse.hex
  106. * \endcode
  107. *
  108. * On Linux systems, this will typically be a /dev/ttyACMx port name:
  109. * \code
  110. * avrdude -c AVR109 -p at90usb1287 -P /dev/ttyACM0 -U flash:w:Mouse.hex
  111. * \endcode
  112. *
  113. * Refer to the AVRDude project documentation for additional usage instructions.
  114. *
  115. * \section Sec_API User Application API
  116. *
  117. * Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
  118. * allowing the user application to call into the bootloader at runtime to read and write FLASH data.
  119. *
  120. * By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
  121. * following layout:
  122. *
  123. * \code
  124. * #define BOOTLOADER_API_TABLE_SIZE 32
  125. * #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
  126. * #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
  127. *
  128. * void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
  129. * void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
  130. * void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
  131. * uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
  132. * uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
  133. * uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
  134. * void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
  135. *
  136. * #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
  137. * #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
  138. *
  139. * #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
  140. * #define BOOTLOADER_CDC_SIGNATURE 0xDF00
  141. *
  142. * #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
  143. * #define BOOTLOADER_ADDRESS_LENGTH 4
  144. * \endcode
  145. *
  146. * From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
  147. * \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
  148. * can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
  149. * to the value \c BOOTLOADER_CDC_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH
  150. * memory starting from address \c BOOTLOADER_ADDRESS_START.
  151. *
  152. * \subsection SSec_API_MemLayout Device Memory Map
  153. * The following illustration indicates the final memory map of the device when loaded with the bootloader.
  154. *
  155. * \verbatim
  156. * +----------------------------+ 0x0000
  157. * | |
  158. * | |
  159. * | |
  160. * | |
  161. * | |
  162. * | |
  163. * | |
  164. * | |
  165. * | User Application |
  166. * | |
  167. * | |
  168. * | |
  169. * | |
  170. * | |
  171. * | |
  172. * | |
  173. * +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
  174. * | |
  175. * | Bootloader Application |
  176. * | (Not User App. Accessible) |
  177. * | |
  178. * +----------------------------+ FLASHEND - 96
  179. * | API Table Trampolines |
  180. * | (Not User App. Accessible) |
  181. * +----------------------------+ FLASHEND - 32
  182. * | Bootloader API Table |
  183. * | (User App. Accessible) |
  184. * +----------------------------+ FLASHEND - 8
  185. * | Bootloader ID Constants |
  186. * | (User App. Accessible) |
  187. * +----------------------------+ FLASHEND
  188. * \endverbatim
  189. *
  190. * \section Sec_KnownIssues Known Issues:
  191. *
  192. * \par On Linux machines, the CDC bootloader is unstable or inaccessible.
  193. * A change to the \c ModemManager module in many Linux distributions causes
  194. * this module to try to take control over inserted CDC devices, corrupting the
  195. * datastream. A UDEV rule is required to prevent this.
  196. * See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
  197. * If the issue still persists then uninstall modemmanager by executing <tt>sudo apt-get remove modemmanager</tt>, or
  198. * the equivalent using your chosen distribution's package manager.
  199. *
  200. * \par On Linux machines, the CDC bootloader is inaccessible.
  201. * On many Linux systems, non-root users do not have automatic access to newly
  202. * inserted CDC devices. Root privileges or a UDEV rule is required to gain
  203. * access.
  204. * See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
  205. *
  206. * \section Sec_Options Project Options
  207. *
  208. * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
  209. *
  210. * <table>
  211. * <tr>
  212. * <th><b>Define Name:</b></th>
  213. * <th><b>Location:</b></th>
  214. * <th><b>Description:</b></th>
  215. * </tr>
  216. * <tr>
  217. * <td>NO_BLOCK_SUPPORT</td>
  218. * <td>AppConfig.h</td>
  219. * <td>Define to disable memory block read/write support in the bootloader, requiring all reads and writes to be made
  220. * using the byte-level commands.</td>
  221. * </tr>
  222. * <tr>
  223. * <td>NO_EEPROM_BYTE_SUPPORT</td>
  224. * <td>AppConfig.h</td>
  225. * <td>Define to disable EEPROM memory byte read/write support in the bootloader, requiring all EEPROM reads and writes
  226. * to be made using the block-level commands.</td>
  227. * </tr>
  228. * <tr>
  229. * <td>NO_FLASH_BYTE_SUPPORT</td>
  230. * <td>AppConfig.h</td>
  231. * <td>Define to disable FLASH memory byte read/write support in the bootloader, requiring all FLASH reads and writes
  232. * to be made using the block-level commands.</td>
  233. * </tr>
  234. * <tr>
  235. * <td>NO_LOCK_BYTE_WRITE_SUPPORT</td>
  236. * <td>AppConfig.h</td>
  237. * <td>Define to disable lock byte write support in the bootloader, preventing the lock bits from being set programmatically.</td>
  238. * </tr>
  239. * </table>
  240. */