Wednesday, June 13, 2018

TMK with ChibiOS

Setting up the build environment

I usually compile my firmware in Linux. I use either Ubuntu in a virtual machine or Raspbian on a Raspberry Pi. They are both Debian based and the same procedure should work on either.

Start with a fresh install of the OS.

Then update the list of software packages.

sudo apt-get update

Update all the installed packages.

sudo apt-get upgrade

Install the required packages for compiling TMK and ChibiOS

sudo apt-get install gcc-avr avr-libc dfu-programmer git make gcc-arm-none-eabi

Clone the TMK repository

git clone

Change to the chibios folder

cd tmk_keyboard/tmk_core/tool/chibios/

Clone the stable branch of ChibiOS repo

git clone -b stable_17.6.x

Clone the ChibiOS-Contrib repo

git clone

That's it. You should be able to compile for TeensyLC, Teensy3.2, Maple Mini, etc...

This video goes through the process on Ubuntu 18.04 LTS server.

Monday, June 11, 2018

Praetorian Gherkin

Dark and silent

Red Gherkin plates and black PCB. Cherry silent black switches.
Black nylon M2 spacers. Oxide black screws.
Cheap translucent blank red ABS keycaps from eBay.
Funko Pop bobble head.

Wednesday, June 6, 2018

Dressing up cheap M2 spacers

M3 nylon spacers fit over M2 spacers

Non-threaded M3 nylon spacers have a 3.2 mm inner diameter (ID) that fits over the cheap brass M2 threaded spacers. They come in two outer diameters (OD), 5mm and 7mm. The 7mm ones are most common but are probably too large for most uses. The 5mm OD ones are perfect for hiding the skinny brass spacers.

They are sold on eBay and Aliexpress. They come in all the same lengths as the brass spacers. Amazon has some but they are in kits of mixed sizes, many too short or too long to be useful.

Since they are made of nylon they should dye very well.

These are much sturdier than regular all nylon threaded spacers, when combined with a brass spacer. You can tighten them much more as the brass spacer's threads won't easily strip.

5mm OD M3 nylon spacer next to a M2 threaded brass spacer.

M3 spacer on top of the M2 spacer. It fits well but is not snug. It will fall off if you flip the board over while assembling.

Installed and screwed in place. The raw nylon is translucent. Could dye them black or some other dark color. I have seen ones that are white nylon (more opaque) and some in black nylon.

8mm long 5mm OD spacers on a Dilly with plates.

Monday, June 4, 2018


The Golbat 40% Keyboard

I purchased this as a kit from a GB from several years ago. Blue anodized top and bottom plate with light blue clear laser cut acrylic middle pieces.

It was shipped with the case pieces assembled but the screws all worked themselves loose and scratched up everything. Several deep scratches on the top and bottom plates.

I decided to experiment with it. I sanded down the pieces and it blended in the scratches to be less noticeable. I also sanded down the two acrylic pieces so they would be flush together.

Switches are Zealios, with blue 2x3x4mm LEDs mounted inside the switches.

The keycaps are PBT Gaterons from another group buy.

The controller is a Kimera Core. It is an ATmega32U4 with two io expanders. Somewhat pointless to use this in a board with so few columns/rows. It adds complexity to the design and many people have problems figuring out how to program it.

Friday, June 1, 2018


Maple Mini powered modular 5x5 keypad

Up to 9 of the 5x5x9 boards can be connected together to create a 15x15 matrix with 225 key positions.

The board is constructed in a similar way to the 5x5 board, except it also has connections vertically, allowing for three rows of boards, three columns wide. Each individual board is 95.25mm square.

A Maple Mini clone was used as the controller. It has 34 IO pins. 2 of these pins are actually the USB port data pins. So if you want USB there are only 32 pins left. One of these pins is connected to an LED on the top of the Maple Mini, and has no physical pin to solder to. This leaves 31 actual usable pins. This is enough for the 15x15 grid. The onboard LED is used as a capslock indicator.

