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.

242 lines
11 KiB

  1. # Flashing Instructions and Bootloader Information
  2. There are quite a few different types of bootloaders that keyboards use, and just about all of the use a different flashing method. Luckily, projects like the [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) aim to be compatible with all the different types without having to think about it much, but this article will describe the different types of bootloaders, and available methods for flashing them.
  3. If you have a bootloader selected with the `BOOTLOADER` variable in your `rules.mk`, QMK will automatically calculate if your .hex file is the right size to be flashed to the device, and output the total size in bytes (along with the max). To run this process manually, compile with the target `check-size`, eg `make planck/rev4:default:check-size`.
  4. ## DFU
  5. Atmel's DFU bootloader comes on all atmega32u4 chips by default, and is used by many keyboards that have their own ICs on their PCBs (Older OLKB boards, Clueboards). Some keyboards may also use LUFA's DFU bootloader (or QMK's fork) (Newer OLKB boards) that adds in additional features specific to that hardware.
  6. To ensure compatibility with the DFU bootloader, make sure this block is present your `rules.mk` (optionally with `lufa-dfu` or `qmk-dfu` instead):
  7. ```make
  8. # Bootloader selection
  9. # Teensy halfkay
  10. # Pro Micro caterina
  11. # Atmel DFU atmel-dfu
  12. # LUFA DFU lufa-dfu
  13. # QMK DFU qmk-dfu
  14. # ATmega32A bootloadHID
  15. # ATmega328P USBasp
  16. BOOTLOADER = atmel-dfu
  17. ```
  18. Compatible flashers:
  19. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  20. * [dfu-programmer](https://github.com/dfu-programmer/dfu-programmer) / `:dfu` in QMK (recommended command line)
  21. * [Atmel's Flip](http://www.microchip.com/developmenttools/productdetails.aspx?partno=flip) (not recommended)
  22. Flashing sequence:
  23. 1. Press the `RESET` keycode, or tap the RESET button (or short RST to GND).
  24. 2. Wait for the OS to detect the device
  25. 3. Erase the memory (may be done automatically)
  26. 4. Flash a .hex file
  27. 5. Reset the device into application mode (may be done automatically)
  28. or:
  29. make <keyboard>:<keymap>:dfu
  30. ### QMK DFU
  31. QMK has a fork of the LUFA DFU bootloader that allows for a simple matrix scan for exiting the bootloader and returning to the application, as well as flashing an LED/making a ticking noise with a speaker when things are happening. To enable these features, use this block in your `config.h` (The key that exits the bootloader needs to be hooked-up to the INPUT and OUTPUT defined here):
  32. #define QMK_ESC_OUTPUT F1 // usually COL
  33. #define QMK_ESC_INPUT D5 // usually ROW
  34. #define QMK_LED E6
  35. #define QMK_SPEAKER C6
  36. The Manufacturer and Product names are automatically pulled from your `config.h`, and "Bootloader" is added to the product.
  37. To generate this bootloader, use the `bootloader` target, eg `make planck/rev4:default:bootloader`.
  38. To generate a production-ready .hex file (containing the application and the bootloader), use the `production` target, eg `make planck/rev4:default:production`.
  39. ### DFU commands
  40. There are a number of DFU commands that you can use to flash firmware to a DFU device:
  41. * `:dfu` - This is the normal option and waits until a DFU device is available, and then flashes the firmware. This will check every 5 seconds, to see if a DFU device has appeared.
  42. * `:dfu-ee` - This flashes an `eep` file instead of the normal hex. This is uncommon.
  43. * `:dfu-split-left` - This flashes the normal firmware, just like the default option (`:dfu`). However, this also flashes the "Left Side" EEPROM file for split keyboards. _This is ideal for Elite C based split keyboards._
  44. * `:dfu-split-right` - This flashes the normal firmware, just like the default option (`:dfu`). However, this also flashes the "Right Side" EEPROM file for split keyboards. _This is ideal for Elite C based split keyboards._
  45. ## Caterina
  46. Arduino boards and their clones use the [Caterina bootloader](https://github.com/arduino/ArduinoCore-avr/tree/master/bootloaders/caterina) (any keyboard built with a Pro Micro, or clone), and uses the avr109 protocol to communicate through virtual serial. Bootloaders like [A-Star](https://www.pololu.com/docs/0J61/9) are based on Caterina.
  47. To ensure compatibility with the Caterina bootloader, make sure this block is present your `rules.mk`:
  48. ```make
  49. # Bootloader selection
  50. # Teensy halfkay
  51. # Pro Micro caterina
  52. # Atmel DFU atmel-dfu
  53. # LUFA DFU lufa-dfu
  54. # QMK DFU qmk-dfu
  55. # ATmega32A bootloadHID
  56. # ATmega328P USBasp
  57. BOOTLOADER = caterina
  58. ```
  59. Compatible flashers:
  60. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  61. * [avrdude](http://www.nongnu.org/avrdude/) with avr109 / `:avrdude` (recommended command line)
  62. * [AVRDUDESS](https://github.com/zkemble/AVRDUDESS)
  63. Flashing sequence:
  64. 1. Press the `RESET` keycode, or short RST to GND quickly (you only have 7 seconds to flash once it enters)
  65. 2. Wait for the OS to detect the device
  66. 3. Flash a .hex file
  67. 4. Wait for the device to reset automatically
  68. or
  69. make <keyboard>:<keymap>:avrdude
  70. #### Caterina commands
  71. There are a number of DFU commands that you can use to flash firmware to a DFU device:
  72. * `:avrdude` - This is the normal option which waits until a Caterina device is available (by detecting a new COM port), and then flashes the firmware.
  73. * `:avrdude-loop` - This runs the same command as `:avrdude`, but after each device is flashed, it will attempt to flash again. This is useful for bulk flashing. _This requires you to manually escape the loop by hitting Ctrl+C._
  74. * `:avrdude-split-left` - This flashes the normal firmware, just like the default option (`:avrdude`). However, this also flashes the "Left Side" EEPROM file for split keyboards. _This is ideal for Pro Micro based split keyboards._
  75. * `:avrdude-split-right` - This flashes the normal firmware, just like the default option (`:avrdude`). However, this also flashes the "Right Side" EEPROM file for split keyboards. _This is ideal for Pro Micro based split keyboards._
  76. ## Halfkay
  77. Halfkay is a super-slim protocol developed by PJRC that uses HID, and come on all Teensys (namely the 2.0).
  78. To ensure compatibility with the Halfkay bootloader, make sure this block is present your `rules.mk`:
  79. ```make
  80. # Bootloader selection
  81. # Teensy halfkay
  82. # Pro Micro caterina
  83. # Atmel DFU atmel-dfu
  84. # LUFA DFU lufa-dfu
  85. # QMK DFU qmk-dfu
  86. # ATmega32A bootloadHID
  87. # ATmega328P USBasp
  88. BOOTLOADER = halfkay
  89. ```
  90. Compatible flashers:
  91. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  92. * [Teensy Loader](https://www.pjrc.com/teensy/loader.html)
  93. * [Teensy Loader Command Line](https://www.pjrc.com/teensy/loader_cli.html) (recommended command line)
  94. Flashing sequence:
  95. 1. Press the `RESET` keycode, or short RST to GND quickly (you only have 7 seconds to flash once it enters)
  96. 2. Wait for the OS to detect the device
  97. 3. Flash a .hex file
  98. 4. Reset the device into application mode (may be done automatically)
  99. ## USBasploader
  100. USBasploader is a bootloader developed by matrixstorm. It is used in some non-USB AVR chips such as the ATmega328P, which run V-USB.
  101. To ensure compatibility with the USBasploader bootloader, make sure this block is present in your `rules.mk`:
  102. ```make
  103. # Bootloader selection
  104. # Teensy halfkay
  105. # Pro Micro caterina
  106. # Atmel DFU atmel-dfu
  107. # LUFA DFU lufa-dfu
  108. # QMK DFU qmk-dfu
  109. # ATmega32A bootloadHID
  110. # ATmega328P USBasp
  111. BOOTLOADER = USBasp
  112. ```
  113. Compatible flashers:
  114. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  115. * [avrdude](http://www.nongnu.org/avrdude/) with the `usbasp` programmer
  116. * [AVRDUDESS](https://github.com/zkemble/AVRDUDESS)
  117. Flashing sequence:
  118. 1. Press the `RESET` keycode, or keep the boot pin shorted to GND while quickly shorting RST to GND
  119. 2. Wait for the OS to detect the device
  120. 3. Flash a .hex file
  121. 4. Reset the device into application mode (may be done automatically)
  122. ## BootloadHID
  123. BootloadHID is a USB bootloader for AVR microcontrollers. The uploader tool requires no kernel level driver on Windows and can therefore be run without installing any DLLs.
  124. To ensure compatibility with the bootloadHID bootloader, make sure this block is present your `rules.mk`:
  125. ```make
  126. # Bootloader selection
  127. # Teensy halfkay
  128. # Pro Micro caterina
  129. # Atmel DFU atmel-dfu
  130. # LUFA DFU lufa-dfu
  131. # QMK DFU qmk-dfu
  132. # ATmega32A bootloadHID
  133. # ATmega328P USBasp
  134. BOOTLOADER = bootloadHID
  135. ```
  136. Compatible flashers:
  137. * [HIDBootFlash](http://vusb.wikidot.com/project:hidbootflash) (recommended Windows GUI)
  138. * [bootloadhid Command Line](https://www.obdev.at/products/vusb/bootloadhid.html) / `:BootloadHID` in QMK (recommended command line)
  139. Flashing sequence:
  140. 1. Enter the bootloader using any of the following methods:
  141. * Tap the `RESET` keycode (may not work on all devices)
  142. * Hold the salt key while plugging the keyboard in (usually documented within keyboard readme)
  143. 2. Wait for the OS to detect the device
  144. 3. Flash a .hex file
  145. 4. Reset the device into application mode (may be done automatically)
  146. or:
  147. make <keyboard>:<keymap>:bootloadHID
  148. ## STM32
  149. All STM32 chips come preloaded with a factory bootloader that cannot be modified nor deleted. Some STM32 chips have bootloaders that do not come with USB programming (e.g. STM32F103) but the process is still the same.
  150. At the moment, no `BOOTLOADER` variable is needed on `rules.mk` for STM32.
  151. Compatible flashers:
  152. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  153. * [dfu-util](https://github.com/Stefan-Schmidt/dfu-util) / `:dfu-util` (recommended command line)
  154. Flashing sequence:
  155. 1. Enter the bootloader using any of the following methods:
  156. * Tap the `RESET` keycode (may not work on STM32F042 devices)
  157. * If a reset circuit is present, tap the RESET button
  158. * Otherwise, you need to bridge BOOT0 to VCC (via BOOT0 button or bridge), short RESET to GND (via RESET button or bridge), and then let go of the BOOT0 bridge
  159. 2. Wait for the OS to detect the device
  160. 3. Flash a .bin file
  161. * You will receive a warning about the DFU signature; Just ignore it
  162. 4. Reset the device into application mode (may be done automatically)
  163. * If you are building from command line (e.g. `make planck/rev6:default:dfu-util`), make sure that `:leave` is passed to the `DFU_ARGS` variable inside your `rules.mk` (e.g. `DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave`) so that your device resets after flashing
  164. ### STM32 Commands
  165. There are a number of DFU commands that you can use to flash firmware to a STM32 device:
  166. * `:dfu-util` - The default command for flashing to STM32 devices, and will wait until an STM32 bootloader device is present.
  167. * `:dfu-util-split-left` - This flashes the normal firmware, just like the default option (`:dfu-util`). However, this also configures the "Left Side" EEPROM setting for split keyboards.
  168. * `:dfu-util-split-right` - This flashes the normal firmware, just like the default option (`:dfu-util`). However, this also configures the "Right Side" EEPROM setting for split keyboards.
  169. * `:st-link-cli` - This allows you to flash the firmware via ST-LINK's CLI utility, rather than dfu-util.