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.

307 lines
13 KiB

  1. # 刷新你的键盘
  2. 现在您已经构建了一个自定义固件文件,那么您就需要刷新键盘了。
  3. ## 用QMK工具箱刷新键盘
  4. 刷新键盘的最简单方法是使用[QMK 工具箱](https://github.com/qmk/qmk_toolbox/releases).
  5. 但是,QMK工具箱目前仅适用于Windows和MacOS。如果您使用的是Linux(或者只是希望从命令行刷新固件),则必须使用 [方法概述](newbs_flashing.md#flash-your-keyboard-from-the-command-line).
  6. ### 将文件加载到QMK工具箱中
  7. 首先打开QMK工具箱应用程序。您将要在访达或资源管理器中找到固件文件。您的键盘固件可能是两种格式之一`.hex`或`.bin`。qmk会尝试将键盘的相应文件复制到“qmk_firmware”根目录中。
  8. ?> 如果您在Windows或MacOS上,可以使用以下命令轻松地在资源管理器或访达中打开当前固件文件夹。
  9. ?> Windows:
  10. start .
  11. ?> macOS:
  12. open .
  13. 固件文件始终遵循此命名格式:
  14. <keyboard_name>_<keymap_name>.{bin,hex}
  15. 例如,使用 `default` 布局的 `plank/rev5` 将使用以下名字:
  16. planck_rev5_default.hex
  17. 找到固件文件后,将其拖到QMK工具箱中的“Local file”框中,或单击“Open”并导航到固件文件的存储位置。
  18. ### 将键盘置于DFU(Bootloader)模式
  19. 要刷新自定义固件,您必须将键盘置于特殊的刷新模式。在此模式下,您将无法键入或使用键盘。在写入固件时,不要拔下键盘插头或以其他方式中断刷新过程,这一点非常重要。
  20. 不同的键盘有不同的方式进入这种特殊模式。如果您的键盘当前运行的是QMK或TMK,而您没有得到特定的指示,请按顺序尝试以下操作:
  21. * 按住两个shift键并按 `Pause`
  22. * 按住两个shift键并按 `B`
  23. * 拔下键盘插头, 同时按住空格键和 `B` , 插上键盘然后等一会再放开按键
  24. * 按下PCB底部的 `RESET` 物理键
  25. * 找到PCB上标记有 `BOOT0``RESET`的金属点, 在插入PCB的同时短接它们
  26. 成功后,您将在QMK工具箱中看到类似以下内容的消息:
  27. ```
  28. *** Clueboard - Clueboard 66% HotSwap disconnected -- 0xC1ED:0x2390
  29. *** DFU device connected
  30. ```
  31. ### 刷新你的键盘
  32. 单击QMK工具箱中的 `Flash` 按钮。您将看到类似以下内容的输出:
  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. ## 使用命令行刷新键盘
  53. 首先,您需要知道您的键盘使用的是哪个bootloader。通常是以下四个常见的bootloader。Pro-Micro 和 clones 使用 CATERINA, Teensy 使用 Halfkay, OLKB 键盘使用 QMK-DFU, 其他的atmega32u4芯片使用DFU。
  54. 您可以在以下文章中了解更多关于bootloader[刷新指令和Bootloader信息](flashing.md)。
  55. 如果您知道正在使用的bootloader是哪种,那么在编译固件时,可以向“make”命令里添加一些额外参数,以自动执行刷新过程。
  56. ### DFU
  57. 对于DFU引导加载程序,当您准备好编译和刷新固件时,打开终端窗口并运行构建命令:
  58. make <my_keyboard>:<my_keymap>:dfu
  59. 例如,如果您的布局名为“xyverz”,并且您正在为rev5 planck构建一个布局,那么您可以使用此命令:
  60. make planck/rev5:xyverz:dfu
  61. 编译完成后,应输出以下内容:
  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. 到了这个时候, 构建脚本将每隔5秒查找一次DFU。它将重复以下操作,直到找到设备或将其取消。
  70. dfu-programmer: no device present.
  71. Error: Bootloader not found. Trying again in 5s.
  72. 一旦出现以上回显,您将需要重置控制器。然后,它应该显示与以下类似的输出:
  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. 如果您对此有任何问题,您可能需要这样做:
  89. sudo make <my_keyboard>:<my_keymap>:dfu
  90. #### DFU命令
  91. 有许多DFU命令可用于将固件下载到DFU设备:
  92. * `:dfu` - 这是正常选项,等待DFU设备可用,然后刷新固件。这将每隔5秒检查一次,以查看是否出现了DFU设备。
  93. * `:dfu-ee` - 这将刷新一个`eep`文件,而不是普通的十六进制文件。这很不常见。
  94. * `:dfu-split-left` - 这将刷新正常固件,就像默认选项 (`:dfu`)一样. 但是,这也会刷新“左侧”EEPROM文件,用于分割键盘。 _这是基于Elite C的键盘的推荐选择。_
  95. * `:dfu-split-right` - 这将刷新正常固件,就像默认选项(`:dfu`). 但是,这也会刷新“右侧”EEPROM文件,用于分割键盘。 _这是基于Elite C的键盘的推荐选择。_
  96. ### Caterina
  97. 对于Arduino板以及其克隆版来说(比如SparkFun和ProMicro), 准备好编译和刷新固件后,打开终端窗口并运行构建命令:
  98. make <my_keyboard>:<my_keymap>:avrdude
  99. 比如, 你的布局叫"xyverz"你要创建一个rev2 Lets Split的布局,你要用以下命令:
  100. make lets_split/rev2:xyverz:avrdude
  101. 固件完成编译后,它将输出类似以下的内容:
  102. ```
  103. Linking: .build/lets_split_rev2_xyverz.elf [OK]
  104. Creating load file for flashing: .build/lets_split_rev2_xyverz.hex [OK]
  105. Checking file size of lets_split_rev2_xyverz.hex [OK]
  106. * File size is fine - 27938/28672
  107. Detecting USB port, reset your controller now..............
  108. ```
  109. 此时,复位,然后脚本将检测bootloader,然后刷新固件。输出应该像这样:
  110. ```
  111. Detected controller on USB port at /dev/ttyS15
  112. Connecting to programmer: .
  113. Found programmer: Id = "CATERIN"; type = S
  114. Software Version = 1.0; No Hardware Version given.
  115. Programmer supports auto addr increment.
  116. Programmer supports buffered memory access with buffersize=128 bytes.
  117. Programmer supports the following devices:
  118. Device code: 0x44
  119. avrdude.exe: AVR device initialized and ready to accept instructions
  120. Reading | ################################################## | 100% 0.00s
  121. avrdude.exe: Device signature = 0x1e9587 (probably m32u4)
  122. avrdude.exe: NOTE: "flash" memory has been specified, an erase cycle will be performed
  123. To disable this feature, specify the -D option.
  124. avrdude.exe: erasing chip
  125. avrdude.exe: reading input file "./.build/lets_split_rev2_xyverz.hex"
  126. avrdude.exe: input file ./.build/lets_split_rev2_xyverz.hex auto detected as Intel Hex
  127. avrdude.exe: writing flash (27938 bytes):
  128. Writing | ################################################## | 100% 2.40s
  129. avrdude.exe: 27938 bytes of flash written
  130. avrdude.exe: verifying flash memory against ./.build/lets_split_rev2_xyverz.hex:
  131. avrdude.exe: load data flash data from input file ./.build/lets_split_rev2_xyverz.hex:
  132. avrdude.exe: input file ./.build/lets_split_rev2_xyverz.hex auto detected as Intel Hex
  133. avrdude.exe: input file ./.build/lets_split_rev2_xyverz.hex contains 27938 bytes
  134. avrdude.exe: reading on-chip flash data:
  135. Reading | ################################################## | 100% 0.43s
  136. avrdude.exe: verifying ...
  137. avrdude.exe: 27938 bytes of flash verified
  138. avrdude.exe: safemode: Fuses OK (E:CB, H:D8, L:FF)
  139. avrdude.exe done. Thank you.
  140. ```
  141. 如果您对此有任何问题,您可能需要这样做:
  142. sudo make <my_keyboard>:<my_keymap>:avrdude
  143. 此外,如果要刷新多个板,请使用以下命令:
  144. make <keyboard>:<keymap>:avrdude-loop
  145. 当你完成了刷新后,你需要按下ctrl+c或者其他正确的按键来让你的操作系统终止循环。
  146. ## HalfKay
  147. 对于PJRC设备(Teensy),当您准备好编译和刷新固件时,打开终端窗口并运行构建命令:
  148. make <my_keyboard>:<my_keymap>:teensy
  149. 比如, 如果你的布局叫做"xyverz"你想创建Ergodox or Ergodox EZ的布局,你要使用以下命令:
  150. make erdogox_ez:xyverz:teensy
  151. 固件完成编译后,它将输出如下内容:
  152. ```
  153. Linking: .build/ergodox_ez_xyverz.elf [OK]
  154. Creating load file for flashing: .build/ergodox_ez_xyverz.hex [OK]
  155. Checking file size of ergodox_ez_xyverz.hex [OK]
  156. * File size is fine - 25584/32256
  157. Teensy Loader, Command Line, Version 2.1
  158. Read "./.build/ergodox_ez_xyverz.hex": 25584 bytes, 79.3% usage
  159. Waiting for Teensy device...
  160. (hint: press the reset button)
  161. ```
  162. 此时,复位键盘。完成后,您将看到如下输出:
  163. ```
  164. Found HalfKay Bootloader
  165. Read "./.build/ergodox_ez_xyverz.hex": 28532 bytes, 88.5% usage
  166. Programming............................................................................................................................................................................
  167. ...................................................
  168. Booting
  169. ```
  170. ## STM32 (ARM)
  171. 对于大多数ARM板(包括Proton C、Planck Rev 6和Preonic Rev 3),当您准备好编译和刷新固件时,打开终端窗口并运行构建命令:
  172. make <my_keyboard>:<my_keymap>:dfu-util
  173. 例如,如果您的keymap被命名为“xyverz”,并且您正在为Planck Revision 6键盘构建一个布局,那么您需要使用以下命令,然后将键盘重新启动到bootloader(在完成编译之前):
  174. make planck/rev6:xyverz:dfu-util
  175. 固件完成编译后,它将输出如下内容:
  176. ```
  177. Linking: .build/planck_rev6_xyverz.elf [OK]
  178. Creating binary load file for flashing: .build/planck_rev6_xyverz.bin [OK]
  179. Creating load file for flashing: .build/planck_rev6_xyverz.hex [OK]
  180. Size after:
  181. text data bss dec hex filename
  182. 0 41820 0 41820 a35c .build/planck_rev6_xyverz.hex
  183. Copying planck_rev6_xyverz.bin to qmk_firmware folder [OK]
  184. dfu-util 0.9
  185. Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
  186. Copyright 2010-2016 Tormod Volden and Stefan Schmidt
  187. This program is Free Software and has ABSOLUTELY NO WARRANTY
  188. Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
  189. Invalid DFU suffix signature
  190. A valid DFU suffix will be required in a future dfu-util release!!!
  191. Opening DFU capable USB device...
  192. ID 0483:df11
  193. Run-time device DFU version 011a
  194. Claiming USB DFU Interface...
  195. Setting Alternate Setting #0 ...
  196. Determining device status: state = dfuERROR, status = 10
  197. dfuERROR, clearing status
  198. Determining device status: state = dfuIDLE, status = 0
  199. dfuIDLE, continuing
  200. DFU mode device DFU version 011a
  201. Device returned transfer size 2048
  202. DfuSe interface name: "Internal Flash "
  203. Downloading to address = 0x08000000, size = 41824
  204. Download [=========================] 100% 41824 bytes
  205. Download done.
  206. File downloaded successfully
  207. Transitioning to dfuMANIFEST state
  208. ```
  209. ## 试一试吧!
  210. 恭喜您! 您的自定义固件已经刷写到您的键盘
  211. 试一试,确保一切按你想的方式进行。我们写了[测试和调试](newbs_testing_debugging.md)来完善新手引导。 因此,请前往那里了解如何排除自定义功能的故障。