Skip to content

About

QMK userspace for my custom keyboards.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

my_qmk

QMK userspace for my custom keyboards. Each keyboard lives under keyboards/<name>/<rev>/ with its own readme.md, keyboard.json, keymaps, and per-keyboard docs/RE artifacts. Shared tooling and cross-keyboard docs live at the repo root.

Keyboards

Keyboard MCU Notes README
Lucky65 V3 (Weikav) WB32FQ95 (Cortex-M3) 65%, per-key RGB (WS2812), rotary encoder, CH582F BLE/2.4G wireless, WB32 ROM DFU bootloader keyboards/lucky65/v3/readme.md

To add a keyboard: qmk new-keyboard (or copy an existing dir under keyboards/<name>/<rev>/), then add a ["<name>/<rev>", "<keymap>"] row to qmk.json's build_targets.

Repository layout

my_qmk/
├── keyboards/<name>/<rev>/       one dir per keyboard revision
│   ├── readme.md                 hardware / features / DFU-flashing walkthrough
│   ├── keyboard.json  config.h  halconf.h  mcuconf.h  <rev>.c
│   ├── keymaps/                  default, via, and custom keymaps
│   ├── wireless/                 (if applicable) CH582F host-side stack port
│   ├── docs/                     per-keyboard docs (re-findings, rgb, recovery,
│   │                             flashing, wireless, …)
│   └── re/{inputs,outputs}/      per-keyboard RE artifacts (stock image, dumps)
├── layouts/<name>_<rev>/         VIA layout JSON files for that keyboard
├── tools/
│   ├── re/{scripts,lib}/         generic capstone-based RE tooling (env-var
│   │                             driven: QMK_RE_KEYBOARD=<name>/<rev>)
│   └── battery/                  host battery-query client (RAW HID + BlueZ GATT,
│                                                                 --keyboard flag)
├── docs/                         cross-keyboard docs only
│   ├── wb32-dfu.md               WB32 DFU bootloader + flashing primer
│   └── ch582f-protocol.md        CH582F UART protocol (shared reference)
├── build/                        qmk compile output (.bin) — gitignored
├── community_repos/              QMK trees on disk only, NOT tracked
│                                 (upstream qmk/qmk_firmware = build target,
│                                  emolitor wireless-2.0 fork = reference)
├── .opencode/                    OpenCode subagents for the QMK RE pipeline
├── pyproject.toml                Python env for RE scripts (capstone)
├── qmk.json                      QMK CLIs default build targets
└── .gitignore

Setup

1. QMK firmware tree

The WB32FQ95 platform support and CH582F wireless stack are not in upstream QMK. Keyboards that need them carry the ported code in their own userspace dir (keyboards/lucky65/v3/wireless/, mcuconf.h, halconf.h, v3.c, …) so they build against upstream without forking. The emolitor/qmk_firmware wireless-2.0 branch is the reference that code was ported from.

Point QMK_HOME (or run qmk setup) at the upstream clone, then build:

qmk compile -kb lucky65/v3 -km default
qmk compile -kb lucky65/v3 -km via

Output .bin files are written to build/ (gitignored).

Which tree to build against. Set QMK_HOME to upstream qmk/qmk_firmware. The emolitor fork is kept only as a reference for the WB32/wireless source this repo's ports derive from (see References and Tested versions).

2. Python tooling (RE scripts)

uv sync      # installs capstone from pyproject.toml

All RE scripts resolve paths relative to the script file and pick the target keyboard from the QMK_RE_KEYBOARD env var (default lucky65/v3), reading the stock image from keyboards/$QMK_RE_KEYBOARD/re/inputs/original_firmware.bin:

python tools/re/scripts/analyze.py
python tools/re/scripts/disasm.py
QMK_RE_KEYBOARD=lucky65/v3 python tools/re/scripts/scan.py | less

3. Battery monitoring (CH582F keyboards)

python tools/battery/battery_query.py --keyboard lucky65/v3
tools/battery/battery_monitor.sh -k lucky65/v3

Add new CH582F-based keyboards to the KEYBOARDS table in tools/battery/battery_query.py.

4. Flashing

Shared WB32 DFU mechanics (bootloader, flashing tool, command pitfalls, udev rules) live in docs/wb32-dfu.md. Each keyboard's DFU-entry procedure (bootmagic key, QK_BOOT combo, recovery from a stock firmware that blocks bootloader entry) lives in that keyboard's docs/{flashing,recovery}.md:

Quick recap: enter DFU via host HID / Bootmagic / QK_BOOT / VIA remap, then flash with the WB32 DFU updater (not dfu-util). The ROM bootloader at 0x1FFFE000 cannot be erased by user firmware, so a WB32 board cannot be bricked by a bad flash.

