【Let's split】qmkの書き込み
レツプリ基板が全然届かなくて暇なのでArduino pro microにファームを焼いた
qmkとはQuantum Mechanical Keyboard Firmwareのことらしい
https://github.com/qmk/qmk_firmware/blob/master/readme.md##customizing-your-keymap
・環境
Ubuntu 16.04 LTS
avrdude (sudo apt-get install avrdude でインストールできるがいつのまにかインストールされていた)
git
・基本的なやりかた
1 gitディレクトリを作る
2 qmk_firmwareを取得する
参考 https://github.com/qmk/qmk_firmware/tree/master/keyboards/lets_split
git clone https://github.com/qmk/qmk_firmware.git
3 qmkのディレクトリに移動する
~/git/qmk_firmware$
4 makeする
make lets_split/rev2:default
このようなログが出る
[プロンプト]:~/git/qmk_firmware$ make lets_split/rev2:default QMK Firmware 0.5.173 WARNING: Some git sub-modules are out of date or modified, please consider runnning: make git-submodule You can ignore this warning if you are not compiling any ChibiOS keyboards, or if you have modified the ChibiOS libraries yourself. Making lets_split/rev2 with keymap default avr-gcc (GCC) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiling: keyboards/lets_split/matrix.c [OK] Compiling: keyboards/lets_split/i2c.c [OK] Compiling: keyboards/lets_split/split_util.c [OK] Compiling: keyboards/lets_split/serial.c [OK] Compiling: ./drivers/avr/ssd1306.c [OK] Compiling: keyboards/lets_split/lets_split.c [OK] Compiling: keyboards/lets_split/rev2/rev2.c [OK] Compiling: keyboards/lets_split/keymaps/default/keymap.c [OK] Compiling: quantum/quantum.c [OK] Compiling: quantum/keymap_common.c [OK] Compiling: quantum/keycode_config.c [OK] Compiling: quantum/process_keycode/process_leader.c [OK] Compiling: ./tmk_core/common/host.c [OK] Compiling: ./tmk_core/common/keyboard.c [OK] Compiling: ./tmk_core/common/action.c [OK] Compiling: ./tmk_core/common/action_tapping.c [OK] Compiling: ./tmk_core/common/action_macro.c [OK] Compiling: ./tmk_core/common/action_layer.c [OK] Compiling: ./tmk_core/common/action_util.c [OK] Compiling: ./tmk_core/common/print.c [OK] Compiling: ./tmk_core/common/debug.c [OK] Compiling: ./tmk_core/common/util.c [OK] Compiling: ./tmk_core/common/eeconfig.c [OK] Compiling: ./tmk_core/common/report.c [OK] Compiling: ./tmk_core/common/avr/suspend.c [OK] Compiling: ./tmk_core/common/avr/timer.c [OK] Compiling: ./tmk_core/common/avr/bootloader.c [OK] Assembling: ./tmk_core/common/avr/xprintf.S [OK] Compiling: ./tmk_core/common/magic.c [OK] Compiling: ./tmk_core/common/mousekey.c [OK] Compiling: ./tmk_core/common/command.c [OK] Compiling: ./tmk_core/protocol/lufa/lufa.c [OK] Compiling: ./tmk_core/protocol/lufa/descriptor.c [OK] Compiling: ./tmk_core/protocol/lufa/outputselect.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Class/Common/HIDParser.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/ConfigDescriptors.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/DeviceStandardReq.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/Events.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/HostStandardReq.c [OK] Compiling: lib/lufa/LUFA/Drivers/USB/Core/USBTask.c [OK] Linking: .build/lets_split_rev2_default.elf [OK] Creating load file for Flash: .build/lets_split_rev2_default.hex [OK] Size after: text data bss dec hex filename 0 18780 0 18780 495c lets_split_rev2_default.hex
5 qmk_firmwareディレクトリにhexファイルができていることを確認する
lets_split_rev2_default.hex
6 Arduino pro microをUSBで接続して次のコマンドを実行する
USB端子壊してしまう前にこういう3個セットなど購入して予備を用意しておくべき
git/qmk_firmware$ make lets_split:default:avrdude
これは公式の説明と異なるので注意※
数日後に公式が修正されていた
するとこのようになる
[プロンプト]:~/git/qmk_firmware$ make lets_split:default:avrdude QMK Firmware 0.5.173 WARNING: Some git sub-modules are out of date or modified, please consider runnning: make git-submodule You can ignore this warning if you are not compiling any ChibiOS keyboards, or if you have modified the ChibiOS libraries yourself. Making lets_split/rev2 with keymap default and target avrdude avr-gcc (GCC) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Size before: text data bss dec hex filename 0 18780 0 18780 495c lets_split_rev2_default.hex Compiling: ./tmk_core/common/command.c [OK] Linking: .build/lets_split_rev2_default.elf [OK] Creating load file for Flash: .build/lets_split_rev2_default.hex [OK] Detecting USB port, reset your controller now
と出てリセットの待機状態になる
7 この状態でArduino pro microの左上の並んだ2つの穴のGNDとRSTをショートさせる
スイッチを使うならリセットは1回押すだけで良い
8 処理が進み、「avrdude done. Thank you.」と出たら完了
[プロンプト]:~/git/qmk_firmware$ make lets_split:default:avrdude QMK Firmware 0.5.173 WARNING: Some git sub-modules are out of date or modified, please consider runnning: make git-submodule You can ignore this warning if you are not compiling any ChibiOS keyboards, or if you have modified the ChibiOS libraries yourself. Making lets_split/rev2 with keymap default and target avrdude avr-gcc (GCC) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Size before: text data bss dec hex filename 0 18780 0 18780 495c lets_split_rev2_default.hex Compiling: ./tmk_core/common/command.c [OK] Linking: .build/lets_split_rev2_default.elf [OK] Creating load file for Flash: .build/lets_split_rev2_default.hex [OK] Detecting USB port, reset your controller now..... Detected controller on USB port at /dev/ttyACM0 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: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.00s avrdude: Device signature = 0x1e9587 (probably m32u4) avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed To disable this feature, specify the -D option. avrdude: erasing chip avrdude: reading input file "./.build/lets_split_rev2_default.hex" avrdude: input file ./.build/lets_split_rev2_default.hex auto detected as Intel Hex avrdude: writing flash (18780 bytes): Writing | ################################################## | 100% 1.40s avrdude: 18780 bytes of flash written avrdude: verifying flash memory against ./.build/lets_split_rev2_default.hex: avrdude: load data flash data from input file ./.build/lets_split_rev2_default.hex: avrdude: input file ./.build/lets_split_rev2_default.hex auto detected as Intel Hex avrdude: input file ./.build/lets_split_rev2_default.hex contains 18780 bytes avrdude: reading on-chip flash data: Reading | ################################################## | 100% 0.14s avrdude: verifying ... avrdude: 18780 bytes of flash verified avrdude: safemode: Fuses OK (E:CB, H:D8, L:FF) avrdude done. Thank you.
・自分のキーマップをつくる
1 新しいキーマップのファイルを作る
/git/qmk_firmware/keyboards/lets_split/keymaps
にあるdefaultディレクトリーをコピーして適当な名前をつける
例:mykeymap
2 keymap.cのキーマップを好きなように編集する
3 buildする
$ make lets_split/rev2:mykeymap
4 git/qmk_firmwareディレクトリにhexファイルができていることを確認する
lets_split_rev2_original1.hex
5 Arduino pro microをUSBで接続して次のコマンドを実行する
git/qmk_firmware$ make lets_split:mykeymap:avrdude
6 リセット待ちになったらリセットする
リセットはGNDとRSTをショートする
7 処理が進み、「avrdude done. Thank you.」と出たら完了
・失敗した時
自分は机の上にあったクリップを使ってショートさせたら、ショートする時間が長すぎてエラーavrdude: ser_open(): can't open deviceが出た。
Detecting USB port, reset your controller now................................. Detected controller on USB port at /dev/ttyACM0 avrdude: ser_open(): can't open device "/dev/ttyACM0": No such file or directory avrdude done. Thank you. tmk_core/avr.mk:172: recipe for target 'avrdude' failed make[1]: *** [avrdude] Error 1 Makefile:528: recipe for target 'lets_split:default:avrdude' failed Make finished with errors make: *** [lets_split:default:avrdude] Error 1
はじめはショートさせる時間が長すぎることが問題だとわからず、調べていたら権限追加(https://stackoverflow.com/questions/40951728/avrdude-ser-open-cant-open-device-dev-ttyacm0-device-or-resource-busy)が足りないと思いやってしまったが、まだ同じエラーが出てショートさせる時間だと気づいた。
$ sudo adduser <username> dialout $ sudo chmod a+rw /dev/ttyACM0
※注意
公式のFlashのページ(https://github.com/nicinabox/lets-split-guide/blob/master/flashing.md)を見ていると
make lets_split-rev2-YOUR_KEYMAP_NAME-avrdude
とあり、-avrdudeなんてファイルできてないしなんでこうなるのかわからないまま実行したら、当然エラーになった。
make: *** No rule to make target 'rev2-default'. Stop.
全然わからず調べていたらこのブログ(http://hanocha.hateblo.jp/entry/2017/11/23/154320)に
3. 以下のコマンドを実行 # make lets_split:default:avrdude
とあり、ようやくわかった。