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.

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