fbpx

燒錄 qmk_firmware 到你的鍵盤

所需軟體

安裝 git

  • Debian / Ubuntu / Devuan: apt-get install git
  • Fedora / Red Hat / CentOS: yum install git
  • Arch: pacman -S git

Windows 環境請安裝:http://www.msys2.org/ ,開啟 MSYS2 MinGW 64bit 後,執行安裝 git。

# pacman -S git

Linux 環境只需要先安裝 git 即可,將程式庫複製下來之後執行安裝命令稿即可,需要 root 權限。

qmk_firmware 韌體

下載 qmk_firmware

下載 qmk_firmware:

# git clone --recurse-submodules https://github.com/qmk/qmk_firmware.git

安裝 qmk_firmware

執行安裝,過程中一直按 Y 就對了,Linux 系統需要 root 權限。

# cd qmk_firmware
# ./util/qmk_install.sh

編譯測試

都先不要修改,先測試一下能不能編譯:

# make ergodash:default

.....
Copying ergodash_rev1_default.hex to qmk_firmware folder    
  [OK]
Checking file size of ergodash_rev1_default.hex             
  [OK]
 * The firmware size is fine - 18124/28672 (10548 bytes free)

最後在 qmk_firmware 目錄底下就可以看到 ergodash_rev1_default.hex 這個編譯好的檔案。

自訂鍵盤設定與配置

完成編譯測試之後,就可以開始自訂設定與鍵盤配置,qmk_firmware 內有工具可以協助你建立自己的設定,在 util 資料夾內有一個 new_keymaps.sh 的工具,假如我要的鍵盤是 ergodash,然後我想自訂一組設定,可以幫設定檔取名,假設叫 ergotaiwan:

# cd util/
# ./new_keymap.sh ergodash/rev1 ergotaiwan
ergotaiwan keymap directory created in: qmk_firmware/keyboards/ergodash/rev1/keymaps/

Compile a firmware file with your new keymap by typing: 
   make ergodash/rev1:ergotaiwan
from the qmk_firmware directory

就可以在 qmk_firmware/keyboards/ergodash/rev1/keymaps 內看到一個叫 ergotaiwan 的目錄,裡面有 config.h、keymaps.c 與 rules.mk。你就可以依照自己的需求去修改這三個檔案。

編譯的時候指令要改:

# make ergodash/rev1:ergotaiwan

...
Copying ergodash_rev1_ergotaiwan.hex to qmk_firmware folder
  [OK]
Checking file size of ergodash_rev1_ergotaiwan.hex
  [OK]
 * The firmware size is fine - 24426/28672 (4246 bytes free)

就可以在 qmk_firmware/ 內看到 ergodash_rev1_ergotaiwan.hex。

燒錄韌體到鍵盤

接下來請把鍵盤與 USB 連接。輸入:

# make ergodash/rev1:ergotaiwan:avrdude

就會開始編譯,接者你會看到如下類色的提示時,就按下鍵盤上的重置按鈕

Linking: .build/ergodash_rev1_ergotaiwan.hex                                                            [OK]
Creating load file for flashing: .build/ergodash_rev1_ergotaiwan.hex                                    [OK]
Checking file size of ergodash_rev1_ergotaiwan.hex                                                      [OK]
 * File size is fine - 27938/28672
Detecting USB port, reset your controller now..............

按下重置後,會自動偵測到可以寫入,就會開始燒錄程式碼:

Detected controller on USB port at /dev/ttyS15

Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude.exe: Device signature = 0x1e9587 (probably m32u4)
avrdude.exe: NOTE: "flash" memory has been specified, an erase cycle will be performed
             To disable this feature, specify the -D option.
avrdude.exe: erasing chip
avrdude.exe: reading input file "./.build/ergodash_rev1_jack.hex"
avrdude.exe: input file ./.build/ergodash_rev1_ergotaiwan.hex auto detected as Intel Hex
avrdude.exe: writing flash (27938 bytes):

Writing | ################################################## | 100% 2.40s

avrdude.exe: 27938 bytes of flash written
avrdude.exe: verifying flash memory against ./.build/ergodash_rev1_ergotaiwan.hex:
avrdude.exe: load data flash data from input file ./.build/ergodash_rev1_ergotaiwan.hex:
avrdude.exe: input file ./.build/ergodash_rev1_ergotaiwan.hex auto detected as Intel Hex
avrdude.exe: input file ./.build/ergodash_rev1_ergotaiwan.hex contains 27938 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 0.43s

avrdude.exe: verifying ...
avrdude.exe: 27938 bytes of flash verified

avrdude.exe: safemode: Fuses OK (E:CB, H:D8, L:FF)

avrdude.exe done.  Thank you.

完成!把鍵盤重新連結即可。

參考資料:https://docs.qmk.fm/#/newbs_flashing

Show CommentsClose Comments

Leave a comment