DocsDevelop
Build the firmware yourself
An overview for developers: environment, signing key, first USB flash, deploying over Wi-Fi, and the daily development loop, with links to step-by-step guides on GitHub.
Who this is for#
Developers who want to change the firmware, add endpoints, or work on the UI. If you just want to use the device, install from the website; see Quick start.
The full step-by-step guide is on GitHub: docs/getting-started.md. Going from a brand-new board to controlling it from the command line and an agent takes about an hour, most of it spent installing ESP-IDF and downloading components for the first time. This page is an overview.
NoteBuilding from scratch has only been done on Windows so far.
Environment#
| Tool | Version | Install |
|---|---|---|
| Git | Any recent version | git-scm.com |
| uv | 0.9 or later | winget install astral-sh.uv |
| Node.js | 22 or later, for building the device web app | winget install OpenJS.NodeJS.LTS |
| EIM | 0.23 or later | winget install Espressif.EIM-CLI |
| ESP-IDF | v6.1.1 | eim install -i v6.1.1 |
You don't need to install Python separately; uv sets up the version the project needs.
Get the code#
git clone https://github.com/kk8o/keyling C:\Projects\keyling
cd C:\Projects\keyling
uv sync --project host
function stick { uv run --project C:\Projects\keyling\host stick @args }WarningThe repository path must not contain spaces, or the build fails with path_has_space.
Steps at a glance#
| Step | Command | Notes |
|---|---|---|
| Generate a signing key | stick keygen |
Creates secrets/signing_key.pem. From then on the device only accepts Wi-Fi updates signed with this key. Keep a backup |
| First USB flash | stick usb-flash --port COM3 --build |
First hold BOOT while plugging in USB to enter download mode. Builds and flashes the bootloader, partition table, and rescue firmware, then pairs over serial |
| Wi-Fi setup | Connect your phone to the device's hotspot and open http://192.168.4.1/ |
See Wi-Fi setup and networking |
| Install the kernel | stick deploy |
Builds the kernel, uploads over Wi-Fi, restarts, runs a health check, confirms |
| Set the time zone | stick tz |
Sets the device time zone to this computer's |
| Install the device web app | stick www build, then stick www push |
Run npm install in web/ first |
| Install the macro player | stick push apps/macro |
|
| Self-test | stick selftest |
Presses F13–F24 and moves the cursor |
The secrets/ directory holds the signing key and pairing keys. It is excluded by .gitignore; do not commit it.
If the device already runs official firmware, start from "First USB flash" as well: the signing key can only be changed over USB; see Updates and recovery.
Daily development#
| What you changed | What to do |
|---|---|
| Kernel | stick deploy. If the new version fails to come up, it rolls back automatically and brings back the logs |
| Rescue firmware | stick deploy rescue. Goes through the other kernel slot, so the fallback version in that slot is erased |
| Lua app | stick push apps/<app ID>. Hot reload, no restart |
| Device web app | stick www build → stick www push |
| After firmware changes | stick selftest |
Troubleshooting:
| Command | Purpose |
|---|---|
stick logs |
Logs; --boots and --boot read the black-box log on the microSD card |
stick status |
Status snapshot |
stick crash --decode |
Fetch the crash dump and decode the backtrace |
stick snap |
Screenshot |
stick drill <name> |
Fault drills: network loss, restart, crash, long-running soak, and more |
Host tool tests run against a fake device and never touch real hardware:
cd host
uv run pytest -qFirmware structure#
- Two firmware projects,
firmware/rescue(rescue firmware) andfirmware/kernel(kernel), sharing the components undercomponents/. - Partitions on the 16 MB flash: 1.5 MB for rescue firmware, 3 MB for each of the two kernel slots, about 8.3 MB for storage, plus small partitions for configuration, crash dumps, and so on.
- Firmware is signed with an RSA-3072 key and checked when updating over Wi-Fi. No eFuses are burned; Secure Boot and flash encryption are not enabled.
- By default the kernel sets USB to keyboard and mouse, so the USB serial port disappears and updates, logs, and screenshots all go over Wi-Fi. For a serial port:
stick boot rescue, orstick usb serial.
Working with agents#
The .mcp.json at the repository root registers two sets of MCP tools, stick and stick-sdk, and CLAUDE.md describes the environment, common commands, and rules. Open an MCP-capable agent in the repository directory and it can handle the whole loop on its own: write code, build, update, read logs, look at the screen, and verify output.
Developer docs#
| Document | Contents |
|---|---|
| docs/getting-started.md | Step-by-step guide to building from scratch, with FAQ |
| docs/design.md | Layers, partitions, updates and recovery, status and screens, component versions |
| docs/interfaces.md | Device protocol, boot rules, authentication, HID, app layer, microSD card |
| docs/lua.md | Lua app API |
| docs/web.md | Device web app, pairing with BOOT, macro format |
| docs/web-flash.md | Design of the web installer |
| host/README.md | All host tool commands |
| sdk/README.md | Software-layer SDK |
| THIRD_PARTY.md | Third-party components and licenses |
License#
The project's own code is released under the MIT license. Third-party components keep their own licenses: Lua (MIT), the Noto Sans SC font subset (SIL OFL 1.1), ESP-IDF components such as LVGL, TinyUSB, mDNS, LittleFS, and cJSON, and Preact, htm, and esbuild used by the web app.