Reverse-engineering

Each keyboard's stock firmware image and RE findings live under keyboards/<name>/<rev>/re/ and keyboards/<name>/<rev>/docs/re-findings/ respectively. The capstone-based scripts under tools/re/scripts/ are keyboard-agnostic and target the keyboard selected by QMK_RE_KEYBOARD. The OpenWork RE-pipeline agents (.opencode/agents/) write their phase outputs to keyboards/$QMK_RE_KEYBOARD/docs/re-findings/ and attempt logs to keyboards/$QMK_RE_KEYBOARD/re/attempts/ (per-keyboard, no collision).

References & upstream sources

The sites/repositories used to build, flash, and understand these keyboards:

Resource What it gives you
qmk/qmk_firmware Upstream QMK — the build target. Set QMK_HOME here. Keyboards needing WB32FQ95 + CH582F support carry the port in their own userspace dir so they build against upstream without a fork.
emolitor/qmk_firmware (wireless-2.0 branch) Reference fork. Adds WB32FQ95 platform support, CH582F BLE wireless stack, and battery/low-power drivers. The keyboards/lucky65/v3/wireless/ sources in this repo were ported from this fork; clone it alongside to diff.
emolitor/WestberryTech-WB32 emolitor's fork of the WB32 MCU SDK/HAL. Reference for the Westberry WB32FQ95 (Cortex-M3) register layout, clock tree, and DFU bootloader behaviour used by the firmware.
CH582F wireless-module UART protocol The on-host description of the UART smsg/md_raw framing the CH582F BLE module speaks. Summarized locally at docs/ch582f-protocol.md (shared, cross-keyboard); the full per-board reference with byte tables and Lucky65-specific pinout is keyboards/lucky65/v3/docs/wireless.md.
docs.qmk.fm Main QMK documentation (keycodes, features, build system, keyboard.json schema, keymap API).
docs.qmk.fm/drivers/battery QMK battery telemetry driver docs. The Lucky65 V3 uses a custom battery readout (wireless/battery_custom.c, tools/battery/) layered on the CH582F module, not the stock QMK battery driver.
WestberryTech/wb32-dfu-updater The CLI used to flash WB32 boards. wb32-dfu-updater_cli downloads/uploads firmware to WB32 MCUs over USB DFU. This replaces dfu-util, which does not understand the WB32 DFU protocol. Pre-built packages exist for Windows (MSYS2), macOS (Homebrew), and Fedora (COPR); on other Linux build from source (bash ./bootstrap.sh install). See docs/wb32-dfu.md.

Tested versions

This build is known-good against the following stack. The WB32 platform + wireless code is the fragile part — it lives in this userspace as a port from the emolitor fork, and if a future upstream QMK bumps the HAL/ChibiOS layer or the emolitor fork bumps its wireless SMSG layer, re-verify pin assignments, USB descriptors, and the RGB timing constants before flashing:

  • QMK userspace schema: 1.1 (this repo's qmk.json)
  • Build tree: upstream qmk/qmk_firmware (set QMK_HOME here)
  • Reference fork: emolitor/qmk_firmware branch wireless-2.0, checked out at tag em-2.0.0-1-gb3f5ed4bfc — the source the wireless/ port in this repo derives from
  • qmk CLI: 1.2.0 (Python)
  • Toolchain: arm-none-eabi-gcc (ARM embedded toolchain, as installed by qmk setup / the QMK MSYS bundle)
  • Flashing tool: wb32-dfu-updater_cli (Linux self-built binary)
  • Python tooling: Python >=3.12, capstone>=5.0.9 (for the RE scripts in tools/re/, installed via uv sync)
  • MCU (Lucky65 V3): WB32FQ95 (ARM Cortex-M3, Thumb-2), ROM DFU bootloader at 0x1FFFE000, user flash at 0x08000000

If the build breaks on a newer tree, first check that:

  1. QMK_HOME points at upstream qmk/qmk_firmware and the keyboard's wireless/ port still compiles against the current HAL/ChibiOS layer
  2. the ported files haven't drifted from the emolitor reference fork (diff -r keyboards/<name>/<rev>/wireless ../qmk_firmware_emolitor/...)
  3. keyboard.json matrix pins / ws2812.pin / encoder pins match the keyboard's RE-derived pinout (the stock-firmware pinout is the source of truth, not the QMK reference PCB) — see keyboards/<name>/<rev>/docs/re-findings/.

About

QMK userspace for my custom keyboards.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages