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