A truly modular keyboard
C
journal: oct 25-28, SWIO dock flashing, chain fixes, next keybit ideas
Nathanf24bc6f9515b
diff --git a/JOURNAL.md b/JOURNAL.mdindex a7f92f9..088bd4b 100644--- a/JOURNAL.md+++ b/JOURNAL.md@@ -2,6 +2,109 @@This journal is auto generated by Stasis.-->+# 10/28/2026 11 PM - Flashing Keybits and Chaining Them++_Time spent: 6h_++So I still couldnt get the keyword to flash the keybits over SWIO, and I wasnt sure if the chips on my keybits were fried or if the driver was wrong, so I got some CH32V003 dev boards off amazon to test with. Turns out it was the driver. The firmware builds with -Og so the delay functions never got inlined and every pulse came out about 15 cycles too long, which made a 1 look almost like a 0. After fixing that I shorted the SWIO stud to ground to make sure the keyword could actually see the line and then it finally started detecting the chip (blue then red lol).++After that it was a long list of problems:++- the halt command was resending the link setup commands which cut the link every time+- reads were fine but only like 1 in 4 writes actually landed, so writes needed their own short pulse timing+- around 1 in 100 messages still got garbled (probably from me holding the board by hand) so I made it verify every write, retry, and resume from the last good block instead of starting over++and then it flashed the whole 6.4KB keybit firmware and read it back as a match!! I also got it working without the 1k pull up on SWIO by driving the line push pull and reading the answer a bit later. Now it blinks blue while flashing, green once when its done or already up to date, and red only when it gives up.++A big bag of switches also came in today so I can actually build more keybits++++Then the sides werent detecting anything. The keyword talks to the sides with hardware I2C at 100kHz but the keybits bit bang their I2C while also watching their other 3 sides so they couldnt keep up, dropping it to 20kHz fixed that and I got the white blinks for a keybit joining. A second later the bus would lock up though, because a keybit that hadnt been addressed in 2 seconds would pull the clock low to check if that side was another keybit, which jammed the keyword's bus (fixed in v7). After that:++- the I2C timeouts were 10ms but reading a chained keybit at 20kHz takes about 19ms+- the dock was blocking side polling for seconds while it flashed so keys kept connecting and disconnecting, now it flashes 2 blocks at a time+- the watchdog was firing during long flashes and resetting the keyword+- keybits were locking a side as the keyword's side forever (v8), giving up link requests too early (v9), and the probe timing could get stuck when the SysTick timer rolled over (v10)++++Another problem is that sometimes when I put a board on the wrong way the whole keyword turns off and drops off USB. Docking it backwards shorts or drags down the 3.3V, and I even got a brownout reset with a board on the right way. So for the next revision I want a current limited load switch on the dock and side 3.3V, ~100 ohm series resistors on SWIO and the I2C lines, and some way to key the dock so a board only goes on one way. Also since all 3 sides share 1 bus the keyword cant tell a rotated keybit on the top from one on the left, so a sense line per side would fix that.++It also detects when a keybit is next to another one backwards now and blinks red twice++++But by the end I had 3 keybits chained off the keyword in a row and all of them showing up in the app!!++++++I also made the app draw the chained keybits on the board view so you can see where each one is++++# 10/27/2026 10 PM - Ideas for the Next Keybit++_Time spent: 4h_++So the current keybit only works in a straight grid and the pogo headers are like half the cost, so I spent today thinking about how to make the next version better.++The first idea was a 2 wire system where power and data both go through 2 terminals so keys can be staggered. I got the idea from my 6.2020 lab where you AC couple a signal through a cap, so the data would go through a cap onto the DC power line and then a bridge rectifier at the other end gets the power back.++++It turns out its doable but it needs a MOSFET bridge instead of diodes (a 0.6V drop at every key would kill the power a few keys out), a small choke so the bulk cap doesnt short out the data, and the data has to be sent as a 2MHz carrier.++Then for the stagger, if the contacts are on a 2.38mm grid (19.05 / 8) a key can slide along another one and snap every 25%, which covers every normal ANSI/ISO stagger since those are all multiples of a quarter key (37.5% isnt really a thing). If every contact is a magnet on a pogo pin with the poles going N S N S clockwise on every side, then at every quarter step N lands on S and pulls, halfway between N lands on N and pushes it to the next step, and it still works when you rotate a key 90 degrees. I was looking at these 1mm x 2mm magnets from JC magnetics for it++++The small magnets are about 3-5x weaker than the J7 ones though, so I would add a second row of bigger block magnets just for holding, and maybe a tongue and groove lip so a row doesnt fold when you pick it up.++The other idea is making the keybit a flex pcb with 4 flaps that have pads for the pogo pins. I solder the pogos on, fold the flaps up into a box and slide it into the case, and the case holds the switch. That gets rid of the right angle pogo headers which are the most expensive part. I priced out 5 panels of 5x5 flex boards with the CH32 assembled on JLC and it came out to about $1.49 a board. I also looked at hot swap sockets but the Kailh one is about 0.8mm too wide to fit, so it would have to be the Mill-Max cups.++I also noticed that if a keybit is plugged into another keybit backwards nothing tells you, so now the keybit firmware (v6) flags a side thats held low as backwards and the keyword sends that to the app.++And I rewrote the desktop app in typescript with react and tailwind and installed it as an app on my mac, and cleaned up the firmware folder so the keyword's CubeMX project is in its own folder next to the keybit one.++++# 10/26/2026 6 PM - Keyword Flashed and Bluetooth++_Time spent: 5h_++So it turns out the STLINK V3SET was the problem the whole time (it didnt work on Ember either), so I got out an old STLINK V2 and it connected right away lol++++The chip was fine and already booting from flash with no read protection, so I installed the bluetooth stack (1.24.0) and flashed the OTA bootloader with the app. At first nothing ran because I only flashed the app, which lives at 0x08007000 behind the bootloader, so I had to flash the full image at 0x08000000. Then it showed up as "Keyword" in bluetooth with the green LED!! I flashed the second keyword the same way.++Then I tried updating it over bluetooth from the app and it failed because 131 packets in a row went missing on mac, so now it waits 20ms between packets and OTA works. I also added a DFU command so I can get into the USB bootloader from software since BOOT0 isnt connected to anything. The battery also says 87% with no battery plugged in because the charger keeps the empty battery pin at the charge voltage lol++++The dock still couldnt see a keybit though, every read came back as all 1s so the keybit was never pulling the line low. I found a blog post where someone reverse engineered the CH32V003 debug protocol and changed the reset pulse to 2ms but it still didnt answer.++I was also worried about what happens when you put a keybit on rotated. It probably wont kill the CH32 right away but it pushes something like 30-50mA through the clamp diode on SCL (rated for 4mA) and jams the whole bus, so now the keybit wont touch a side that looks reversed and the keyword stops polling and blinks red if SDA gets stuck low.++# 10/25/2026 11 PM - SWIO, Bluetooth and Not Being Able to Flash++_Time spent: 6h_++Now that it worked I wanted the keyword to be able to flash the keybits by itself. The keyword has 3 studs on top (3.3V, SWIO, GND) that line up with the pads on the bottom of a keybit, so a keybit sitting on top gets powered and its SWIO pin lands on PB5. So I wrote a driver that bit bangs WCH's one wire debug protocol on PB5 (a short low pulse is a 1 and a long one is a 0) and a keybit firmware that bit bangs I2C on all 4 sides, and the keybit image gets embedded in the keyword firmware so it can flash any keybit put on top.++For addressing I was originally gonna have every key pick a random I2C address and check if its taken, but instead the keyword reads each CH32's unique 96 bit ID and hands it an address, and the keybit says which of its sides got addressed so the keyword knows if its on the left, right or top. Keybits that arent touching the keyword pass their presses inward through the other keybits. I also changed the keybit to keybit links to a custom protocol where a keybit with a key press rings a doorbell on the data line and then the data gets sent push pull like half duplex SPI, so it doesnt have to wait for the next poll.++I also added the bluetooth stack and a BLE keyboard to the keyword and started a desktop app that connects over USB or bluetooth, shows which side keys are on and lets me map any key to any key, shortcut, macro or media key with profiles.++Then I spent most of the night trying to flash the keyword over SWD and it would not connect. I had the wires on the wrong header of the STLINK at first, then soldered wires on, swapped DIO and CLK, soldered NRST, held BOOT0 high, tried an Atmel-ICE, and even thought SWCLK was shorted to ground but that was just my multimeter probe touching the ground pad. I also tried going through USB DFU instead and the FUS step changed the option bytes, so now it doesnt go into DFU from the BOOT0 pin anymore aaaa++++I also looked at batteries, only a 10-15mAh one fits inside the keyword, but if it sits on top theres room for an 80-130mAh one.+# 10/24/2026 9 PM - It Finally Works!!_Time spent: 4h_@@ -20,12 +123,20 @@ and here is the demo[](assets/demo.mp4)+[](assets/journal/keybit_keyword_table.mp4)++Later that night I also posted it on r/MechanicalKeyboards+++# 10/23/2026 10 PM - Gluing Magnets and Picking a Joint_Time spent: 5h_So I started gluing the magnets in with gorilla super glue gel (from the inside so it doesnt get on the faces) and when I put two J7 keybits together they tilted up a little. I thought I had to sand it but it turned out that glue had gotten onto the outside face of some magnets so they werent flat, after scraping it off with a razor the tilt went away. Btw acetone doesnt hurt the magnets but it does wreck the resin so dont get it on the case.+[](assets/journal/j7_cases_magnets.mp4)+J7 was the one I liked the most so I made it the main keybit case.diff --git a/assets/journal/app_backwards.jpeg b/assets/journal/app_backwards.jpegnew file mode 100644index 0000000..334dff4Binary files /dev/null and b/assets/journal/app_backwards.jpeg differdiff --git a/assets/journal/app_board_chained.png b/assets/journal/app_board_chained.pngnew file mode 100644index 0000000..cc1c334Binary files /dev/null and b/assets/journal/app_board_chained.png differdiff --git a/assets/journal/app_firmware_battery.jpeg b/assets/journal/app_firmware_battery.jpegnew file mode 100644index 0000000..826521eBinary files /dev/null and b/assets/journal/app_firmware_battery.jpeg differdiff --git a/assets/journal/app_keybit_pcb.jpeg b/assets/journal/app_keybit_pcb.jpegnew file mode 100644index 0000000..12ef70dBinary files /dev/null and b/assets/journal/app_keybit_pcb.jpeg differdiff --git a/assets/journal/app_side_flapping.jpeg b/assets/journal/app_side_flapping.jpegnew file mode 100644index 0000000..847afd1Binary files /dev/null and b/assets/journal/app_side_flapping.jpeg differdiff --git a/assets/journal/app_three_hops.jpeg b/assets/journal/app_three_hops.jpegnew file mode 100644index 0000000..59f8e2bBinary files /dev/null and b/assets/journal/app_three_hops.jpeg differdiff --git a/assets/journal/j7_cases_magnets.jpeg b/assets/journal/j7_cases_magnets.jpegnew file mode 100644index 0000000..163dea8Binary files /dev/null and b/assets/journal/j7_cases_magnets.jpeg differdiff --git a/assets/journal/j7_cases_magnets.mp4 b/assets/journal/j7_cases_magnets.mp4new file mode 100644index 0000000..e0201ebBinary files /dev/null and b/assets/journal/j7_cases_magnets.mp4 differdiff --git a/assets/journal/jc_magnetics_1x2.jpeg b/assets/journal/jc_magnetics_1x2.jpegnew file mode 100644index 0000000..1778b44Binary files /dev/null and b/assets/journal/jc_magnetics_1x2.jpeg differdiff --git a/assets/journal/keybit_keyword_table.jpeg b/assets/journal/keybit_keyword_table.jpegnew file mode 100644index 0000000..296c8efBinary files /dev/null and b/assets/journal/keybit_keyword_table.jpeg differdiff --git a/assets/journal/keybit_keyword_table.mp4 b/assets/journal/keybit_keyword_table.mp4new file mode 100644index 0000000..685310cBinary files /dev/null and b/assets/journal/keybit_keyword_table.mp4 differdiff --git a/assets/journal/keyword_swd_wires.jpeg b/assets/journal/keyword_swd_wires.jpegnew file mode 100644index 0000000..5549ac0Binary files /dev/null and b/assets/journal/keyword_swd_wires.jpeg differdiff --git a/assets/journal/rc_coupling_lab.jpeg b/assets/journal/rc_coupling_lab.jpegnew file mode 100644index 0000000..dad0cf8Binary files /dev/null and b/assets/journal/rc_coupling_lab.jpeg differdiff --git a/assets/journal/reddit_post.jpeg b/assets/journal/reddit_post.jpegnew file mode 100644index 0000000..f7b8c16Binary files /dev/null and b/assets/journal/reddit_post.jpeg differdiff --git a/assets/journal/stlink_v2_flashing.jpeg b/assets/journal/stlink_v2_flashing.jpegnew file mode 100644index 0000000..0aa65d3Binary files /dev/null and b/assets/journal/stlink_v2_flashing.jpeg differdiff --git a/assets/journal/switches_came.jpeg b/assets/journal/switches_came.jpegnew file mode 100644index 0000000..a87379fBinary files /dev/null and b/assets/journal/switches_came.jpeg differdiff --git a/assets/journal/three_keybits_chained.jpeg b/assets/journal/three_keybits_chained.jpegnew file mode 100644index 0000000..ea36ac4Binary files /dev/null and b/assets/journal/three_keybits_chained.jpeg differ