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.

BootloaderCDC.txt 11KB

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