Maple Mini clones can be found on eBay or Aliexpress for around $4. As cheap as a Pro Micro clone. You will probably find 2 different boards being called Maple Mini, you want the one that looks like the one pictured. The other board has a similar chip but has a different pinout and less flash memory. It is often called the "Blue Pill". You do not want the Blue Pill, although it works with TMK it will not work on this board.

The chip on the Maple Mini is supported in TMK using the Chibios library. Be sure to clone a stable branch of the library. The firmware is on github. The keymap is the same as I use on my i75, repeated 3 times.

The assembled 225 key board. A PCB top plate has been used. The Gerber files are on github.

The bottom of the assembled board. The routing of the board edges is not perfect and they do not align perfectly. Getting the 9 PCBs aligned and soldered as straight as possible was very time consuming. You need a large flat workspace.

The Maple Mini clone and the BUT1 and RESET buttons on the right. The Serial programming header and the BOOT1 switch on the left. I chose these switches because they are available from and you can get free shipping when combined with a PCB order from

To boot into the serial bootloader BOOT1 has to be held low. The switch connects it to ground. In normal use the switch in the other position disconnects it from ground and that pin is used as a part of the switch matrix.

The BUT1 and RESET switches have the same function as the switches on the top of the Maple Mini. I added them to make it easier to enter the bootloader with the board mounted to a plate.

To enter the bootloader:
  1. Disconnect the Maple Mini from USB
  2. Connect a 3.3v TTL serial adapter to the serial header. It must be 3.3v and not 5v. The Maple Mini will be powered through the Serial adapter.
  3. Switch BOOT1 switch to programming position, (to the left in this picture).
  4. Press both RESET and BUT1, you can use the buttons on the Maple Mini or the ones on the board.
  5. While continuing to hold BUT1, release RESET.
  6. Release BUT1
  7. It should now be in serial bootloader. 
To program it I used the utility from STMicro. Flasher-STM32. You will need to register to download it. The program is very simple and you only need to choose the serial port of your serial adapter. The defaults for all other options are fine. The Maple Mini must be in serial bootloader mode before trying to connect. If it errors it is either the wrong serial port or the TX/RX pins are swapped when you connected to the header on the board. (If BOOT1 switch is in the wrong position it will also error. It goes into some other boot mode.)

I am not sure what USB bootloader came installed on the Maple Mini clone. To get anything to work properly I flashed the original Maple Mini Bootloader from here.

Scroll to the Setup section Step 1 and download the Maple Mini bootloader.

I flashed the bootloader and then the compiled firmware, no need to reset in between. You will have to change the file type to BIN for the bootloader and then to HEX for the compiled TMK firmware.

I was hoping to omit the USB bootloader since it takes up flash space (the serial bootloader is hard coded and permanent). But the firmware would not run without the bootloader. It should be possible, I have not spent the time to figure out what needs to be changed in the firmware code to make it work that way.

Be sure to return BOOT1 switch to the normal position before plugging in the Maple Mini USB. Otherwise you will have stuck key presses.

There are multiple ways to flash from the command line using many different methods. I have not tried any of these. The Flash-STM32 download also comes with the source code if you want to develop your own method of flashing.

This was the first version of the board. The BUT1 button was incorrectly connected, Otherwise it works fine. You can see all the solder bridges that hold the boards together and connect the matrix circuits.

The base is a simple 12x12" 5052 aluminum plate with holes drilled for the M2 spacers. It is slightly oversize as the assembled board itself is 11.25" square.

Some of the theoretically possible ways the boards can be connected together and the matrix still work. The Maple Mini has to be in the top left position in all cases.

Monday, May 28, 2018

U2F One Key

MX U2F authenticator

My attempt to build a U2F key based on the design and firmware of the U2F Zero.

It mostly works, but I did not add a debug header so can only program it via the factory USB bootloader, which limits the size of the firmware. I can only load a stripped down version of the firmware.

The basic circuit is the same as the U2F. The microcontroller needs very few external parts to work.

I used 3 separate LEDs instead of the single RGB LED on the U2F Zero. The MX switch footpad allows the board to be flipped and the switch mounted on either side. I can have the ICs exposed on top or hidden under the board.

