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.

177 lines
9.3 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. # Bootloader
  8. # This definition is optional, and if your keyboard supports multiple bootloaders of
  9. # different sizes, comment this out, and the correct address will be loaded
  10. # automatically (+60). See bootloader.mk for all options.
  11. BOOTLOADER = atmel-dfu
  12. Compatible flashers:
  13. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  14. * [dfu-programmer](https://github.com/dfu-programmer/dfu-programmer) / `:dfu` in QMK (recommended command line)
  15. * [Atmel's Flip](http://www.microchip.com/developmenttools/productdetails.aspx?partno=flip) (not recommended)
  16. Flashing sequence:
  17. 1. Press the `RESET` keycode, or tap the RESET button (or short RST to GND).
  18. 2. Wait for the OS to detect the device
  19. 3. Erase the memory (may be done automatically)
  20. 4. Flash a .hex file
  21. 5. Reset the device into application mode (may be done automatically)
  22. or:
  23. make <keyboard>:<keymap>:dfu
  24. ### QMK DFU
  25. 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):
  26. #define QMK_ESC_OUTPUT F1 // usually COL
  27. #define QMK_ESC_INPUT D5 // usually ROW
  28. #define QMK_LED E6
  29. #define QMK_SPEAKER C6
  30. The Manufacturer and Product names are automatically pulled from your `config.h`, and "Bootloader" is added to the product.
  31. To generate this bootloader, use the `bootloader` target, eg `make planck/rev4:default:bootloader`.
  32. To generate a production-ready .hex file (containing the application and the bootloader), use the `production` target, eg `make planck/rev4:default:production`.
  33. ### DFU commands
  34. There are a number of DFU commands that you can use to flash firmware to a DFU device:
  35. * `: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.
  36. * `:dfu-ee` - This flashes an `eep` file instead of the normal hex. This is uncommon.
  37. * `: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._
  38. * `: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._
  39. ## Caterina
  40. 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.
  41. To ensure compatibility with the Caterina bootloader, make sure this block is present your `rules.mk`:
  42. # Bootloader
  43. # This definition is optional, and if your keyboard supports multiple bootloaders of
  44. # different sizes, comment this out, and the correct address will be loaded
  45. # automatically (+60). See bootloader.mk for all options.
  46. BOOTLOADER = caterina
  47. Compatible flashers:
  48. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  49. * [avrdude](http://www.nongnu.org/avrdude/) with avr109 / `:avrdude` (recommended command line)
  50. * [AVRDUDESS](https://github.com/zkemble/AVRDUDESS)
  51. Flashing sequence:
  52. 1. Press the `RESET` keycode, or short RST to GND quickly (you only have 7 seconds to flash once it enters)
  53. 2. Wait for the OS to detect the device
  54. 3. Flash a .hex file
  55. 4. Wait for the device to reset automatically
  56. or
  57. make <keyboard>:<keymap>:avrdude
  58. or if you want to flash multiple boards, use the following command
  59. make <keyboard>:<keymap>:avrdude-loop
  60. When you're done flashing boards, you'll need to hit Ctrl + C or whatever the correct keystroke is for your operating system to break the loop.
  61. ## Halfkay
  62. Halfkay is a super-slim protocol developed by PJRC that uses HID, and come on all Teensys (namely the 2.0).
  63. To ensure compatibility with the Halfkay bootloader, make sure this block is present your `rules.mk`:
  64. # Bootloader
  65. # This definition is optional, and if your keyboard supports multiple bootloaders of
  66. # different sizes, comment this out, and the correct address will be loaded
  67. # automatically (+60). See bootloader.mk for all options.
  68. BOOTLOADER = halfkay
  69. Compatible flashers:
  70. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  71. * [Teensy Loader](https://www.pjrc.com/teensy/loader.html)
  72. * [Teensy Loader Command Line](https://www.pjrc.com/teensy/loader_cli.html) (recommended command line)
  73. Flashing sequence:
  74. 1. Press the `RESET` keycode, or short RST to GND quickly (you only have 7 seconds to flash once it enters)
  75. 2. Wait for the OS to detect the device
  76. 3. Flash a .hex file
  77. 4. Reset the device into application mode (may be done automatically)
  78. ## USBasploader
  79. USBasploader is a bootloader developed by matrixstorm. It is used in some non-USB AVR chips such as the ATmega328P, which run V-USB.
  80. To ensure compatibility with the USBasploader bootloader, make sure this block is present in your `rules.mk`:
  81. # Bootloader
  82. # This definition is optional, and if your keyboard supports multiple bootloaders of
  83. # different sizes, comment this out, and the correct address will be loaded
  84. # automatically (+60). See bootloader.mk for all options.
  85. BOOTLOADER = USBasp
  86. Compatible flashers:
  87. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  88. * [avrdude](http://www.nongnu.org/avrdude/) with the `usbasp` programmer
  89. * [AVRDUDESS](https://github.com/zkemble/AVRDUDESS)
  90. Flashing sequence:
  91. 1. Press the `RESET` keycode, or keep the boot pin shorted to GND while quickly shorting RST to GND
  92. 2. Wait for the OS to detect the device
  93. 3. Flash a .hex file
  94. 4. Reset the device into application mode (may be done automatically)
  95. ## STM32
  96. 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.
  97. At the moment, no `BOOTLOADER` variable is needed on `rules.mk` for STM32.
  98. Compatible flashers:
  99. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  100. * [dfu-util](https://github.com/Stefan-Schmidt/dfu-util) / `:dfu-util` (recommended command line)
  101. Flashing sequence:
  102. 1. Enter the bootloader using any of the following methods:
  103. * Tap the `RESET` keycode (may not work on STM32F042 devices)
  104. * If a reset circuit is present, tap the RESET button
  105. * 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
  106. 2. Wait for the OS to detect the device
  107. 3. Flash a .bin file
  108. * You will receive a warning about the DFU signature; Just ignore it
  109. 4. Reset the device into application mode (may be done automatically)
  110. * 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
  111. ### STM32 Commands
  112. There are a number of DFU commands that you can use to flash firmware to a STM32 device:
  113. * `:dfu-util` - The default command for flashing to STM32 devices.
  114. * `:dfu-util-wait` - This works like the default command, but it gives you a (configurable) 10 second timeout before it attempts to flash the firmware. You can use `TIME_DELAY=20` from the command line to change the timeout.
  115. * Eg: `make <keyboard>:<keymap>:dfu-util TIME_DELAY=5`
  116. * `:st-link-cli` - This allows you to flash the firmware via ST-LINK's CLI utility, rather than dfu-util.