使用 docker 建立 qmk 的開發環境
參考 Setting Up Your QMK Environment
使用和 Linux 下個人帳號,可以在外部直接編輯修改程式
必須要加上 sudo,才能夠建立 qmk 的
Dockerfile
## ref: https://docs.qmk.fm/#/newbs_getting_started
FROM ubuntu:22.10
# Prerequisites
RUN apt-get -y update && apt-get -y upgrade && apt-get clean
RUN apt-get -y install sudo git python3 python3-pip
# Install the QMK CLI
RUN python3 -m pip install --upgrade pip \
&& python3 -m pip install qmk
# 安裝 QMK 開發需求
RUN apt-get -y install \
gcc-arm-none-eabi \
gcc-avr avrdude \
dfu-util dfu-programmer
# 要安裝,否則會出現錯誤
# fatal error: avr/pgmspace.h: No such file or directory
RUN apt-get -y install avr-libc
RUN groupadd ajax -g 1000 \
&& useradd -g 1000 -u 1000 ajax \
&& echo 'ajax:cc1234' | chpasswd \
&& adduser ajax sudo \
&& usermod -aG sudo ajax \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/nopwd
USER ajax
CMD ["/bin/bash"]
經測試,sudo 無效。
要執行 docker,可以建立 docker-compose.yml,或者使用下列命令執行
docker run -it --rm --user 1000:1000 --name qmk-dev \
-v `pwd`:/work -v `pwd`:/home/ajax \
-w /work \
qmk-dev bash
docker-compose.yml
## Teensy development environment
qmk_dev:
build: .
working_dir: /work
volumes:
- "../qmk_work:/work"
- "../qmk_work:/home/ajax"
stdin_open: true
tty: true
user: 1000:1000
entrypoint: /bin/bash
.bashrc
export PS1='\[\033]0;\u@\h:\w\007\]\[\033[01;31m\]qmk_dev@docker\[\033[01;34m\] \w \$\[\033[00m\] '
執行
docker-compose -f docker-compose.yml run --rm qmk_dev
執行 qmk setup
qmk_dev@docker /work $ qmk setup
Ψ Could not find qmk_firmware!
Would you like to clone qmk/qmk_firmware to /home/ajax/qmk_firmware? [y/n] y
Cloning into '/home/ajax/qmk_firmware'...
.....
Ψ QMK home: /home/ajax/qmk_firmware
Ψ Detected Linux.
⚠ Missing or outdated udev rules for 'atmel-dfu' boards. Run 'sudo cp /home/ajax/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'kiibohd' boards. Run 'sudo cp /home/ajax/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'stm32' boards. Run 'sudo cp /home/ajax/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'bootloadhid' boards. Run 'sudo cp /home/ajax/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'usbasploader' boards. Run 'sudo cp /home/ajax/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'massdrop' boards. Run 'sudo cp /home/ajax/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'caterina' boards. Run 'sudo cp /home/ajax/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
⚠ Missing or outdated udev rules for 'hid-bootloader' boards. Run 'sudo cp /home/ajax/qmk_firmware/util/udev/50-qmk.rules /etc/udev/rules.d/'.
Ψ Git branch: master
Ψ Repo version: 0.16.5
☒ Can't find arm-none-eabi-gcc in your path.
☒ Can't find avrdude in your path.
☒ Can't find dfu-programmer in your path.
☒ Can't find dfu-util in your path.
Would you like to install dependencies? [Y/n]
......................
Ψ All dependencies are installed.
Ψ Found arm-none-eabi-gcc version 9.2.1
Ψ Found avr-gcc version 5.4.0
Ψ Found avrdude version 6.3-20171130
Ψ Found dfu-util version 0.9
Ψ Found dfu-programmer version 0.6.1
Ψ Submodules are up to date.
Ψ QMK is ready to go, but minor problems were found
qmk_dev@docker /work $
測試
qmk_dev@docker /work $ qmk compile -kb clueboard/66/rev3 -km default
Ψ Compiling keymap with make --jobs=1 clueboard/66/rev3:default
QMK Firmware 0.16.5
Making clueboard/66/rev3 with keymap default
avr-gcc (GCC) 5.4.0
.....
Linking: .build/clueboard_66_rev3_default.elf [OK]
Creating load file for flashing: .build/clueboard_66_rev3_default.hex [OK]
Copying clueboard_66_rev3_default.hex to qmk_firmware folder [OK]
Checking file size of clueboard_66_rev3_default.hex [OK]
* The firmware size is fine - 27228/28672 (94%, 1444 bytes free)
qmk_dev@docker /work $
.... 待續 ....
沒有留言:
張貼留言