These PCB's were produced at This was during their $5 promotion. The promotion has since ended, but for small orders they have the cheapest DHL shipping.

Thursday, May 24, 2018

Micro Strong

Another ATmega32U4 breakout board

You can find these on eBay and Aliexpress for quite cheap. Search for "ATmega32u4 board". This seems to be the same circuitry as an Arduino Micro, but not having the schematic, this is only a guess.

The ones I ordered came with the headers loose in the bag. I was not planning to use them. (There are a few extra 12 pin headers from a Pro Micro in the picture)

The board is a square, 4cm on a side. The Micro USB connector is the stronger type that has legs that go through the PCB. There are 3mm diameter mount holes in each corner (34mm centers).

These would be a good choice for a hand wired board. Lots of power and ground connectors and built in mount points.

The bottom is mostly flat. There is a solder bridge jumper to select the voltage. I have seen 8MHz versions for sale. I assume those are jumpered for 3.3v.

The website printed on the back loads a broken Chinese webpage.

24 of the ATmega32U4 pins are easily accessible (just like on an Arduino Micro). Some are connected to LEDs (C7, B0). Pins D5 and E2 can be accessed on the large ATmega32U4. D5 should be usable as an output. E2 is connected to ground through a 10k resistor so should also be usable as an output.

Monday, May 21, 2018


GNAP! Gherkin hybrid

It's the top three rows of the GNAP! constructed like a Gherkin.

It has a regular PWM backlight like the Gherkin does, powered by a MOSFET connected to pin B5.

Still working on a keymap. I have a basic one for testing on github.

Gerber files on github.

Assembled with cheap typewriter style keycaps.

Bottom is a second PCB, just like on the Gherkin.

Top and bottom PCBs are connected with M2 spacers and screws.

The Pro Micro sticks out the side.

Top of a fully populated PCB. 1n4148 diodes and resistors for the backlight.

Bottom of PCB. You can see the MOSFET and the reset switch. A socket makes the Pro Micro removable. All of the parts used are the same as on the Gherkin, there are just 6 more of them for the 6 additional switches.

The 2 unused pins are broken out to pads along with GND and VCC.

Backlight on. It has a single dimmable backlight, It does not have the per key backlighting of the GNAP!.

Wednesday, May 16, 2018

Micro Repair

Fixed a dead Arduino Micro Clone

One of the three pack of Arduino Micro clones I purchased was DOA. I could program it via ISP but it was never recognized over USB.

Upon close inspection two sides of the AtMega32U4 looked to have bad solder connections.

 This side doesn't look too bad, but they are the pins that are the USB data pins look a little funny.

There are three pins on this side that don't have any solder at all.

I used a lot of liquid flux and added a tiny amount of solder and rolled it across the pins. Much like in this video, but I used liquid flux which is much messier.

All pins are now connected with an even amount of solder. I touched up the solder on all four sides.

The Arduino Micro clone now works like it should.

Monday, May 14, 2018


Contra Pi Zero W

Contra keyboard with a Pi Zero W embedded.

 Contraption connected to a mini LCD monitor with a mini HDMI cable. It is running asciiquarium.
The ports on the back of the PI Zero W are accessible. Power is the micro USB connector on the right. The normal USB connector is plugged and not used. Mini HDMI connector on the left.

Ports with cables unplugged. Space between the PCB and bottom plate is 6.4mm. A 6mm standoff with two 0.2mm washers.

Bottom plate is unchanged.

The Pro Micro is rotated. This allows the connector to not stick out the side.

Closeup of the Pi Zero W.

Bottom of the Pi Zero W. The wires are soldered to the test pads for the onboard USB port. This is the same port as the external one, so it can't be used at the same time. 3M VHB heavy duty double stick tape holds the Pi Zero W in place on the bottom plate.

Close up of the rotated Pro Micro. Some of the pins have to be jumpered to connect the remaining columns, also the RESET pin and ground to retain the functionality of the RESET switch.

cols B5  B4  F4  F5  F6  F7  B1  B3  B2  B6  D7  C6
rows E6  D4  D0  D1

Modified TMK firmware is on github.