Hi, I've written a replacement firmware for the STM32F103 keyboard co-processor and thought it might be useful to people here:
https://github.com/casaroli/picocalc-kbd-2
It's a from-scratch implementation in Rust (Embassy), not a fork. It is drop-in compatible: it serves the stock protocol at 0x1F unchanged, so PicoMite, MicroPython and anything else already talking to the keyboard keeps working with no changes at all.
It adds a second protocol at 0x1E, which a host can detect by probing - a NACK means stock firmware. Everything below is on that address only.
What it adds
- Burst key reads. One transaction returns a header plus up to 8 queued events, instead of one event per two-phase transaction with a ~16 ms wait between the phases.
- An attention line on PC10, asserted while events are pending, so the host polls only when there is something to collect. Key-to-host latency measures 695 µs mean, 947 µs worst case.
- Battery and PMU access. A cached AXP2101 summary - charge state, capacity, and battery/VBUS/VSYS voltages - in one 12-byte read, plus a guarded mailbox for arbitrary AXP2101 transfers.
- Audio control: the speaker amplifiers and headphone-jack detection.
- Reflashing over I2C. The co-processor can be put into its ROM bootloader from the host, so no DIP-switch change is needed - useful precisely when the running firmware is what's broken.
- Key injection, so a host can exercise its whole keyboard path (driver, terminal, line editor) from a script with nothing pressed.
Alt+, / Alt+. / Alt+space / Alt+B behave exactly as the stock firmware does, including the step sizes and the LED flash counts, except that the battery flash no longer blocks the scan for two seconds.
Testing
99 host tests. The protocol is a separate, dependency-free crate compiled both into the firmware and into host tests, so most of it is testable without hardware. 23 KB of the 64 KB flash.
Docs: I2C protocol and keymap.
I'm using it with a NuttX port on a Pico Plus 2 W, but nothing in it is NuttX-specific.
Hi, I've written a replacement firmware for the STM32F103 keyboard co-processor and thought it might be useful to people here:
https://github.com/casaroli/picocalc-kbd-2
It's a from-scratch implementation in Rust (Embassy), not a fork. It is drop-in compatible: it serves the stock protocol at
0x1Funchanged, so PicoMite, MicroPython and anything else already talking to the keyboard keeps working with no changes at all.It adds a second protocol at
0x1E, which a host can detect by probing - a NACK means stock firmware. Everything below is on that address only.What it adds
Alt+
,/ Alt+./ Alt+space / Alt+B behave exactly as the stock firmware does, including the step sizes and the LED flash counts, except that the battery flash no longer blocks the scan for two seconds.Testing
99 host tests. The protocol is a separate, dependency-free crate compiled both into the firmware and into host tests, so most of it is testable without hardware. 23 KB of the 64 KB flash.
Docs: I2C protocol and keymap.
I'm using it with a NuttX port on a Pico Plus 2 W, but nothing in it is NuttX-specific.