A Keyboard for Before the Operating System Boots
SSH works after the operating system boots, networking starts and remote access is configured.
Sometimes the problem is earlier than that.
I built a small controller which appears to the target as an ordinary USB keyboard but accepts commands from another computer over Bluetooth Low Energy. It can type into firmware menus, boot pickers, recovery screens and disk-unlock prompts before the target has a network stack.
Two sides of one keyboard
The controller applies experience from a split nRF52 keyboard running ZMK to a nice_nano@2.0.0//zmk-compatible board running ZMK and Zephyr.
To the target machine it is a USB HID keyboard (CONFIG_ZMK_USB=y), with a zero-row zmk,kscan-mock matrix because there are no physical keys at all.
That interface is understood very early in the boot process.
To the controlling machine, ZMK’s own Bluetooth HID profile is turned off (CONFIG_ZMK_BLE=n) and replaced by a custom BLE GATT service advertised as "Remote Ctrl".
The host writes binary command packets to a GATT characteristic, and the firmware injects them into ZMK with raise_zmk_keycode_state_changed_from_encoded() so they go out over USB.
control computer -- BLE GATT --> nRF52 (ZMK) -- USB HID --> target computer
The target does not need Bluetooth, Wi-Fi, an operating system or any special driver. It believes somebody is pressing keys on a normal wired keyboard.
The firmware builds reproducibly with nix build .#firmware and runs on a real nice!nano-compatible board.
More than sending a string
Every command starts with a 4-byte binary header (version, command, sequence, flags), followed by command-specific bytes: ping (0x01), bootloader entry (0x02), key press/release/tap/release-all (0x10–0x13) carrying a HID (usage_page, usage_id) pair, and power actuator commands (0x20–0x22).
The host CLI translates ordinary text into keyboard usages (0x07) and modifiers, including shifted letters and punctuation, and also accepts symbolic names or raw usage_page:usage_id pairs.
Macros are readable TOML rather than captured packets:
name = "boot-login-example"
[[steps]]
action = "sleep"
ms = 1000
[[steps]]
action = "type"
text = "password"
[[steps]]
action = "tap"
key = "ENTER"
They can combine key actions, text entry, sleeps and bootloader entry.
An interactive recorder (remote-keyboard macro record) stores those high-level operations.
A persistent session can execute several commands over one BLE connection, and a Python library exposes the same control plane to a larger boot orchestrator.
The firmware tracks up to 64 held usages in a mutex-guarded table and releases all of them on release-all, bootloader entry or BLE disconnect so a failed controller does not leave the target believing that Control or Shift remains pressed forever.
The host side has sixteen pytest tests covering packet encoding, usage parsing, text translation, macro validation and recording.
Updating the controller remotely
Command 0x02 releases all held keys, sets Zephyr’s retention boot mode (BOOT_MODE_TYPE_BOOTLOADER) and triggers a warm reboot into the UF2 bootloader after 250 ms.
The host (remote-keyboard flash result/zmk.uf2) treats the resulting BLE disconnect as expected, waits for the NICENANO UF2 storage volume, mounts it when necessary, copies the new image and waits for the volume to disappear as the board restarts.
That made firmware iteration much less dependent on repeatedly reaching for tiny reset switches.
It does not make the controller magically recoverable from every failure. The machine performing the update still needs access to the UF2 volume, and broken bootloader firmware would remain a physical problem.
Power is not a key
USB keyboard control begins only after the target has electrical power and initializes USB. A completely shut-down laptop may still require its physical power button.
I designed a sibling power-actuator channel around an externally powered MG90S-class micro servo driven from P0.06 (pwm0, 20 ms period, 1000 µs rest / 2000 µs press pulses):
nRF52 P0.06 PWM --> servo signal
external +5V --> servo V+ (common GND with nRF52)
servo horn --> physical power button
The servo must use its own 5 V supply rather than the nice!nano’s 3.3 V rail, share ground with the controller and have calibrated travel limits so it does not damage or continuously hold the button.
The firmware and host commands support short presses (power tap, default 200 ms), timed holds (power hold) and long-hold resets (power reset, default 8000 ms).
This part is not a finished physical mechanism.
CONFIG_REMOTE_KEYBOARD_POWER_ACTUATOR remains disabled by default (returning -ENOTSUP), and I have no assembled mount or validated geometry.
The keyboard path is a working prototype; cold-power actuation remains the next hardware layer.
Apple Fn is not ordinary Fn
Testing around Apple hardware exposed another boundary.
A normal ZMK layer key, like the local Fn layer on my Cosmos keyboard, does not emit the Apple Fn or Globe behavior expected by some firmware and operating-system shortcuts.
Standard keyboard HID does not fully describe that vendor-specific key.
I added an experimental Apple-only path (CONFIG_REMOTE_KEYBOARD_APPLE_FN_EXPERIMENTAL=y) that sets an Apple-like USB identity (VID 0x05AC, PID 0x024F), maps FN, GLOBE and APPLE_FN to vendor usage 0xFF:0x03, toggles the reserved byte in ZMK’s keyboard HID report and also exposes the standard HID keyboard power key (POWERKEY, 0x07:0x66).
The code exists, but the Apple Fn path is not sufficiently validated for critical recovery automation.
The HID power key is also not equivalent to physically pressing a laptop’s cold-boot button.
The dangerous keyboard
This device is also a security problem.
The current proof-of-concept BLE service disables pairing and bonding (CONFIG_BT_SMP=n, CONFIG_BT_BONDABLE=n) and leaves its command characteristic open to unauthenticated writes.
A nearby party able to discover and connect to "Remote Ctrl" could inject keystrokes, reboot the controller into its bootloader and, if actuation were enabled, request physical power operations.
At a firmware menu or unlock prompt, those capabilities exist below the target operating system’s security controls.
Unattended deployment would require authenticated encrypted BLE, trusted-controller restriction, replay protection, connection ownership, protected macro files and a physical way to disable remote actuation. Passwords or recovery input must not quietly become plaintext macro files or shell history.
Before remote administration
This is not a replacement for SSH-based remote administration. It handles the part of a machine’s lifecycle where SSH cannot yet exist.
The working prototype can inject keys and modifiers, type text, run timed macros and update its own firmware remotely. It cannot see the target screen or know which boot state the target reached. Playback is based on timing and assumptions.
That makes it useful for repeatable known paths and dangerous for ambiguous ones.
The project turns a basic compatibility guarantee, “firmware understands USB keyboards,” into a remote-control primitive that works before any software I control has started.