My personal ZMK CONFIG’s for my keyboards.
Distilled from: ZMK Docs: Toolchain Setup and ZMK Docs: Building and Flashing.
- Get ZMK source to mount into container:
git clone https://github.com/zmkfirmware/zmk.git
. - Initialise a Docker Container that will be modified: ~docker run -it –name zmk -v $HOME/github_repos/zmk/app/:/app -v $HOME/github_repos/zmk-config:/zmk-config zmkfirmware/zmk-build-arm:stable~.
docker stop zmk
.docker sart zmk
.- Initial setup in the container:
west init -l /app
west update
west zephyr-export
- Subsequent builds in the container:
cd /app
west build -p -d build/cradio/right/ --board nice_nano -- -DSHIELD=cradio_right -DZMK_CONFIG=/zmk-config/config && west build -p -d build/cradio/left/ --board nice_nano -- -DSHIELD=cradio_left -DZMK_CONFIG=/zmk-config/config && west build -p -d build/ferris --board ferris_rev02 -- -DZMK_CONFIG=/zmk-config/config
- Initial setup in the container:
echo "- Get ZMK source to mount into container..."
git clone https://github.com/zmkfirmware/zmk.git $zmk_path || true
cd $zmk_path
git pull
cd -
echo "- Initialise a Docker Container that will be modified..."
docker run --name zmk -v $PWD/$zmk_path/app/:/app -v $PWD:/zmk-config zmkfirmware/zmk-build-arm:stable sleep infinity
docker stop zmk
docker start zmk
echo "- Initial setup in the container..."
docker exec zmk west init -l /app
docker exec zmk west update
docker exec zmk west zephyr-export
echo "- Install LSP Server (clangd) for emacs..."
docker exec zmk apt-get update
docker exec zmk apt-get -y install clangd
echo "- Subsequent builds in the container..."
docker exec zmk west build -p -s /app -d /app/build/cradio/left/ --board nice_nano -- -DSHIELD=cradio_left -DZMK_CONFIG=/zmk-config/config
docker exec zmk west build -p -s /app -d /app/build/cradio/right/ --board nice_nano -- -DSHIELD=cradio_right -DZMK_CONFIG=/zmk-config/config
docker exec zmk west build -p -s /app -d /app/build/ferris --board ferris_rev02 -- -DZMK_CONFIG=/zmk-config/config
echo "- Copy files to root of build/ ..."
docker exec zmk rm -rf /app/build/*.uf2 /app/build/*.bin || true
docker exec zmk cp /app/build/cradio/left/zephyr/zmk.uf2 /app/build/cradio_left.uf2
docker exec zmk cp /app/build/cradio/right/zephyr/zmk.uf2 /app/build/cradio_right.uf2
docker exec zmk cp /app/build/ferris/zephyr/zmk.bin /app/build/ferris.bin
echo "- SymLink one of the compile_commands.json to satisfy clangd lsp + eglot in emacs..."
docker exec zmk ln -sf /app/build/craidio/right/compile_commands.json /zmk-config/.
Pre-reqs:
- Connect usb.
- Quickly double tap reset button or
GND
+RST
pins.
USB Storage devices (eg. nice!nano):
- Mac doesn’t auto-mount FAT16 external drives. Therefore:
sudo mount -t msdos /dev/disk<#> </mount/path>
echo "- Double-tap GND & RST now!!" mkdir -p ~/Downloads/mounted_keyboard echo "- NOTE: hardcoding to /dev/disk4 for my mac." sleep 10; ls -al /dev/disk*; sudo mount -t msdos /dev/disk4 Downloads/mounted_keyboard echo "- Copy .uf2 file to mounted Nice!Nano now."
- All:
cp </path/to/build/<shield>/<side>/zephyr/zmk.uf2> </mount/path>
.- Unplug after device unmounts itself.
- Power cycle board.