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.

359 lines
16 KiB

  1. # Flashing Your Keyboard
  2. Now that you've built a custom firmware file you'll want to flash your keyboard.
  3. ## Flashing Your Keyboard with QMK Toolbox
  4. The simplest way to flash your keyboard will be with the [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases).
  5. 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).
  6. ### Load The File Into QMK Toolbox
  7. 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.
  8. If you are on Windows or macOS there are commands you can use to easily open the current firmware folder in Explorer or Finder.
  9. #### Windows
  10. ```
  11. start .
  12. ```
  13. #### macOS
  14. ```
  15. open .
  16. ```
  17. The firmware file always follows this naming format:
  18. ```
  19. <keyboard_name>_<keymap_name>.{bin,hex}
  20. ```
  21. For example, the `planck/rev5` with a `default` keymap will have this filename:
  22. ```
  23. planck_rev5_default.hex
  24. ```
  25. 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.
  26. ### Put Your Keyboard Into DFU (Bootloader) Mode
  27. 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.
  28. 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:
  29. * Hold down both shift keys and press `Pause`
  30. * Hold down both shift keys and press `B`
  31. * 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
  32. * Press the physical `RESET` button on the bottom of the PCB
  33. * Locate header pins on the PCB labeled `BOOT0` or `RESET`, short those together while plugging your PCB in
  34. When you are successful you will see a message similar to this in QMK Toolbox:
  35. ```
  36. *** Clueboard - Clueboard 66% HotSwap disconnected -- 0xC1ED:0x2390
  37. *** DFU device connected
  38. ```
  39. ### Flash Your Keyboard
  40. Click the `Flash` button in QMK Toolbox. You will see output similar to the following:
  41. ```
  42. *** Clueboard - Clueboard 66% HotSwap disconnected -- 0xC1ED:0x2390
  43. *** DFU device connected
  44. *** Attempting to flash, please don't remove device
  45. >>> dfu-programmer atmega32u4 erase --force
  46. Erasing flash... Success
  47. Checking memory from 0x0 to 0x6FFF... Empty.
  48. >>> dfu-programmer atmega32u4 flash /Users/skully/qmk_firmware/clueboard_66_hotswap_gen1_skully.hex
  49. Checking memory from 0x0 to 0x55FF... Empty.
  50. 0% 100% Programming 0x5600 bytes...
  51. [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] Success
  52. 0% 100% Reading 0x7000 bytes...
  53. [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] Success
  54. Validating... Success
  55. 0x5600 bytes written into 0x7000 bytes memory (76.79%).
  56. >>> dfu-programmer atmega32u4 reset
  57. *** DFU device disconnected
  58. *** Clueboard - Clueboard 66% HotSwap connected -- 0xC1ED:0x2390
  59. ```
  60. ## Flash your Keyboard from the Command Line
  61. First thing you'll need to know is which bootloader that your keyboard uses. There are four main bootloaders that are used, usually. Pro-Micro and clones use CATERINA, and Teensy's use Halfkay, OLKB boards use QMK-DFU, and other atmega32u4 chips use DFU.
  62. You can find more information about the bootloaders in the [Flashing Instructions and Bootloader Information](flashing.md) page.
  63. 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.
  64. ### DFU
  65. For the DFU bootloader, when you're ready to compile and flash your firmware, open up your terminal window and run the build command:
  66. make <my_keyboard>:<my_keymap>:dfu
  67. For example, if your keymap is named "xyverz" and you're building a keymap for a rev5 planck, you'll use this command:
  68. make planck/rev5:xyverz:dfu
  69. Once it finishes compiling, it should output the following:
  70. ```
  71. Linking: .build/planck_rev5_xyverz.elf [OK]
  72. Creating load file for flashing: .build/planck_rev5_xyverz.hex [OK]
  73. Copying planck_rev5_xyverz.hex to qmk_firmware folder [OK]
  74. Checking file size of planck_rev5_xyverz.hex
  75. * File size is fine - 18574/28672
  76. ```
  77. 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.
  78. dfu-programmer: no device present.
  79. Error: Bootloader not found. Trying again in 5s.
  80. Once it does this, you'll want to reset the controller. It should then show output similar to this:
  81. ```
  82. *** Attempting to flash, please don't remove device
  83. >>> dfu-programmer atmega32u4 erase --force
  84. Erasing flash... Success
  85. Checking memory from 0x0 to 0x6FFF... Empty.
  86. >>> dfu-programmer atmega32u4 flash /Users/skully/qmk_firmware/clueboard_66_hotswap_gen1_skully.hex
  87. Checking memory from 0x0 to 0x55FF... Empty.
  88. 0% 100% Programming 0x5600 bytes...
  89. [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] Success
  90. 0% 100% Reading 0x7000 bytes...
  91. [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] Success
  92. Validating... Success
  93. 0x5600 bytes written into 0x7000 bytes memory (76.79%).
  94. >>> dfu-programmer atmega32u4 reset
  95. ```
  96. ?> If you have any issues with this - such as `dfu-programmer: no device present` - please see the [Frequently Asked Build Questions](faq_build.md).
  97. #### DFU commands
  98. There are a number of DFU commands that you can use to flash firmware to a DFU device:
  99. * `: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.
  100. * `:dfu-ee` - This flashes an `eep` file instead of the normal hex. This is uncommon.
  101. * `: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._
  102. * `: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._
  103. ### Caterina
  104. 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:
  105. make <my_keyboard>:<my_keymap>:avrdude
  106. For example, if your keymap is named "xyverz" and you're building a keymap for a rev2 Lets Split, you'll use this command:
  107. make lets_split/rev2:xyverz:avrdude
  108. Once the firmware finishes compiling, it will output something like this:
  109. ```
  110. Linking: .build/lets_split_rev2_xyverz.elf [OK]
  111. Creating load file for flashing: .build/lets_split_rev2_xyverz.hex [OK]
  112. Checking file size of lets_split_rev2_xyverz.hex [OK]
  113. * File size is fine - 27938/28672
  114. Detecting USB port, reset your controller now..............
  115. ```
  116. 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:
  117. ```
  118. Detected controller on USB port at /dev/ttyS15
  119. Connecting to programmer: .
  120. Found programmer: Id = "CATERIN"; type = S
  121. Software Version = 1.0; No Hardware Version given.
  122. Programmer supports auto addr increment.
  123. Programmer supports buffered memory access with buffersize=128 bytes.
  124. Programmer supports the following devices:
  125. Device code: 0x44
  126. avrdude.exe: AVR device initialized and ready to accept instructions
  127. Reading | ################################################## | 100% 0.00s
  128. avrdude.exe: Device signature = 0x1e9587 (probably m32u4)
  129. avrdude.exe: NOTE: "flash" memory has been specified, an erase cycle will be performed
  130. To disable this feature, specify the -D option.
  131. avrdude.exe: erasing chip
  132. avrdude.exe: reading input file "./.build/lets_split_rev2_xyverz.hex"
  133. avrdude.exe: input file ./.build/lets_split_rev2_xyverz.hex auto detected as Intel Hex
  134. avrdude.exe: writing flash (27938 bytes):
  135. Writing | ################################################## | 100% 2.40s
  136. avrdude.exe: 27938 bytes of flash written
  137. avrdude.exe: verifying flash memory against ./.build/lets_split_rev2_xyverz.hex:
  138. avrdude.exe: load data flash data from input file ./.build/lets_split_rev2_xyverz.hex:
  139. avrdude.exe: input file ./.build/lets_split_rev2_xyverz.hex auto detected as Intel Hex
  140. avrdude.exe: input file ./.build/lets_split_rev2_xyverz.hex contains 27938 bytes
  141. avrdude.exe: reading on-chip flash data:
  142. Reading | ################################################## | 100% 0.43s
  143. avrdude.exe: verifying ...
  144. avrdude.exe: 27938 bytes of flash verified
  145. avrdude.exe: safemode: Fuses OK (E:CB, H:D8, L:FF)
  146. avrdude.exe done. Thank you.
  147. ```
  148. If you have any issues with this, you may need to this:
  149. sudo make <my_keyboard>:<my_keymap>:avrdude
  150. Additionally, if you want to flash multiple boards, use the following command:
  151. make <keyboard>:<keymap>:avrdude-loop
  152. 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.
  153. ### HalfKay
  154. 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:
  155. make <my_keyboard>:<my_keymap>:teensy
  156. 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:
  157. make ergodox_ez:xyverz:teensy
  158. Once the firmware finishes compiling, it will output something like this:
  159. ```
  160. Linking: .build/ergodox_ez_xyverz.elf [OK]
  161. Creating load file for flashing: .build/ergodox_ez_xyverz.hex [OK]
  162. Checking file size of ergodox_ez_xyverz.hex [OK]
  163. * File size is fine - 25584/32256
  164. Teensy Loader, Command Line, Version 2.1
  165. Read "./.build/ergodox_ez_xyverz.hex": 25584 bytes, 79.3% usage
  166. Waiting for Teensy device...
  167. (hint: press the reset button)
  168. ```
  169. At this point, reset your board. Once you've done that, you'll see output like this:
  170. ```
  171. Found HalfKay Bootloader
  172. Read "./.build/ergodox_ez_xyverz.hex": 28532 bytes, 88.5% usage
  173. Programming............................................................................................................................................................................
  174. ...................................................
  175. Booting
  176. ```
  177. ### BootloadHID
  178. 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:
  179. make <my_keyboard>:<my_keymap>:bootloaderHID
  180. For example, if your keymap is named "xyverz" and you're building a keymap for a jj40, you'll use this command:
  181. make jj40:xyverz:bootloaderHID
  182. Once the firmware finishes compiling, it will output something like this:
  183. ```
  184. Linking: .build/jj40_default.elf [OK]
  185. Creating load file for flashing: .build/jj40_default.hex [OK]
  186. Copying jj40_default.hex to qmk_firmware folder [OK]
  187. Checking file size of jj40_default.hex [OK]
  188. * The firmware size is fine - 21920/28672 (6752 bytes free)
  189. ```
  190. 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.
  191. ```
  192. Error opening HIDBoot device: The specified device was not found
  193. Trying again in 5s.
  194. ```
  195. Once it does this, you'll want to reset the controller. It should then show output similar to this:
  196. ```
  197. Page size = 128 (0x80)
  198. Device size = 32768 (0x8000); 30720 bytes remaining
  199. Uploading 22016 (0x5600) bytes starting at 0 (0x0)
  200. 0x05580 ... 0x05600
  201. ```
  202. ### STM32 (ARM)
  203. 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:
  204. make <my_keyboard>:<my_keymap>:dfu-util
  205. 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):
  206. make planck/rev6:xyverz:dfu-util
  207. Once the firmware finishes compiling, it will output something like this:
  208. ```
  209. Linking: .build/planck_rev6_xyverz.elf [OK]
  210. Creating binary load file for flashing: .build/planck_rev6_xyverz.bin [OK]
  211. Creating load file for flashing: .build/planck_rev6_xyverz.hex [OK]
  212. Size after:
  213. text data bss dec hex filename
  214. 0 41820 0 41820 a35c .build/planck_rev6_xyverz.hex
  215. Copying planck_rev6_xyverz.bin to qmk_firmware folder [OK]
  216. dfu-util 0.9
  217. Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
  218. Copyright 2010-2016 Tormod Volden and Stefan Schmidt
  219. This program is Free Software and has ABSOLUTELY NO WARRANTY
  220. Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
  221. Invalid DFU suffix signature
  222. A valid DFU suffix will be required in a future dfu-util release!!!
  223. Opening DFU capable USB device...
  224. ID 0483:df11
  225. Run-time device DFU version 011a
  226. Claiming USB DFU Interface...
  227. Setting Alternate Setting #0 ...
  228. Determining device status: state = dfuERROR, status = 10
  229. dfuERROR, clearing status
  230. Determining device status: state = dfuIDLE, status = 0
  231. dfuIDLE, continuing
  232. DFU mode device DFU version 011a
  233. Device returned transfer size 2048
  234. DfuSe interface name: "Internal Flash "
  235. Downloading to address = 0x08000000, size = 41824
  236. Download [=========================] 100% 41824 bytes
  237. Download done.
  238. File downloaded successfully
  239. Transitioning to dfuMANIFEST state
  240. ```
  241. #### STM32 Commands
  242. There are a number of DFU commands that you can use to flash firmware to a STM32 device:
  243. * `:dfu-util` - The default command for flashing to STM32 devices.
  244. * `: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.
  245. * Eg: `make <keyboard>:<keymap>:dfu-util TIME_DELAY=5`
  246. * `: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.
  247. * `: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.
  248. ## Test It Out!
  249. Congrats! Your custom firmware has been programmed to your keyboard!
  250. 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.