keybrain
keybrain copied to clipboard
Hey Fellow WASD tinkerer
It's really cool to see a simple keyboard FW implemented in rust, that is pretty amazing level of functionality with so little code. Mad respect.
I did a similar project but used QMK and a Teensie:
- https://hackaday.io/project/171323-circuit-bending-wasd-keyboard
I saw your project when I was trying not to design my own board, actually! You linked to the WASDat, which I was really excited about until I realized it's neither open source nor available for purchase, so I had to re-reverse-engineer the mechanical layout and spacing. (Disappointment with WASDat is a lot of why I published this.)
Your wiring is very neat, nice work. :-)
I was looking at QMK and came across the WASDat hardware target. If only the HW were also open!
@cbiffle Out of sheer curiosity what references did you use to get USB/HID and DFU compatibility implemented in rust?
Looking at stuff like this:
- https://github.com/cbiffle/keybrain/blob/master/fw/src/main.rs#L32
- https://github.com/cbiffle/keybrain/blob/master/fw/src/main.rs#L58
- https://github.com/cbiffle/keybrain/blob/master/fw/memory.x
- and https://github.com/cbiffle/keybrain/blob/master/fw/asm/farjmp.S
Also are there any good sources to start on embedded rust journey? Besides your website =]
I was looking at QMK and came across the WASDat hardware target. If only the HW were also open!
@dhiltonp - or even available for purchase! But it looks like it was a one-time group buy. Which is okay in the end, I don't love 8-bit processors anyway. The information in this repo should enable someone to make a QMK-compatible system if desired. (QMK might even run on this hardware already! I have no idea.)
Out of sheer curiosity what references did you use to get USB/HID and DFU compatibility implemented in rust?
@NonLogicalDev - so there's a stack of potential answers to that question. :-)
In terms of starting the journey, the Rust Embedded Book is a good place to start. It will give you enough information to get up to the "blinking an LED" point. There are some nice frameworks and stuff available in the Rust ecosystem, none of which I use, because I apparently like to make my life difficult?
The system init code, linker script, etc. that you linked is the result of past experience with the stm32 series and a large quantity of trial and error while staring at the ST reference manual. Referring to the ChromeOS embedded controller STM32L4 port also helped (though it's in C).
Same with the USB driver. This is my first USB project, so I spent a lot of time staring at:
- The USB controller chapter in the STM32L4 Reference Manual
- USB in a Nutshell was a great intro to the protocol stack and terms
- The USB 2.0 spec (though you have to squint and ignore the high-speed parts)
- The USB HID spec when I got that far
- Logic analyzer traces captured with my Saleae Logic, of both my code misbehaving, and the factory controller behaving better.
The DFU support is, uh, weird. That code is not implementing USB DFU per se, it's jumping into the ST ROM bootloader, which itself can do DFU. Arguably a hack, but a very convenient one. So as a result, I actually have no idea how USB DFU works on the wire -- I just know that if I b 0x1fff0000 with the right context the ROM will do it for me. (I decided to implement this at the last minute after noticing that a freshly built board showed up as a USB device, because the ROM couldn't find any firmware in Flash.)