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.

133 lines
6.9 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. ## Caterina
  34. Arduino boards and their clones use the [Caterina bootloader](https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/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.
  35. To ensure compatibility with the Caterina bootloader, make sure this block is present your `rules.mk`:
  36. # Bootloader
  37. # This definition is optional, and if your keyboard supports multiple bootloaders of
  38. # different sizes, comment this out, and the correct address will be loaded
  39. # automatically (+60). See bootloader.mk for all options.
  40. BOOTLOADER = caterina
  41. Compatible flashers:
  42. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  43. * [avrdude](http://www.nongnu.org/avrdude/) with avr109 / `:avrdude` (recommended command line)
  44. * [AVRDUDESS](https://github.com/zkemble/AVRDUDESS)
  45. Flashing sequence:
  46. 1. Press the `RESET` keycode, or short RST to GND quickly (you only have 7 seconds to flash once it enters)
  47. 2. Wait for the OS to detect the device
  48. 3. Flash a .hex file
  49. 4. Wait for the device to reset automatically
  50. or
  51. make <keyboard>:<keymap>:avrdude
  52. or if you want to flash multiple boards, use the following command
  53. make <keyboard>:<keymap>:avrdude-loop
  54. 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.
  55. ## Halfkay
  56. Halfkay is a super-slim protocol developed by PJRC that uses HID, and come on all Teensys (namely the 2.0).
  57. To ensure compatibility with the Halfkay bootloader, make sure this block is present your `rules.mk`:
  58. # Bootloader
  59. # This definition is optional, and if your keyboard supports multiple bootloaders of
  60. # different sizes, comment this out, and the correct address will be loaded
  61. # automatically (+60). See bootloader.mk for all options.
  62. BOOTLOADER = halfkay
  63. Compatible flashers:
  64. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  65. * [Teensy Loader](https://www.pjrc.com/teensy/loader.html)
  66. * [Teensy Loader Command Line](https://www.pjrc.com/teensy/loader_cli.html) (recommended command line)
  67. Flashing sequence:
  68. 1. Press the `RESET` keycode, or short RST to GND quickly (you only have 7 seconds to flash once it enters)
  69. 2. Wait for the OS to detect the device
  70. 3. Flash a .hex file
  71. 4. Reset the device into application mode (may be done automatically)
  72. ## STM32
  73. 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.
  74. At the moment, no `BOOTLOADER` variable is needed on `rules.mk` for STM32.
  75. Compatible flashers:
  76. * [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
  77. * [dfu-util](https://github.com/Stefan-Schmidt/dfu-util) / `:dfu-util` (recommended command line)
  78. Flashing sequence:
  79. 1. Enter the bootloader using any of the following methods:
  80. * Tap the `RESET` keycode (may not work on STM32F042 devices)
  81. * If a reset circuit is present, tap the RESET button
  82. * 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
  83. 2. Wait for the OS to detect the device
  84. 3. Flash a .bin file
  85. * You will receive a warning about the DFU signature; Just ignore it
  86. 4. Reset the device into application mode (may be done automatically)
  87. * 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