Skip to content

jackson15j/zmk-config

Repository files navigation

ZMK Config

My personal ZMK CONFIG’s for my keyboards.

Docker:

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

Org codeblock to initialise the zmk DevContainer:

See: zmk docs: local toolchain > container setup.

ZMK_CONFIG_PATH=$zmk_config_path
echo "$PWD"
echo "$zmk_path"
echo "$zmk_config_path"

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 "- Get DevContainer installed..."
brew install devcontainer
LABEL="ci-container=zmk-dev"
echo "- create mount point for my config..."
# docker rm -f zmk-dev
docker volume rm -f zmk-config
docker volume create --driver local -o o=bind -o type=none \
  -o device=$zmk_config_path zmk-config

echo "- Initial setup in the container..."
devcontainer up \
             --remove-existing-container=true \
             --id-label=$LABEL \
             --workspace-folder "$zmk_path"
             # --mount type=volume,source=$zmk_config_path,target=/workspaces/zmk-config \

echo "- Initial setup in the container..."
# devcontainer exec --id-label=$LABEL west init -l /workspaces/zmk/app/
# devcontainer exec --id-label=$LABEL sh -c 'cd /workspaces/zmk/ && west update'
devcontainer exec --id-label=$LABEL sh -c 'cd /workspaces/zmk/ && west init -l app/; west update'
# devcontainer exec --id-label=$LABEL west zephyr-export

# echo "- Install LSP Server (clangd) for emacs..."
# devcontainer exec --id-label=$LABEL pip3 install pre-commit

Org codeblock to initialise the zmk docker 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
docker exec zmk pip3 install pre-commit

Org codeblock to build firmware’s in the zmk docker container:

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
docker exec zmk west build -p -s /app -d /app/build/pepesweep/left/ --board nice_nano -- -DSHIELD=pepesweep_left -DZMK_EXTRA_MODULES=/zmk-config -DZMK_CONFIG=/zmk-config/config
docker exec zmk west build -p -s /app -d /app/build/pepesweep/right/ --board nice_nano -- -DSHIELD=pepesweep_right -DZMK_EXTRA_MODULES=/zmk-config -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
docker exec zmk cp /app/build/pepesweep/left/zephyr/zmk.uf2 /app/build/pepesweep_left.uf2
docker exec zmk cp /app/build/pepesweep/right/zephyr/zmk.uf2 /app/build/pepesweep_right.uf2

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/.

flashing:

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.

Layouts:

Sweep:

keymap-drawer/cradio.svg

Pepesweep:

keymap-drawer/pepesweep.svg

About

ZMK Config for the custom programmable keyboards that I have.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors