1 # Flashing Your Keyboard
3 Now that you've built a custom firmware file you'll want to flash your keyboard.
5 ## Flashing Your Keyboard with QMK Toolbox
7 The simplest way to flash your keyboard will be with the [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases).
9 However, the QMK Toolbox is only available for Windows and macOS currently. If you're using Linux (or just wish to flash the firmware from the command line), you'll have to use the [method outlined below](newbs_flashing.md#flash-your-keyboard-from-the-command-line).
11 ### Load The File Into QMK Toolbox
13 Begin by opening the QMK Toolbox application. You'll want to locate the firmware file in Finder or Explorer. Your keyboard firmware may be in one of two formats- `.hex` or `.bin`. QMK tries to copy the appropriate one for your keyboard into the root `qmk_firmware` directory.
15 If you are on Windows or macOS there are commands you can use to easily open the current firmware folder in Explorer or Finder.
29 The firmware file always follows this naming format:
32 <keyboard_name>_<keymap_name>.{bin,hex}
35 For example, the `planck/rev5` with a `default` keymap will have this filename:
38 planck_rev5_default.hex
41 Once you have located your firmware file drag it into the "Local file" box in QMK Toolbox, or click "Open" and navigate to where your firmware file is stored.
43 ### Put Your Keyboard Into DFU (Bootloader) Mode
45 In order to flash your custom firmware you have to put your keyboard into a special flashing mode. While it is in this mode you will not be able to type or otherwise use your keyboard. It is very important that you do not unplug your keyboard or otherwise interrupt the flashing process while the firmware is being written.
47 Different keyboards have different ways to enter this special mode. If your PCB currently runs QMK or TMK and you have not been given specific instructions try the following, in order:
49 * Hold down both shift keys and press `Pause`
50 * Hold down both shift keys and press `B`
51 * Unplug your keyboard, hold down the Spacebar and `B` at the same time, plug in your keyboard and wait a second before releasing the keys
52 * Press the physical `RESET` button on the bottom of the PCB
53 * Locate header pins on the PCB labeled `BOOT0` or `RESET`, short those together while plugging your PCB in
55 When you are successful you will see a message similar to this in QMK Toolbox:
58 *** Clueboard - Clueboard 66% HotSwap disconnected -- 0xC1ED:0x2390
59 *** DFU device connected
62 ### Flash Your Keyboard
64 Click the `Flash` button in QMK Toolbox. You will see output similar to the following:
67 *** Clueboard - Clueboard 66% HotSwap disconnected -- 0xC1ED:0x2390
68 *** DFU device connected
69 *** Attempting to flash, please don't remove device
70 >>> dfu-programmer atmega32u4 erase --force
71 Erasing flash... Success
72 Checking memory from 0x0 to 0x6FFF... Empty.
73 >>> dfu-programmer atmega32u4 flash /Users/skully/qmk_firmware/clueboard_66_hotswap_gen1_skully.hex
74 Checking memory from 0x0 to 0x55FF... Empty.
75 0% 100% Programming 0x5600 bytes...
76 [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] Success
77 0% 100% Reading 0x7000 bytes...
78 [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] Success
80 0x5600 bytes written into 0x7000 bytes memory (76.79%).
81 >>> dfu-programmer atmega32u4 reset
83 *** DFU device disconnected
84 *** Clueboard - Clueboard 66% HotSwap connected -- 0xC1ED:0x2390
87 ## Flash your Keyboard from the Command Line
89 This has been made pretty simple compared to what it used to be. When you are ready to compile and flash your firmware, open up your terminal window and run the build command:
91 make <my_keyboard>:<my_keymap>:flash
93 For example, if your keymap is named "xyverz" and you're building a keymap for a rev5 planck, you'll use this command:
95 make planck/rev5:xyverz:flash
97 This will check the keyboard's configuration, and then attempt to flash it based on the specified bootloader. This means that you don't need to know which bootloader that your keyboard uses. Just run the command, and let the command do the heavy lifting.
99 However, this does rely on the bootloader being set by the keyboard. If this information is not configured, or you're using a board that doesn't have a supported target to flash it, you will see this error:
101 WARNING: This board's bootloader is not specified or is not supported by the ":flash" target at this time.
103 In this case, you'll have to fall back on specifying the bootloader.
105 There are five main bootloaders that are used. Pro Micro and clones use Caterina, Teensys use HalfKay, OLKB's AVR boards use QMK-DFU, other ATmega32U4 boards use DFU, and most ARM boards use ARM DFU.
107 You can find more information about the bootloaders in the [Flashing Instructions and Bootloader Information](flashing.md) page.
109 If you know what bootloader that you're using, then when compiling the firmware, you can actually add some extra text to the `make` command to automate the flashing process.
113 For the DFU bootloader, when you're ready to compile and flash your firmware, open up your terminal window and run the build command:
115 make <my_keyboard>:<my_keymap>:dfu
117 For example, if your keymap is named "xyverz" and you're building a keymap for a rev5 planck, you'll use this command:
119 make planck/rev5:xyverz:dfu
121 Once it finishes compiling, it should output the following:
124 Linking: .build/planck_rev5_xyverz.elf [OK]
125 Creating load file for flashing: .build/planck_rev5_xyverz.hex [OK]
126 Copying planck_rev5_xyverz.hex to qmk_firmware folder [OK]
127 Checking file size of planck_rev5_xyverz.hex
128 * File size is fine - 18574/28672
131 After it gets to this point, the build script will look for the DFU bootloader every 5 seconds. It will repeat the following until the device is found or you cancel it.
133 dfu-programmer: no device present.
134 Error: Bootloader not found. Trying again in 5s.
136 Once it does this, you'll want to reset the controller. It should then show output similar to this:
139 *** Attempting to flash, please don't remove device
140 >>> dfu-programmer atmega32u4 erase --force
141 Erasing flash... Success
142 Checking memory from 0x0 to 0x6FFF... Empty.
143 >>> dfu-programmer atmega32u4 flash /Users/skully/qmk_firmware/clueboard_66_hotswap_gen1_skully.hex
144 Checking memory from 0x0 to 0x55FF... Empty.
145 0% 100% Programming 0x5600 bytes...
146 [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] Success
147 0% 100% Reading 0x7000 bytes...
148 [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] Success
149 Validating... Success
150 0x5600 bytes written into 0x7000 bytes memory (76.79%).
151 >>> dfu-programmer atmega32u4 reset
154 ?> If you have any issues with this - such as `dfu-programmer: no device present` - please see the [Frequently Asked Build Questions](faq_build.md).
158 There are a number of DFU commands that you can use to flash firmware to a DFU device:
160 * `: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.
161 * `:dfu-ee` - This flashes an `eep` file instead of the normal hex. This is uncommon.
162 * `: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._
163 * `: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._
168 For Arduino boards and their clones (such as the SparkFun ProMicro), when you're ready to compile and flash your firmware, open up your terminal window and run the build command:
170 make <my_keyboard>:<my_keymap>:avrdude
172 For example, if your keymap is named "xyverz" and you're building a keymap for a rev2 Lets Split, you'll use this command:
174 make lets_split/rev2:xyverz:avrdude
176 Once the firmware finishes compiling, it will output something like this:
179 Linking: .build/lets_split_rev2_xyverz.elf [OK]
180 Creating load file for flashing: .build/lets_split_rev2_xyverz.hex [OK]
181 Checking file size of lets_split_rev2_xyverz.hex [OK]
182 * File size is fine - 27938/28672
183 Detecting USB port, reset your controller now..............
186 At this point, reset the board and then the script will detect the bootloader and then flash the board. The output should look something like this:
189 Detected controller on USB port at /dev/ttyS15
191 Connecting to programmer: .
192 Found programmer: Id = "CATERIN"; type = S
193 Software Version = 1.0; No Hardware Version given.
194 Programmer supports auto addr increment.
195 Programmer supports buffered memory access with buffersize=128 bytes.
197 Programmer supports the following devices:
200 avrdude.exe: AVR device initialized and ready to accept instructions
202 Reading | ################################################## | 100% 0.00s
204 avrdude.exe: Device signature = 0x1e9587 (probably m32u4)
205 avrdude.exe: NOTE: "flash" memory has been specified, an erase cycle will be performed
206 To disable this feature, specify the -D option.
207 avrdude.exe: erasing chip
208 avrdude.exe: reading input file "./.build/lets_split_rev2_xyverz.hex"
209 avrdude.exe: input file ./.build/lets_split_rev2_xyverz.hex auto detected as Intel Hex
210 avrdude.exe: writing flash (27938 bytes):
212 Writing | ################################################## | 100% 2.40s
214 avrdude.exe: 27938 bytes of flash written
215 avrdude.exe: verifying flash memory against ./.build/lets_split_rev2_xyverz.hex:
216 avrdude.exe: load data flash data from input file ./.build/lets_split_rev2_xyverz.hex:
217 avrdude.exe: input file ./.build/lets_split_rev2_xyverz.hex auto detected as Intel Hex
218 avrdude.exe: input file ./.build/lets_split_rev2_xyverz.hex contains 27938 bytes
219 avrdude.exe: reading on-chip flash data:
221 Reading | ################################################## | 100% 0.43s
223 avrdude.exe: verifying ...
224 avrdude.exe: 27938 bytes of flash verified
226 avrdude.exe: safemode: Fuses OK (E:CB, H:D8, L:FF)
228 avrdude.exe done. Thank you.
230 If you have any issues with this, you may need to this:
232 sudo make <my_keyboard>:<my_keymap>:avrdude
235 #### Caterina commands
237 There are a number of DFU commands that you can use to flash firmware to a DFU device:
239 * `: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.
240 * `: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 Control+C._
241 * `: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._
242 * `: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._
247 For the PJRC devices (Teensy's), when you're ready to compile and flash your firmware, open up your terminal window and run the build command:
249 make <my_keyboard>:<my_keymap>:teensy
251 For example, if your keymap is named "xyverz" and you're building a keymap for an Ergodox or Ergodox EZ, you'll use this command:
253 make ergodox_ez:xyverz:teensy
255 Once the firmware finishes compiling, it will output something like this:
258 Linking: .build/ergodox_ez_xyverz.elf [OK]
259 Creating load file for flashing: .build/ergodox_ez_xyverz.hex [OK]
260 Checking file size of ergodox_ez_xyverz.hex [OK]
261 * File size is fine - 25584/32256
262 Teensy Loader, Command Line, Version 2.1
263 Read "./.build/ergodox_ez_xyverz.hex": 25584 bytes, 79.3% usage
264 Waiting for Teensy device...
265 (hint: press the reset button)
268 At this point, reset your board. Once you've done that, you'll see output like this:
271 Found HalfKay Bootloader
272 Read "./.build/ergodox_ez_xyverz.hex": 28532 bytes, 88.5% usage
273 Programming............................................................................................................................................................................
274 ...................................................
280 For a majority of ARM boards (including the Proton C, Planck Rev 6, and Preonic Rev 3), when you're ready to compile and flash your firmware, open up your terminal window and run the build command:
282 make <my_keyboard>:<my_keymap>:dfu-util
284 For example, if your keymap is named "xyverz" and you're building a keymap for the Planck Revision 6 keyboard, you'll use this command and then reboot the keyboard to the bootloader (before it finishes compiling):
286 make planck/rev6:xyverz:dfu-util
288 Once the firmware finishes compiling, it will output something like this:
291 Linking: .build/planck_rev6_xyverz.elf [OK]
292 Creating binary load file for flashing: .build/planck_rev6_xyverz.bin [OK]
293 Creating load file for flashing: .build/planck_rev6_xyverz.hex [OK]
296 text data bss dec hex filename
297 0 41820 0 41820 a35c .build/planck_rev6_xyverz.hex
299 Copying planck_rev6_xyverz.bin to qmk_firmware folder [OK]
302 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
303 Copyright 2010-2016 Tormod Volden and Stefan Schmidt
304 This program is Free Software and has ABSOLUTELY NO WARRANTY
305 Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
307 Invalid DFU suffix signature
308 A valid DFU suffix will be required in a future dfu-util release!!!
309 Opening DFU capable USB device...
311 Run-time device DFU version 011a
312 Claiming USB DFU Interface...
313 Setting Alternate Setting #0 ...
314 Determining device status: state = dfuERROR, status = 10
315 dfuERROR, clearing status
316 Determining device status: state = dfuIDLE, status = 0
318 DFU mode device DFU version 011a
319 Device returned transfer size 2048
320 DfuSe interface name: "Internal Flash "
321 Downloading to address = 0x08000000, size = 41824
322 Download [=========================] 100% 41824 bytes
324 File downloaded successfully
325 Transitioning to dfuMANIFEST state
330 There are a number of DFU commands that you can use to flash firmware to a STM32 device:
332 * `:dfu-util` - The default command for flashing to STM32 devices, and will wait until an STM32 bootloader is present. .
333 * `: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.
334 * `: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.
335 * `:st-link-cli` - This allows you to flash the firmware via ST-LINK's CLI utility, rather than dfu-util.
340 For Bootmapper Client(BMC)/bootloadHID/ATmega32A based boards, when you're ready to compile and flash your firmware, open up your terminal window and run the build command:
342 make <my_keyboard>:<my_keymap>:bootloaderHID
344 For example, if your keymap is named "xyverz" and you're building a keymap for a jj40, you'll use this command:
346 make jj40:xyverz:bootloaderHID
348 Once the firmware finishes compiling, it will output something like this:
351 Linking: .build/jj40_default.elf [OK]
352 Creating load file for flashing: .build/jj40_default.hex [OK]
353 Copying jj40_default.hex to qmk_firmware folder [OK]
354 Checking file size of jj40_default.hex [OK]
355 * The firmware size is fine - 21920/28672 (6752 bytes free)
358 After it gets to this point, the build script will look for the DFU bootloader every 5 seconds. It will repeat the following until the device is found or you cancel it.
361 Error opening HIDBoot device: The specified device was not found
365 Once it does this, you'll want to reset the controller. It should then show output similar to this:
368 Page size = 128 (0x80)
369 Device size = 32768 (0x8000); 30720 bytes remaining
370 Uploading 22016 (0x5600) bytes starting at 0 (0x0)
376 Congrats! Your custom firmware has been programmed to your keyboard!
378 Give it a try and make sure everything works the way you want it to. We've written [Testing and Debugging](newbs_testing_debugging.md) to round out this Newbie Guide, so head over there to learn about how to troubleshoot your custom functionality.