Add Zadig 101 to docs (#6585)
[jackhill/qmk/firmware.git] / docs / flashing.md
CommitLineData
7b0356d1 1# Flashing Instructions and Bootloader Information
4d421ee3
JH
2
3There 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.
4
b3f6aa94 5If 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`.
9fdc2762 6
4d421ee3
JH
7## DFU
8
9Atmel'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.
10
af37bb2f 11To ensure compatibility with the DFU bootloader, make sure this block is present your `rules.mk` (optionally with `lufa-dfu` or `qmk-dfu` instead):
9fdc2762
JH
12
13 # Bootloader
14 # This definition is optional, and if your keyboard supports multiple bootloaders of
bb53635f 15 # different sizes, comment this out, and the correct address will be loaded
9fdc2762
JH
16 # automatically (+60). See bootloader.mk for all options.
17 BOOTLOADER = atmel-dfu
4d421ee3
JH
18
19Compatible flashers:
20
21* [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
af37bb2f 22* [dfu-programmer](https://github.com/dfu-programmer/dfu-programmer) / `:dfu` in QMK (recommended command line)
a7fca476 23* [Atmel's Flip](http://www.microchip.com/developmenttools/productdetails.aspx?partno=flip) (not recommended)
4d421ee3
JH
24
25Flashing sequence:
26
271. Press the `RESET` keycode, or tap the RESET button (or short RST to GND).
282. Wait for the OS to detect the device
293. Erase the memory (may be done automatically)
304. Flash a .hex file
315. Reset the device into application mode (may be done automatically)
32
33or:
34
35 make <keyboard>:<keymap>:dfu
36
9fdc2762
JH
37### QMK DFU
38
39QMK 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):
40
41 #define QMK_ESC_OUTPUT F1 // usually COL
42 #define QMK_ESC_INPUT D5 // usually ROW
43 #define QMK_LED E6
44 #define QMK_SPEAKER C6
45
46The Manufacturer and Product names are automatically pulled from your `config.h`, and "Bootloader" is added to the product.
47
48To generate this bootloader, use the `bootloader` target, eg `make planck/rev4:default:bootloader`.
49
50To generate a production-ready .hex file (containing the application and the bootloader), use the `production` target, eg `make planck/rev4:default:production`.
51
c534a4c7
DJ
52### DFU commands
53
54There are a number of DFU commands that you can use to flash firmware to a DFU device:
55
56* `: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.
57* `:dfu-ee` - This flashes an `eep` file instead of the normal hex. This is uncommon.
58* `: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._
59* `: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._
60
4d421ee3
JH
61## Caterina
62
ab294813 63Arduino 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.
4d421ee3 64
af37bb2f 65To ensure compatibility with the Caterina bootloader, make sure this block is present your `rules.mk`:
4d421ee3 66
9fdc2762
JH
67 # Bootloader
68 # This definition is optional, and if your keyboard supports multiple bootloaders of
bb53635f 69 # different sizes, comment this out, and the correct address will be loaded
9fdc2762
JH
70 # automatically (+60). See bootloader.mk for all options.
71 BOOTLOADER = caterina
4d421ee3
JH
72
73Compatible flashers:
74
75* [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
af37bb2f 76* [avrdude](http://www.nongnu.org/avrdude/) with avr109 / `:avrdude` (recommended command line)
4d421ee3
JH
77* [AVRDUDESS](https://github.com/zkemble/AVRDUDESS)
78
79Flashing sequence:
80
811. Press the `RESET` keycode, or short RST to GND quickly (you only have 7 seconds to flash once it enters)
822. Wait for the OS to detect the device
292a87ad
MP
833. Flash a .hex file
844. Wait for the device to reset automatically
4d421ee3
JH
85
86or
87
88 make <keyboard>:<keymap>:avrdude
89
baebbc09
TI
90or if you want to flash multiple boards, use the following command
91
92 make <keyboard>:<keymap>:avrdude-loop
93
94When 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.
95
c534a4c7 96
4d421ee3
JH
97## Halfkay
98
99Halfkay is a super-slim protocol developed by PJRC that uses HID, and come on all Teensys (namely the 2.0).
100
af37bb2f 101To ensure compatibility with the Halfkay bootloader, make sure this block is present your `rules.mk`:
9fdc2762
JH
102
103 # Bootloader
104 # This definition is optional, and if your keyboard supports multiple bootloaders of
bb53635f 105 # different sizes, comment this out, and the correct address will be loaded
9fdc2762
JH
106 # automatically (+60). See bootloader.mk for all options.
107 BOOTLOADER = halfkay
4d421ee3
JH
108
109Compatible flashers:
110
111* [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
112* [Teensy Loader](https://www.pjrc.com/teensy/loader.html)
af37bb2f 113* [Teensy Loader Command Line](https://www.pjrc.com/teensy/loader_cli.html) (recommended command line)
4d421ee3
JH
114
115Flashing sequence:
116
1171. Press the `RESET` keycode, or short RST to GND quickly (you only have 7 seconds to flash once it enters)
1182. Wait for the OS to detect the device
35389557 1193. Flash a .hex file
1204. Reset the device into application mode (may be done automatically)
121
122## USBasploader
123
124USBasploader is a bootloader developed by matrixstorm. It is used in some non-USB AVR chips such as the ATmega328P, which run V-USB.
125
126To ensure compatibility with the USBasploader bootloader, make sure this block is present in your `rules.mk`:
127
128 # Bootloader
129 # This definition is optional, and if your keyboard supports multiple bootloaders of
130 # different sizes, comment this out, and the correct address will be loaded
131 # automatically (+60). See bootloader.mk for all options.
132 BOOTLOADER = USBasp
133
134Compatible flashers:
135
136* [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
137* [avrdude](http://www.nongnu.org/avrdude/) with the `usbasp` programmer
138* [AVRDUDESS](https://github.com/zkemble/AVRDUDESS)
139
140Flashing sequence:
141
1421. Press the `RESET` keycode, or keep the boot pin shorted to GND while quickly shorting RST to GND
1432. Wait for the OS to detect the device
292a87ad
MP
1443. Flash a .hex file
1454. Reset the device into application mode (may be done automatically)
146
147## STM32
148
149All 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
151At the moment, no `BOOTLOADER` variable is needed on `rules.mk` for STM32.
152
153Compatible flashers:
154
155* [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI)
156* [dfu-util](https://github.com/Stefan-Schmidt/dfu-util) / `:dfu-util` (recommended command line)
157
158Flashing sequence:
159
1601. Enter the bootloader using any of the following methods:
161 * Tap the `RESET` keycode (may not work on STM32F042 devices)
162 * If a reset circuit is present, tap the RESET button
163 * 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
1642. Wait for the OS to detect the device
1653. Flash a .bin file
166 * You will receive a warning about the DFU signature; Just ignore it
1674. Reset the device into application mode (may be done automatically)
168 * 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
c534a4c7
DJ
169
170### STM32 Commands
171
172There are a number of DFU commands that you can use to flash firmware to a STM32 device:
173
ae44ec98
JC
174* `:dfu-util` - The default command for flashing to STM32 devices.
175* `:st-link-cli` - This allows you to flash the firmware via ST-LINK's CLI utility, rather than dfu-util.