### Install pre-commit Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/pre-commit.md Install the pre-commit tool using pip. Ensure Python is installed if this command fails. ```bash pip3 install pre-commit ``` -------------------------------- ### Example Keymap Bindings for Includes Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/new-behavior.mdx Shows example keymap bindings corresponding to the different 'include' options in devicetree bindings. ```text `&sys_reset` ``` ```text `&kp A` ``` ```text `&mt LSHFT Z` ``` -------------------------------- ### Start Local Development Server Source: https://github.com/zmkfirmware/zmk/blob/main/docs/README.md Starts a local development server for live preview. Changes are reflected without server restart. ```sh $ npm start ``` -------------------------------- ### Macro Bindings Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/keymaps/behaviors/macros.md An example of macro bindings that includes navigating to layer 1, turning on the backlight, and typing 'ZMK!'. ```dts bindings = <&to 1> , <&bl BL_ON> , <&kp Z &kp M &kp K &kp EXCLAMATION> ; ``` -------------------------------- ### Install ZMK CLI with uv Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/user-setup.mdx After installing uv, use this command to install the ZMK CLI. This command ensures ZMK CLI is installed using the uv package manager. ```shell uv tool install zmk ``` -------------------------------- ### Install Dependencies Source: https://github.com/zmkfirmware/zmk/blob/main/docs/README.md Installs project dependencies using npm ci. Ensure Node.js and npm are installed. ```sh $ npm ci ``` -------------------------------- ### Install west tool on Ubuntu (User) Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/native.mdx Installs the 'west' tool for the current user on Ubuntu, ensuring it's added to the PATH. ```sh pip3 install --user -U west echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc source ~/.bashrc ``` -------------------------------- ### Install uv with wget on Linux Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/user-setup.mdx If curl is not available, use wget to install uv on Linux systems. This is an alternative method for environments where curl is not pre-installed. ```shell wget -qO- https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Node Path Examples Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/devicetree.md Illustrates how to specify a path to a devicetree node, either as a reference or a string. ```dts property = &label; ``` ```dts property = "/path/to/some/node"; ``` -------------------------------- ### Devicetree Binding Include Examples Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/new-behavior.mdx Illustrates the different 'include' options for devicetree bindings based on the number of parameters required. ```yaml include: zero_param.yaml ``` ```yaml include: one_param.yaml ``` ```yaml include: two_param.yaml ``` -------------------------------- ### Physical Layout with Keys Property Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/hardware-integration/physical-layouts.md An example of a physical layout for a 2x2 macropad, including the 'keys' property which describes the physical attributes of each key. This is required for ZMK Studio support. ```dts #include / { macropad_physical_layout: macropad_physical_layout { compatible = "zmk,physical-layout"; display-name = "Macro Pad"; transform = <&default_transform>; kscan = <&kscan0>; keys // w h x y rot rx ry = <&key_physical_attrs 100 100 0 0 0 0 0> , <&key_physical_attrs 100 100 100 0 0 0 0> , <&key_physical_attrs 100 100 0 100 0 0 0> , <&key_physical_attrs 100 100 100 100 0 0 0> ; }; }; ``` -------------------------------- ### Kconfig Global Settings Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/config/index.md Example of a Kconfig file defining global settings like sleep mode and EC11 encoder. ```ini CONFIG_ZMK_SLEEP=y CONFIG_EC11=y CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y ``` -------------------------------- ### Install uv with winget on Windows Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/user-setup.mdx This command installs uv on Windows using the winget package manager. After installation, you may need to restart your shell for PATH changes to take effect. ```shell winget install --id astral-sh.uv -e --source winget ``` -------------------------------- ### Keyboard Matrix Transform Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/hardware-integration/dongle.mdx An example of a matrix transform node that needs to be copied into the dongle overlay file. It defines the keyboard's physical layout. ```dts default_transform: keymap_transform_0 { compatible = "zmk,matrix-transform"; columns = <14>; rows = <5>; map = < // Lots of RC(r,c) macros >; }; ``` -------------------------------- ### Install and Verify Dev Container CLI Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/container.mdx Ensure the Dev Container CLI is installed by checking its version. This is a prerequisite for using the CLI to manage development containers. ```bash devcontainer --version ``` -------------------------------- ### Mod-Morph Devicetree Binding Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/new-behavior.mdx Example of a devicetree binding file for the 'mod-morph' behavior. It declares the behavior's properties using YAML format. ```yaml # Copyright (c) 2020 The ZMK Contributors ``` -------------------------------- ### ZMK Devicetree Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/devicetree.md A devicetree segment demonstrating behavior definitions and keymap configuration in ZMK. Includes custom behavior 'space_underscore' and a default layer. ```dts #include #include / { behaviors { spc_ul: space_underscore { compatible = "zmk,behavior-mod-morph"; #binding-cells = <0>; bindings = <&kp SPACE>, <&kp UNDERSCORE>; mods = <(MOD_LSFT|MOD_RSFT)>; }; }; keymap { compatible = "zmk,keymap"; default_layer { bindings = <&spc_ul &kp Z &kp M &kp K>; }; }; }; ``` -------------------------------- ### Install west tool Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/native.mdx Installs the 'west' tool, a meta-tool for managing Zephyr RTOS projects, using pip. ```sh pip install west ``` -------------------------------- ### Kconfig Integer Value Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/config/index.md Shows an integer value assignment in a Kconfig file. ```ini CONFIG_FOO=42 ``` -------------------------------- ### Out-of-Tree Board Pinctrl Configuration Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/blog/2023-04-06-zephyr-3-2.md Example DTS file for configuring pin control settings for UART and I2C peripherals on a board. This is used when updating out-of-tree boards to ZMK's new pinctrl approach. ```dts /* * Copyright (c) 2022 The ZMK Contributors * SPDX-License-Identifier: MIT */ &pinctrl { uart0_default: uart0_default { group1 { psels = ; bias-pull-up; }; group2 { psels = ; }; }; uart0_sleep: uart0_sleep { group1 { psels = , ; low-power-enable; }; }; i2c0_default: i2c0_default { group1 { psels = , ; }; }; i2c0_sleep: i2c0_sleep { group1 { psels = , ; low-power-enable; }; }; }; ``` -------------------------------- ### Kconfig String Value Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/config/index.md Illustrates how to define a string value in a Kconfig file, enclosed in double quotes. ```ini CONFIG_FOO="foo" ``` -------------------------------- ### Install west tool on Windows Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/native.mdx Installs the 'west' tool on Windows and adds the Python scripts directory to the user's PATH environment variable. ```powershell pip install -U west $Scripts = python -c "import sysconfig; print(sysconfig.get_path('scripts'))" $Path = [Environment]::GetEnvironmentVariable('PATH', 'User') [Environment]::SetEnvironmentVariable('PATH', "$Path;$Scripts", 'User') $env:PATH += ";$Scripts" ``` -------------------------------- ### Devicetree Base Hardware Definition Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/config/index.md Example of a base Devicetree file defining the hardware structure, including chosen nodes and kscan configuration. ```dts / { chosen { zmk,kscan = &kscan0; }; kscan0: kscan { compatible = "zmk,kscan-gpio-matrix"; }; }; ``` -------------------------------- ### ZMK CLI General Usage Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/zmk-cli.mdx All ZMK CLI commands start with 'zmk'. Use '--help' for general usage or specific subcommand help. ```sh zmk --help ``` -------------------------------- ### Example EC11 Encoder Bindings for Kyria Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/features/encoders.md Configures two encoders on a Kyria board: one for volume control and another for page navigation. ```dts sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN &inc_dec_kp PG_UP PG_DN>; ``` -------------------------------- ### Example ARM GCC Compiler Path Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/ide-integration.mdx This is an example of a compiler path for the ARM GCC toolchain, derived from the output of the verify-toolchain.cmake script. Adjust the SDK directory and GCC binary path as necessary for your setup. ```text /home/marvin/.local/zephyr-sdk-0.15.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc ``` -------------------------------- ### Example Encoding (Simple) Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/studio-rpc-protocol.md Illustrates message framing when the payload does not contain special bytes. The message is framed with Start of Frame (SoF) and End of Frame (EoF) bytes. ```mermaid block-beta columns 5 space:1 block:group1:3 columns 3 contentLabel["Content"]:1 space:2 OrigA["0x12"] OrigB["0x01"] OrigC["0xBB"] end space down<[" "]>(down):5 block:groupSoF:1 columns 1 SoFLabel["SoF"] SoF["0xAB"] end block:group2:3 columns 3 contentLabel2["Content"]:1 space:2 EncA["0x12"] EncB["0x01"] EncC["0xBB"] end block:groupEoF:1 columns 1 EoFLabel["EoF"] 0xAD end class contentLabel boxLabel class contentLabel2 boxLabel class SoFLabel boxLabel class EoFLabel boxLabel classDef boxLabel stroke:transparent,fill:transparent ``` -------------------------------- ### Configure Mod-Morph Behavior (Grave Escape) Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/keymaps/behaviors/mod-morph.md Example of configuring a mod-morph behavior for 'Grave Escape'. This setup sends 'Escape' when tapped alone and '`' (grave accent) when tapped with Shift or GUI modifiers held. ```dts / { behaviors { gresc: grave_escape { compatible = "zmk,behavior-mod-morph"; #binding-cells = <0>; bindings = <&kp ESC>, <&kp GRAVE>; mods = <(MOD_LGUI|MOD_LSFT|MOD_RGUI|MOD_RSFT)>; }; }; }; ``` -------------------------------- ### Verify ZMK Toolchain Configuration Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/ide-integration.mdx Run this command in VS Code's integrated terminal to get information about your ZMK toolchain, including the SDK version and installation directory. This helps in determining the correct compiler path. ```shell cmake -P zephyr/cmake/verify-toolchain.cmake ``` -------------------------------- ### Keymap with Behavior and Keycode Completion Source: https://github.com/zmkfirmware/zmk/blob/main/docs/blog/2024-01-05-zmk-tools.md Example of a ZMK keymap after ZMK Tools has provided code completion for '&kp' and added the necessary keycode header. ```dts #include #include / { keymap { compatible = "zmk,keymap"; default_layer { bindings = < &kp A >; }; }; }; ``` -------------------------------- ### Initialize a new ZMK config repo Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/user-setup.mdx Navigate to the desired parent directory and run this command to initialize a new ZMK configuration repository. Follow the on-screen prompts to create a new GitHub repository or clone an existing one. ```shell cd ~/Documents zmk init ``` -------------------------------- ### Install curl on Debian-based Linux Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/user-setup.mdx If curl is not found, this command installs curl on Ubuntu and other Debian-based Linux distributions. After installation, you can use the curl command to install uv. ```shell sudo apt update sudo apt install curl curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Bluetooth Behavior Two Param Include Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/new-behavior.mdx Demonstrates the use of 'two_param.yaml' for behaviors like Bluetooth, even when the keymap usage appears to use only one extra parameter. ```c #define BT_NXT BT_NXT_CMD 0 #define BT_PRV BT_PRV_CMD 0 ``` -------------------------------- ### Install Pre-commit Hooks for Documentation Formatting Source: https://github.com/zmkfirmware/zmk/blob/main/CONTRIBUTING.md Set up git to automatically format documentation files using prettier when committing. This ensures consistent code style across the project. ```bash pip3 install pre-commit pre-commit install ``` -------------------------------- ### Initialize ZMK Application and Update Modules Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/native.mdx Initializes the ZMK application and fetches all necessary modules, including Zephyr, using 'west'. This step can take a significant amount of time. ```sh west init -l app/ west update ``` -------------------------------- ### Check Git Installation Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/user-setup.mdx Run this command in your terminal to check if Git is installed. If an error occurs, follow the provided link to install Git. ```sh git --version ``` -------------------------------- ### Install uv with curl on Linux/macOS Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/user-setup.mdx Use this command to install uv, a Python package manager, on Linux or macOS systems using curl. Ensure curl is installed if you encounter errors. ```shell curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Build Command for nice!view Adapter Source: https://github.com/zmkfirmware/zmk/blob/main/app/boards/shields/nice_view_adapter/README.md Use this command to build your ZMK firmware with the nice!view Adapter shield. Ensure the shield is listed before `nice_view` in your build configuration. ```bash west build -b nice_nano -- -DSHIELD="lily58_left nice_view_adapter nice_view" ``` -------------------------------- ### Install west tool on macOS Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/native.mdx Installs the 'west' tool on macOS using pip3. ```sh pip3 install -U west ``` -------------------------------- ### Install Python venv on Ubuntu Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/native.mdx Installs the Python virtual environment package using apt on Ubuntu. ```sh sudo apt install python3-venv ``` -------------------------------- ### Install GCC Multilib on Debian Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/posix-board.md Installs the necessary 32-bit POSIX compiler for building ZMK firmware on Debian systems. ```sh apt install -y gcc-multilib ``` -------------------------------- ### Build ZMK Firmware for nice!60 Source: https://github.com/zmkfirmware/zmk/blob/main/app/boards/nicekeyboards/nice60/README.md Use this command to build the ZMK firmware specifically for the nice!60 keyboard. Ensure you have the ZMK build environment set up. ```bash west build -p -b nice60//zmk ``` -------------------------------- ### Run Container with Podman Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/container.mdx Start a container using Podman, mounting necessary volumes and exposing ports. This command is used to launch the development environment after building the image. ```bash podman run -it --rm \ --security-opt label=disable \ --workdir /workspaces/zmk \ -v /path/to/zmk:/workspaces/zmk \ -v /path/to/zmk-config:/workspaces/zmk-config \ -v /path/to/zmk-modules:/workspaces/zmk-modules \ -p 3000:3000 \ /bin/bash ``` -------------------------------- ### West Build Command Log Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/troubleshooting/building-issues.md This log output from a West build command shows the configuration files that were found and used during the build process, including the ZMK configuration file. ```bash + west build -s zmk/app -d /tmp/tmp.8cJefinXCb -b corneish_zen_left@2 -- -DZMK_CONFIG=/tmp/zmk-config/config -DZMK_EXTRA_MODULES=/__w/zmk-config/zmk-config ... -- ZMK Config Kconfig: /tmp/zmk-config/config/corneish_zen.conf ... ``` -------------------------------- ### Build Leeloo-Micro ZMK Firmware with nice!view Displays (Default Keymap) Source: https://github.com/zmkfirmware/zmk/blob/main/app/boards/shields/leeloo_micro/README.md Build commands for the default keymap of Leeloo-Micro, including the necessary flags for nice!view adapter and display. ```bash west build -d build/left -p -b nice_nano -- -DSHIELD="leeloo_micro_left nice_view_adapter nice_view" west build -d build/right -p -b nice_nano -- -DSHIELD="leeloo_micro_right nice_view_adapter nice_view" ``` -------------------------------- ### Example of Board Revision Shorthands in ZMK Source: https://github.com/zmkfirmware/zmk/blob/main/docs/blog/2025-12-09-zephyr-4-1.md Illustrates how to specify board revisions using shorthand notation in ZMK's build system. This is useful for selecting specific versions of boards like nice!nano and nRFMicro. ```text - nice!nano (`nice_nano`) - `nice_nano` -> `nice_nano@1.0.0//zmk` (short: `nice_nano@1//zmk`) - `nice_nano_v2` -> `nice_nano@2.0.0//zmk` (short: `nice_nano//zmk`) - nRFMicro (`nrfmicro/nrf52840`) - `nrfmicro_11` -> `nrfmicro@1.1.0/nrf52840/zmk` (short: `nrfmicro@1.1/nrf52840/zmk`) - `nrfmicro_11_flipped` -> `nrfmicro@1.1.0/nrf52840/flipped_zmk` (short: `nrfmicro@1.1/nrf52840/flipped_zmk`) - `nrfmicro_13` -> `nrfmicro@1.3.0/nrf52840/zmk` (short: `nrfmicro/nrf52840/zmk`) - `nrfmicro_13_52833` -> `nrfmicro@1.3.0/nrf52833/zmk` (short: `nrfmicro/nrf52833/zmk`) - Mikoto (`mikoto`) - `mikoto` -> `mikoto@5.20.0//zmk` (short: `mikoto//zmk`) - `mikoto@6.1` -> `mikoto@6.1.0//zmk` (short: `mikoto@6//zmk`) - `mikoto@7.2` -> `mikoto@7.2.0//zmk` (short: `mikoto@7//zmk`) - XIAO RP2040 (`xiao_rp2040`) - `seeeduino_xiao_rp2040` -> `xiao_rp2040//zmk` - XIAO nRF52840/BLE (`xiao_ble`) - `seeeduino_xiao_ble` -> `xiao_ble//zmk` - BT60 (`bt60`) - `bt60_v1` -> `bt60@1.0.0//zmk` - `bt60_v2` -> `bt60@2.0.0//zmk` - `bt60_hs` -> `bt60_hs//zmk` - Planck (`planck`) - `planck_rev6` -> `planck//zmk` - BDN9 (`bdn9`) - `bdn9_rev2` -> `bdn9//zmk` - Ferris Rev2 (`ferris`) - `ferris_rev02` -> `ferris@2.0.0//zmk` (short: `ferris//zmk`) - Corne-ish Zen (`corneish_zen`) - `corneish_zen_v2_left` -> `corneish_zen_left@2.0.0//zmk` (short: `corneish_zen_left//zmk`) - `corneish_zen_v2_right` -> `corneish_zen_right@2.0.0//zmk` (short: `corneish_zen_right//zmk`) - `corneish_zen_v1_left` -> `corneish_zen_left@1.0.0//zmk` (short: `corneish_zen_left@1//zmk`) - `corneish_zen_v1_right` -> `corneish_zen_right@1.0.0//zmk` (short: `corneish_zen_right@1//zmk`) ``` -------------------------------- ### Verify ZMK CLI installation Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/user-setup.mdx After updating your shell, run this command to check if ZMK CLI is installed correctly. It should output a version number. ```shell zmk --version ``` -------------------------------- ### West Build Command and Devicetree File Discovery Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/troubleshooting/building-issues.md This output shows the commands used by 'west build' to compile the firmware and lists the devicetree files it found and included in the build process. It's useful for verifying that the correct board, overlay, and keymap files are being recognized. ```bash + west build -s zmk/app -d /tmp/tmp.8cJefinXCb -b corneish_zen_left@2 -- -DZMK_CONFIG=/tmp/zmk-config/config -DZMK_EXTRA_MODULES=/__w/zmk-config/zmk-config -- Found BOARD.dts: /tmp/zmk-config/zmk/app/boards/lowprokb/corneish_zen/corneish_zen_left.dts -- Found devicetree overlay: /tmp/zmk-config/zmk/app/boards/lowprokb/corneish_zen/corneish_zen_left_2_0_0.overlay -- Found devicetree overlay: /tmp/zmk-config/config/corneish_zen.keymap ... ``` -------------------------------- ### Navigate into ZMK Directory Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/native.mdx Change your current directory to the newly cloned ZMK repository. ```bash cd zmk ``` -------------------------------- ### Create a New Keyboard Template Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/zmk-cli.mdx Use 'zmk keyboard new' to generate the boilerplate files for adding support for a new, unsupported keyboard. ```sh zmk keyboard new ``` -------------------------------- ### Build Leeloo-Micro ZMK Firmware with nice!view Displays (Custom Keymap) Source: https://github.com/zmkfirmware/zmk/blob/main/app/boards/shields/leeloo_micro/README.md Build commands for a custom keymap of Leeloo-Micro with nice!view displays, specifying the ZMK configuration path. ```bash west build -d build/left -p -b nice_nano -- -DSHIELD="leeloo_micro_left nice_view_adapter nice_view" -DZMK_CONFIG="/workspaces/zmk-config/[yourName]/leeloo_micro/config" west build -d build/right -p -b nice_nano -- -DSHIELD="leeloo_micro_right nice_view_adapter nice_view" -DZMK_CONFIG="/workspaces/zmk-config/[yourName]/leeloo_micro/config" ``` -------------------------------- ### List and Connect to Docker Containers Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/container.mdx List running Docker containers to find the container ID, then use 'docker exec' to connect to the running container and execute commands within its environment. ```bash docker ps docker exec -w /workspaces/zmk -it /bin/bash ``` -------------------------------- ### Install ZMK Tools Extension Source: https://github.com/zmkfirmware/zmk/blob/main/docs/blog/2024-01-05-zmk-tools.md Install the ZMK Tools extension in VS Code via the command palette. This enables enhanced features for ZMK development. ```shell ext install spadin.zmk-tools ``` -------------------------------- ### Example Commit Message Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/contributing/pull-requests.md An example of a well-formatted commit message following conventional commit standards, including a type, scope, concise summary, and detailed body. ```git feat(boards): Add numpad layouts Added physical layouts for the following variants of numpads: - With and without extra top row - 2U plus key or 1U plus and backspace keys - 2U 0 key or 1U 0 and 00 keys - Full 1U grid/macropad layout Other layouts exist, such as "southpaw" horizontally mirrored layouts, and layouts with a fifth column, but those seem to be much less common. ``` -------------------------------- ### Start Dev Container with Workspace Folder Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/container.mdx Initiate a development container using the Dev Container CLI, specifying the workspace folder. This command pulls images and builds the container if it's the first time. ```bash devcontainer up --workspace-folder "/absolute/path/to/zmk" ``` -------------------------------- ### Build ZMK for Addon MCU Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/build-flash.mdx Build ZMK firmware for keyboards using an addon MCU board. Specify the MCU board as the board argument and the keyboard PCB as a shield using '-DSHIELD'. ```shell west build -b proton_c -- -DSHIELD=kyria_left ``` -------------------------------- ### Direct KScan Driver Setup Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/hardware-integration/includes/_sideband-direct.md Configure the direct kscan driver with a GPIO key for a small side matrix. This setup is used for triggering behaviors out of band. ```dts / { wakeup_scan: wakeup_scan { compatible = "zmk,kscan-gpio-direct"; input-keys = <&soft_off_gpio_key>; wakeup-source; }; }; ``` -------------------------------- ### Install ARM Cross-Compile Toolchain Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/setup/native.mdx Installs the GCC cross-compiler for ARM embedded systems on Debian-based systems like Raspberry Pi OS. This is the first step in setting up the native toolchain. ```sh sudo apt install gcc-arm-none-eabi ``` -------------------------------- ### Automated Board Upgrade Script Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/blog/2025-12-09-zephyr-4-1.md Demonstrates how to use the Zephyr board upgrade script to convert an out-of-tree board to HWMv2. Ensure your ZMK and Zephyr versions are updated and `west update` has been run. ```shell $ python3 zmk/zephyr/scripts/utils/board_v1_to_v2.py \ --board-root my-zmk-module -b my_board \ -v my_company -g my_group -s nrf52840 ``` -------------------------------- ### Example RISC-V GCC Compiler Path Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/ide-integration.mdx This is an example of a compiler path for a RISC-V toolchain. If you are building for an architecture other than ARM, replace the ARM-specific path with the correct path for your target architecture's GCC binary. ```text /home/marvin/.local/zephyr-sdk-0.15.2/riscv64-zephyr-elf/bin/riscv64-zephyr-elf-gcc ``` -------------------------------- ### Conditional Source Inclusion for Settings Reset on Start Source: https://github.com/zmkfirmware/zmk/blob/main/app/src/settings/CMakeLists.txt Conditionally includes the source file for resetting settings on firmware start based on the Kconfig configuration. This allows enabling or disabling the automatic reset of settings when the device boots. ```cmake target_sources_ifdef(CONFIG_ZMK_SETTINGS_RESET_ON_START app PRIVATE reset_settings_on_start.c) ``` -------------------------------- ### Run All Native POSIX Tests Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/local-toolchain/tests.md Execute all tests located in `/app/tests` that contain a `native_posix_64.keymap` file. Ensure you are in the `/zmk/app` directory before running. ```bash west test ``` -------------------------------- ### Iterate and Define All Hold-Tap Behavior Instances Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/new-behavior.mdx This macro iterates through all compatible and enabled devicetree nodes for a behavior, invoking the KP_INST macro for each to create and apply instance-specific configurations. ```c DT_INST_FOREACH_STATUS_OKAY(KP_INST) ``` -------------------------------- ### Kconfig Boolean Value Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/config/index.md Demonstrates the boolean value type in Kconfig, using 'y' for enabled. ```ini CONFIG_FOO=y ``` -------------------------------- ### Devicetree String Property Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/devicetree.md Shows how to define a string property with text enclosed in double quotes. ```dts property = "foo"; ``` -------------------------------- ### Enable USB Logging with west build Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/usb-logging.mdx When building ZMK firmware locally, use the `-S` or `--snippet` flag with `west build` to enable the USB logging snippet. ```sh west build -b nice_nano -S zmk-usb-logging -- -DSHIELD="corne_left" ``` -------------------------------- ### Devicetree Boolean Property Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/devicetree.md Demonstrates how to set a boolean property to true by listing it without a value. ```dts property; ``` -------------------------------- ### Devicetree Node Modification Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/config/index.md Shows how to modify an existing Devicetree node by referencing its label and changing a property. ```dts &kscan0 { debounce-press-ms = <0>; }; ``` -------------------------------- ### Enable Backlight Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/features/lighting.md Enable the backlight feature on your board or shield by adding the CONFIG_ZMK_BACKLIGHT configuration line to your .conf file. ```ini CONFIG_ZMK_BACKLIGHT=y ``` -------------------------------- ### Open Configuration Repo in Editor Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/user-setup.mdx Opens your entire ZMK configuration repository in a text editor, useful for editing multiple files or when no specific keyboard is selected. ```sh zmk code ``` -------------------------------- ### Get Behavior Binding by Name Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/new-behavior.mdx Retrieves the device associated with a behavior from its name. Used for device-level behavior operations. ```c #include const struct device *behavior_dev = zmk_behavior_get_binding("behavior_name"); ``` -------------------------------- ### Enable nice!view SPI Configuration Source: https://github.com/zmkfirmware/zmk/blob/main/app/boards/shields/leeloo_micro/README.md Modify the leeloo_micro.keymap file to uncomment the SPI configuration for nice!view displays. This enables the necessary communication interface. ```c nice_view_spi: &spi0 { cs-gpios = <&pro_micro 4 GPIO_ACTIVE_HIGH>; }; ``` -------------------------------- ### Reference a Code Mapper Instance Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/keymaps/input-processors/code-mapper.md Reference a pre-defined code mapper instance in your configuration. This example shows how to reference the `zip_xy_to_scroll_mapper`. ```dts &zip_xy_to_scroll_mapper ``` -------------------------------- ### Scaler Configuration Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/keymaps/input-processors/scaler.md Configure a scaler input processor with a multiplier of 2 and a divisor of 1 to double X/Y movement. ```dts &zip_xy_scaler 2 1 ``` -------------------------------- ### Keymap with Behavior Completion Source: https://github.com/zmkfirmware/zmk/blob/main/docs/blog/2024-01-05-zmk-tools.md Illustrates ZMK Tools' code completion for behaviors like '&kp' in a keymap file. It automatically adds the required behaviors header. ```dts #include / { keymap { compatible = "zmk,keymap"; default_layer { bindings = < &kp >; }; }; }; ``` -------------------------------- ### GPIO Array Example Source: https://github.com/zmkfirmware/zmk/blob/main/docs/docs/development/devicetree.md Defines an array of GPIO nodes with configuration flags. Useful for specifying GPIO configurations in devicetree. ```dts some-gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>, <&gpio0 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> ; ```