・2021/08/23
QMK firmwareの開発環境を ラズパイや Windows WSLにセットアップする方法
(ラズパイや Windows WSL環境でカスタマイズ キーボードのファームウェア QMK firmwareの開発環境を構築)
Tags: [電子工作], [QMK]
● 【2023年】QMK firmwareの開発環境を Windows WSLにセットアップする方法
・2023/08/25
【2023年】QMK firmwareの開発環境を Windows WSLにセットアップする方法
Windows WSL環境でカスタマイズ キーボードのファームウェア QMK firmwareの開発環境を構築する方法
● 社畜のキーボード「新入社員の同期」を購入してみた!!
・2021/08/11
社畜のキーボード「新入社員の同期」を購入してみた!! VIA、QMK、Remapでのカスタマイズに対応
キー内容が Remap等でカスタマイズ可能な社畜のキーボード「新入社員の同期」を 3500円で購入
● BUFFALOの USB テンキーを Pro Microと QMKを使って VIAカスタマイズ キーボードに改造する方法
・2022/01/09
BUFFALOの USB テンキーを Pro Microと QMKを使って VIAカスタマイズ キーボードに改造する方法
BUFFALO USB 10-Key keyboard BSTK100 modification by Pro Micro and QMK firmware VIA
● QMK firmwareの開発環境を ラズパイや Windows WSLにセットアップする方法
ラズパイや Windows WSL環境でカスタマイズ キーボードのファームウェア QMK firmwareの開発環境を構築。
Setting Up Your QMK Environment
QMK 環境の構築
●ラズパイ
qmk 1.0.0 + Python 3.7.3
sudo apt update
sudo apt install -y git
sudo apt install -y python3 python3-pip
python3 -V
# Python 3.7.3
cd
# git clone https://github.com/qmk/qmk_firmware.git --depth 1
git clone https://github.com/FREEWING-JP/qmk_firmware -b bstk100 --depth 1
cd qmk_firmware
sudo ./util/qmk_install.sh
python3 -m pip install qmk
# WARNING: The script qmk is installed in '/home/user/.local/bin' which is not on PATH.
PATH="$HOME/.local/bin:$PATH"
qmk -V
# 1.0.0
make git-submodule
make handwired/bstk100:default
# Raspberry Pi Build QMK firmware
ls -l hand*.hex
# -rw-r--r-- 1 pi pi 46499 Sep 4 15:18 handwired_bstk100_default.hex
● WSL2 Debian
qmk 1.0.0 + Python 3.7
sudo apt update
sudo apt install -y git
# Uninstall Python 3.5
sudo apt remove -y python3 python3-pip
# Install Python 3.7
cd
git clone https://github.com/FREEWING-JP/Jetson_Convenience_Script --depth 1
cd
bash ./Jetson_Convenience_Script/Python/build_Python_3710.sh
python3 -V
# Python 3.7.10
cd
# git clone https://github.com/qmk/qmk_firmware.git --depth 1
git clone https://github.com/FREEWING-JP/qmk_firmware -b bstk100 --depth 1
cd qmk_firmware
# E: Unable to locate package teensy-loader-cli
# remove teensy-loader-cli
# https://www.pjrc.com/teensy/loader_cli.html
sudo apt-get -yq install \
build-essential clang-format diffutils gcc git unzip wget zip \
python3-pip binutils-avr gcc-avr avr-libc binutils-arm-none-eabi \
gcc-arm-none-eabi libnewlib-arm-none-eabi avrdude dfu-programmer \
dfu-util libhidapi-hidraw0 libusb-dev
sudo ./util/qmk_install.sh
# gcc -O2 -Wall `libusb-config --cflags` -o bootloadHID main.o usbcalls.o `libusb-config --libs`
python3 -m pip install qmk
# WARNING: The script qmk is installed in '/home/user/.local/bin' which is not on PATH.
PATH="$HOME/.local/bin:$PATH"
qmk -V
# 1.0.0
make git-submodule
make handwired/bstk100:default
# WSL2 Debian Build QMK firmware
ls -l hand*.hex
# -rw-r--r-- 1 user user 46082 Sep 4 23:30 handwired_bstk100_default.hex
qmk 0.3.5 + Python 3.5
sudo apt update
sudo apt install -y git
# Install Python 3.5
sudo apt install -y python3 python3-pip
python3 -V
# Python 3.5.3
Unable
● WSL2 Ubuntu
qmk 1.0.0 + Python 3.8.2
sudo apt update
sudo apt install -y git
sudo apt install -y python3 python3-pip
python3 -V
# 2021/08 Python 3.8.2
# 2021/10 Python 3.8.10
cd
# git clone https://github.com/qmk/qmk_firmware.git --depth 1
git clone https://github.com/FREEWING-JP/qmk_firmware -b bstk100 --depth 1
cd qmk_firmware
sudo ./util/qmk_install.sh
# gcc -O2 -Wall `libusb-config --cflags` -o bootloadHID main.o usbcalls.o `libusb-config --libs`
python3 -m pip install qmk
# WARNING: The script qmk is installed in '/home/user/.local/bin' which is not on PATH.
PATH="$HOME/.local/bin:$PATH"
qmk -V
# 1.0.0
make git-submodule
make handwired/bstk100:default
# WSL2 Ubuntu Build QMK firmware
ls -l hand*.hex
# -rw-r--r-- 1 user user 46499 Sep 4 23:26 handwired_bstk100_default.hex
●エラーと解決方法
/qmk_firmware/util/install/linux_shared.sh: line 8: make: command not found
sudo apt install -y make
/bin/sh: 1: gcc: not found
sudo apt-get install -y gcc
/bin/sh: 1: libusb-config: not found
sudo apt-get install -y libusb-dev
Warning: The bin/qmk script is being deprecated. Please install the QMK CLI: python3 -m pip install qmk
sudo python3 -m pip install qmk
qmk --version
/usr/bin/env: ‘python3’: No such file or directory
ERROR: Cannot run "qmk hello"!
sudo apt install -y python3
/usr/bin/python3: No module named pip
sudo apt install -y python3-pip
$ sudo apt install -y git python3-pip
E: Unable to locate package git
E: Unable to locate package python3-pip
sudo apt update
$ python3 -m pip install qmk
$ qmk
-bash: qmk: command not found
$ ls -l ./.local/bin/
-rwxr-xr-x 1 user user 3459 Sep 4 13:13 activate-global-python-argcomplete
-rwxr-xr-x 1 user user 234 Sep 4 13:13 easy_install
-rwxr-xr-x 1 user user 234 Sep 4 13:13 easy_install-3.5
-rwxr-xr-x 1 user user 37 Sep 4 13:13 hjson
-rwxr-xr-x 1 user user 24 Sep 4 13:13 hjson.cmd
-rwxr-xr-x 1 user user 217 Sep 4 13:13 jsonschema
-rwxr-xr-x 1 user user 1330 Sep 4 13:13 milc-color
-rwxr-xr-x 1 user user 219 Sep 4 13:13 pygmentize
-rwxr-xr-x 1 user user 2555 Sep 4 13:13 python-argcomplete-check-easy-install-script
-rwxr-xr-x 1 user user 383 Sep 4 13:13 python-argcomplete-tcsh
-rwxr-xr-x 1 user user 221 Sep 4 13:13 qmk
-rwxr-xr-x 1 user user 1917 Sep 4 13:13 register-python-argcomplete
WARNING: The script pygmentize is installed in '/home/user/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script qmk is installed in '/home/user/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
PATH="$HOME/.local/bin:$PATH"
echo 'PATH="$HOME/.local/bin:$PATH"' >> $HOME/.bashrc
source $HOME/.bashrc
$ qmk --version
Traceback (most recent call last):
File "/home/user/.local/bin/qmk", line 7, in <module>
from qmk_cli.script_qmk import main
File "/home/user/.local/lib/python3.5/site-packages/qmk_cli/script_qmk.py", line 13, in <module>
import milc
File "/home/user/.local/lib/python3.5/site-packages/milc/__init__.py", line 40
warnings.warn(f'Using {name} is deprecated and will not be supported in the future, please use set_metadata() instead.', stacklevel=2)
Update Python 3.5 to Pythom 3.6 or above
$ make handwired/bstk100:default
SyntaxError: invalid syntax
ERROR: Cannot run "qmk hello"!
Please run qmk setup to install all the dependencies QMK requires.
Makefile:518: recipe for target 'bstk100:default' failed
make: *** [bstk100:default] Error 1
sudo ./util/qmk_install.sh
gcc -O2 -Wall `libusb-config --cflags` -c main.c -o main.o
/bin/sh: 1: libusb-config: not found
gcc -O2 -Wall `libusb-config --cflags` -c usbcalls.c -o usbcalls.o
/bin/sh: 1: libusb-config: not found
In file included from usbcalls.c:19:0:
usb-libusb.c:28:17: fatal error: usb.h: No such file or directory
#include <usb.h>
^
compilation terminated.
Makefile:46: recipe for target 'usbcalls.o' failed
make: *** [usbcalls.o] Error 1
sudo apt-get install -y libusb-dev
$ make handwired/bstk100:default
Traceback (most recent call last):
File "bin/qmk", line 15, in <module>
import milc # noqa
ModuleNotFoundError: No module named 'milc'
ERROR: Cannot run "qmk hello"!
Please run qmk setup to install all the dependencies QMK requires.
make: *** [Makefile:521: bstk100:default] Error 1
python3 -m pip install milc
$ make handwired/bstk100:default
ModuleNotFoundError: No module named 'usb'
ERROR: Cannot run "qmk hello"!
python3 -m pip install pyusb
$ qmk --version
Could not find module hid!
Could not find module hjson!
Could not find module jsonschema!
Could not find module pygments!
Could not find module qmk-dotty-dict!
Would you like to install the required Python modules? [y/n] n
python3 -m pip install -r requirements.txt
ImportError: Unable to load any of the following libraries:libhidapi-hidraw.so libhidapi-hidraw.so.0 libhidapi-libusb.so libhidapi-libusb.so.0 libhidapi-iohidmanager.so libhidapi-iohidmanager.so.0 libhidapi.dylib hidapi.dll libhidapi-0.dll
sudo apt-get install libhidapi-hidraw0
$ make handwired/bstk100:default
/bin/sh: 1: avr-gcc: not found
sh: 1: avr-gcc: not found
sh: 1: avr-gcc: not found
sudo apt-get -yq install \
build-essential clang-format diffutils gcc git unzip wget zip \
python3-pip binutils-avr gcc-avr avr-libc binutils-arm-none-eabi \
gcc-arm-none-eabi libnewlib-arm-none-eabi avrdude dfu-programmer \
dfu-util libhidapi-hidraw0 libusb-dev
# E: Unable to locate package teensy-loader-cli
# remove teensy-loader-cli
sudo apt-get -yq install \
build-essential clang-format diffutils gcc git unzip wget zip \
python3-pip binutils-avr gcc-avr avr-libc binutils-arm-none-eabi \
gcc-arm-none-eabi libnewlib-arm-none-eabi avrdude dfu-programmer \
dfu-util libhidapi-hidraw0 libusb-dev
Using legacy setup.py install for termcolor, since package 'wheel' is not installed.
ERROR: qmk 1.0.0 requires hid, which is not installed.
ERROR: qmk 1.0.0 requires hjson, which is not installed.
ERROR: qmk 1.0.0 requires jsonschema>=3, which is not installed.
ERROR: qmk 1.0.0 requires pygments, which is not installed.
ERROR: qmk 1.0.0 requires pyusb, which is not installed.
ERROR: qmk 1.0.0 requires qmk-dotty-dict, which is not installed.
Please run `/usr/local/bin/python3 -m pip install -r /home/user/qmk_firmware/requirements.txt` to install required python dependencies.
python3 -m pip install -r ./requirements.txt
Warning: The bin/qmk script is being deprecated. Please install the QMK CLI: python3 -m pip install qmk
tmk_core/protocol/lufa.mk:14: lib/lufa/LUFA/makefile: No such file or directory
make[1]: *** No rule to make target 'lib/lufa/LUFA/makefile'. Stop.
Make finished with errors
make: *** [Makefile:539: bstk100:default] Error 1
make git-submodule
ERROR: Cannot run "qmk hello"!
sudo python3 -m pip install --user qmk
$ make handwired/bstk100:default
WARNING: Some git submodules are out of date or modified.
Please consider running make git-submodule.
make git-submodule
● QMK firmwareで新規にキーボード(テンプレ)を作成する方法
cd
cd qmk_firmware
./util/new_keyboard.sh
Keyboard Name: hogehoge_keyboard
Keyboard Type [avr]:
Your Name: FREE WING
ls -l ./keyboards/hogehoge_keyboard
-rw-r--r-- 1 user user 4862 Sep 4 23:32 config.h
-rw-r--r-- 1 user user 713 Sep 4 23:32 hogehoge_keyboard.c
-rw-r--r-- 1 user user 1141 Sep 4 23:32 hogehoge_keyboard.h
-rw-r--r-- 1 user user 488 Sep 4 23:32 info.json
drwxr-xr-x 3 user user 4096 Sep 4 23:32 keymaps
-rw-r--r-- 1 user user 1146 Sep 4 23:32 readme.md
-rw-r--r-- 1 user user 918 Sep 4 23:32 rules.mk
●ラズパイで hexファイルの書き込みを avrdudeで行なう方法
AVRDUDE - AVR Downloader/UploaDEr
avrdude 最終更新: 2020-06-21 18:09
avrdude
sudo apt install -y avrdude
make handwired/bstk100:default
ls -l hand*.hex
# -rw-r--r-- 1 pi pi 46499 Sep 4 15:18 handwired_bstk100_default.hex
make handwired/bstk100:default:avrdude
$ avrdude -h
avrdude: invalid option -- 'h'
Usage: avrdude [options]
Options:
-p <partno> Required. Specify AVR device.
-b <baudrate> Override RS-232 baud rate.
-B <bitclock> Specify JTAG/STK500v2 bit clock period (us).
-C <config-file> Specify location of configuration file.
-c <programmer> Specify programmer type.
-D Disable auto erase for flash memory
-i <delay> ISP Clock Delay [in microseconds]
-P <port> Specify connection port.
-F Override invalid signature check.
-e Perform a chip erase.
-O Perform RC oscillator calibration (see AVR053).
-U <memtype>:r|w|v:<filename>[:format]
Memory operation specification.
Multiple -U options are allowed, each request
is performed in the order specified.
-n Do not write anything to the device.
-V Do not verify.
-u Disable safemode, default when running from a script.
-s Silent safemode operation, will not ask you if
fuses should be changed back.
-t Enter terminal mode.
-E <exitspec>[,<exitspec>] List programmer exit specifications.
-x <extended_param> Pass <extended_param> to programmer.
-y Count # erase cycles in EEPROM.
-Y <number> Initialize erase cycle # in EEPROM.
-v Verbose output. -v -v for more.
-q Quell progress output. -q -q for less.
-l logfile Use logfile rather than stderr for diagnostics.
-? Display this usage.
avrdude version 6.3-20171130, URL: <http://savannah.nongnu.org/projects/avrdude/>
# Pi
avrdude -c avr109 -p m32u4 -P /dev/ttyACM0 -U flash:w:hogehoge.hex
# Windows
avrdude -c avr109 -p m32u4 -P COM123 -U flash:w:hogehoge.hex
●ラズパイで qmkの実行で UnicodeDecodeError
糞が!!
$ qmk -V
Traceback (most recent call last):
File "/home/pi/.local/bin/qmk", line 10, in <module>
sys.exit(main())
File "/home/pi/.local/lib/python3.7/site-packages/qmk_cli/script_qmk.py", line 76, in main
import qmk.cli # noqa
File "/home/pi/qmk_firmware/lib/python/qmk/cli/__init__.py", line 213, in <module>
__import__(subcommand)
File "/home/pi/qmk_firmware/lib/python/qmk/cli/docs.py", line 3, in <module>
import http.server
File "/usr/lib/python3.7/http/server.py", line 627, in <module>
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
File "/usr/lib/python3.7/http/server.py", line 871, in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File "/usr/lib/python3.7/mimetypes.py", line 355, in init
db.read(file)
File "/usr/lib/python3.7/mimetypes.py", line 205, in read
self.readfp(fp, strict)
File "/usr/lib/python3.7/mimetypes.py", line 216, in readfp
line = fp.readline()
File "/usr/lib/python3.7/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
解決方法が不明
$ qmk -V
1.0.0
python3
import sys
sys.stdout.encoding
# 'utf-8'
echo $LANGUAGE
echo $LC_ALL
echo $LANG
echo $LC_TYPE
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_TYPE=en_US.UTF-8
● pip install No usable temporary directory found
$ python3 -m pip install qmk
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 143, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 289, in run
wheel_cache = WheelCache(options.cache_dir, options.format_control)
File "/usr/lib/python3/dist-packages/pip/_internal/cache.py", line 186, in __init__
self._ephem_cache = EphemWheelCache(format_control)
File "/usr/lib/python3/dist-packages/pip/_internal/cache.py", line 164, in __init__
self._temp_dir.create()
File "/usr/lib/python3/dist-packages/pip/_internal/utils/temp_dir.py", line 73, in create
tempfile.mkdtemp(prefix="pip-{}-".format(self.kind))
File "/usr/lib/python3.7/tempfile.py", line 495, in mkdtemp
prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)
File "/usr/lib/python3.7/tempfile.py", line 265, in _sanitize_params
dir = gettempdir()
File "/usr/lib/python3.7/tempfile.py", line 433, in gettempdir
tempdir = _get_default_tempdir()
File "/usr/lib/python3.7/tempfile.py", line 368, in _get_default_tempdir
dirlist)
FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/pi/qmk_firmware']
Disk Full
df -h
● WLS2 + sftp
sudo apt install -y vsftpd
sudo apt install -y openssh-server
sudo nano /etc/ssh/sshd_config
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
sudo service ssh restart
# WinSCP
localhost:22
user
user
● Windows WSL2では USBのデバイスを認識しません
WSL2: Ubuntu 18.04 Serial devices are no longer mounted properly #4322
● 解決方法 その1: Windows版の AVRDUDEを Ubuntu側から実行する
AVRDUDE - AVR Downloader/UploaDEr
AVR Downloader/UploaDEr - Summary
avrdude 最終更新: 2020-06-21 18:09
AVRDUDE for Windows
v6.3.1.1-windows Latest
released 28 Jan 2021
● 解決方法 その2: WSL2の Ubuntuを WSL1に戻します
Microsoft Windows [Version 10.0.19043.1288]
(c) Microsoft Corporation. All rights reserved.
C:\> wsl --set-version Ubuntu 1
変換中です。この処理には数分かかることがあります...
変換が完了しました。
C:\>
$ avrdude -p atmega32u4 -c avr109 -P /dev/ttyS18 -U flash:w:/home/user/qmk_firmware/handwired_freewing_test_expand_io_default.hex
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 "/home/user/qmk_firmware/handwired_freewing_test_expand_io_default.hex"
avrdude: input file /home/user/qmk_firmware/handwired_freewing_test_expand_io_default.hex auto detected as Intel Hex
avrdude: writing flash (17914 bytes):
Writing | ################################################## | 100% 1.43s
avrdude: 17914 bytes of flash written
avrdude: verifying flash memory against /home/user/qmk_firmware/handwired_freewing_test_expand_io_default.hex:
avrdude: load data flash data from input file /home/user/qmk_firmware/handwired_freewing_test_expand_io_default.hex:
avrdude: input file /home/user/qmk_firmware/handwired_freewing_test_expand_io_default.hex auto detected as Intel Hex
avrdude: input file /home/user/qmk_firmware/handwired_freewing_test_expand_io_default.hex contains 17914 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.22s
avrdude: verifying ...
avrdude: 17914 bytes of flash verified
avrdude: safemode: Fuses OK (E:FD, H:D8, L:FF)
avrdude done. Thank you.
/dev/ttyS18の /dev/ttySの番号は下記やデバイスマネージャで調べられます。
Pro Micro Web Updater
USB シリアル デバイス(COM18)とか Arduino Leonardo(COM18)とか表示される。
Tags: [電子工作], [QMK]
●関連するコンテンツ(この記事を読んだ人は、次の記事も読んでいます)
【自由工作】市販のキーボードを無改造で VIA QMK化する Keyboard Quantizerを自作する【夏休み】
夏休みが明けたら 僕のキーボードが最強になって クラスのみんなから MMK 大作戦
BUFFALOの USB テンキーを Pro Microと QMKを使って VIAカスタマイズ キーボードに改造する方法
BUFFALO USB 10-Key keyboard BSTK100 modification by Pro Micro and QMK firmware VIA
QMK firmwareでプログラムのサイズを小さくするテクニック、ケチケチ プログラミングの方法
QMK firmware How to Reduce Program Size、Reducing QMK firmware size
QMK firmwareで I/Oピンが足りない場合にデコーダ、デマルチプレクサを使用して IOを拡張する解決方法
QMK firmware expand I/O for many matrix keyboard、How to use IO Expander Multiplexer / Demultiplexer / Decoder
QMK firmwareで I/Oピンが足りない場合に I2Cの GPIOエキスパンダを使用して IOを拡張する解決方法
QMK firmware expand I/O for many matrix keyboard、How to use I2C GPIO Expander PCF8574 and PCF8575
QMK firmwareで Audio機能を試してみる
QMK firmware test Audio function with Piezo buzzer
QMK firmwareで OLED機能で SSD1306を試してみる
QMK firmware test OLED Driver with SSD1306
QMK firmwareで Analog Stick機能で PSP2000用アナログ ジョイスティックを試してみる
QMK firmware test Analog Joystick function with PSP2000 Analog Stick
最新の QMK firmwareで new_keyboard.shのコマンドが動かなくなったのを修正する方法
QMK Bugfix Create New Keyboard new_keyboard.sh command No such file or directory Error
QMK firmwareの Githubを forkした自分のリモートに pushすると怒られて pushできない場合の対応方法
refusing to allow an OAuth App to create or update workflow `.github/workflows/api.yml` without `workflow` scope
中華製の格安なプログラマブル USBキーボードを買ってみた QMK VIAとは別物
中華製のプログラマブル USBキーボード KeyboardSetter.exe
社畜のキーボード「新入社員の同期」を購入してみた!! VIA、QMK、Remapでのカスタマイズに対応
キー内容が Remap等でカスタマイズ可能な社畜のキーボード「新入社員の同期」を 3500円で購入
[HOME]
|
[BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c)
2021 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator
http://www.neko.ne.jp/~freewing/hardware/qmk_setup_environment_build/