Skip to the content
PCBKitNew board
2 layers40 × 40 mmKunlun STM32 MCU Board, the printed circuit board in 3D

Kunlun STM32 MCU Board

project802/kunlun

Technical information about the Kunlun keyboard

Size
40 × 40 mm
Copper layers
2
Thickness
1.6 mm
Parts
40
Nets
58
Pads
158
Tracks, vias
206, 42
Pours
10
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
7 May 2026
Updated
31 Aug 2026

Overview

Kunlun STM32 MCU Board is an open-source printed circuit board by project802, from the project802/kunlun repository on GitHub. It is a 2-layer board of 40 × 40 mm with 40 parts on 58 nets, routed with 206 tracks and 42 vias.

It is built around the STM32F072CBT6, AP2112K-3.3 and USBLC6-2SC6, with the 10129383-908001ALF, SMAJ5.0CA and USB4105-GF-A among its other parts. Its parts include 12 capacitors, 9 connectors, 7 resistors, 3 ICs and 1 diode. It belongs with the keyboards and input and microcontroller boards boards and the STM32 boards of this library.

Main components

6

README

README.md

Kunlun Keyboard Repair and Upgrade

This repository contains documentation for repairing and upgrading the Kunlun keyboard from YDKB / KBDfans.

My Kunlun stopped functioning after one too many ESD strikes approximately 3 years into ownership. The journey to create this documentation started because I wanted to bring my keyboard back to life, and there were no replacement parts.

The failure mode presented as "ghost" key presses. Pressing one key anywhere on the PCB with the failed shift register(s) would register many or all (depending on the duration of the keypress) keys from the same PCB.

As I began the repair, I realized that the design was not something I had seen before, nor was it one commonly seen in the mechanical keyboard community (for good reason, see the section below on shift registers). It is remarkably simple, and therefore remarkably easy to diagnose and repair.

MCU Board Redesign

I have designed a replacement MCU board based on an STM32F072. For more information, see the mcu board redesign folder. Improvements include ESD support, an upgraded processor that allows for enabling all Vial features, and a speaker.

Updated Firmware for Original MCU

During this process, I also ported the original firmware written by YDKB to the latest version of Vial. QMK has grown a lot since Kunlun was introduced, so it required some optimization and feature set choices to be made to fit within the microcontroller constraints.

My port can be found here: https://github.com/project802/vial-qmk

A prebuilt image can be found in the prebuilt binaries folder.

To update the firmware:

  • Rename firmware image to "kunlun.bin".
  • Unplug the keyboard
  • Press and hold the ESC key
  • Plug in keyboard
  • Copy (or drag and drop) the firmware image onto the storage device presented by the keyboard

Keyboard Design

Major Components

Microcontroller - Atmel Mega32U4-AU (datasheet)

A basic 8-bit microcontroller that is commonly seen in keyboards that support QMK. KBDfans used the TQFP44 package and placed it on a small PCB just for the usb interface, power supply, and microcontroller.

Kunlun uses the internal oscillator and only operates at 8 MHz, as VCC is connected to a regulated 3.3V supply and 16 MHz would require > 4.5V.

Shift Registers - 74HC595 (datasheet)

When is a 74HC595 not a 74HC595? When its the one used on this keyboard. Apparently, FM decided to usurp the identifier and make something that is almost the same, but isn't. It uses open drain outputs (instead of push/pull) and also doesn't have either a latch clock nor output enable.

The part is available on LCSC.

This drove almost the entirety of why I went on the reverse engineering journey. The faulty shift registers were replaced with standard parts, and the keyboard had the same failure symptoms. After much head scratching, I figured they had to be open drain outputs and searched Google to find a Facebook post and an EEVblog thread that confirmed my suspicion.

Theory of Operation

The matrix is scanned entirely using only 3 GPIO.

  • PB1 - Serial data clock
  • PB2 - Right PCB input, pull-up enabled
  • PB3 - Left PCB input, pull-up enabled OR serial data

Serial clock and data are sent to the left and right PCB in parallel.

All switches on the right PCB have one side tied to a unique shift register output, and the other to PB2.

All switches on the left PCB have one side tied to a unique shift register output, and the other to PB3 through a 2.2kOhm resistor.

The shift registers on each PCB are run in serial so that shifting the test bit goes through each output sequentially.

Pressing a key acts as a jumper between its corresponding shift register output with the appropriate microcontroller input. If the shift register output is open drain (the bit is set to one), voltage at the microcontroller is not affected and remain logically high. If the shift register output is driven low (the keypress test bit, zero) then it will pull down the appropriate microcontroller input.

Scanning

  • The matrix scan starts with clocking in the keypress test bit, a zero, by driving PB3 low and pulsing the PB1 data clock. PB3 is turned around to an input with pull-up.
  • Both PB2 and PB3 inputs are evaluated for a keypress.
  • The keypress test bit is shifted down one position in the shift register banks by driving PB3 high, pulsing the PB1 clock, then turning PB3 back to an input with pull-up.
  • The loop of evaluate and shift continues until all register outputs have been scanned: the greater of the left (32) and right (40) outputs is 40 iterations.

That's it. It is arguably slower than a typical row/col matrix, but it can still be completed in short order (optimized to approximately 350 microseconds in my port) so it doesn't present any meaningful lag as the USB HID interface runs on a 1 millisecond interval. As a result, the stock and ported firmware restrict the scan rate to no faster than 1 kHz.

Diagnosing a failed board

The photos in this section display the behavior of stock firmware. My ported firmware has different waveforms and sequences.

In my case, the microcontroller appeared to have full function so my focus was on the left and right PCBs.

The right PCB was the closest to where the final ESD strike occurred so that is also where I started checking. There was no visible physical damage, so the first tests were to probe the various pins on the shift registers.

Starting with the first register in the chain, U24, verify inputs on pins 11 (clock) and 14 (data). You should see something similar to below.

Scan Start

The data (yellow trace) can be seen driving low, clocked in, and slowly rising due to the weak pull-up.

Next, check pin 9 to make sure the IC is shifting the bit out and into the next one in the chain. In my case, this was part of the failure mode. It was not outputting anything but low so it was clocking in zeros to the next IC, so on and so forth, causing everything to look like it was pressed at the same time.

Check the outputs of the shift register to make sure they are switching between open drain and driving low. You will need to press a key to connect the output to the pull-up within the micro, otherwise it will look like its driving low the entire time. It isn't! I also had this failure mode where the lines were driving low. It seems my IC had a dead data input internally and was always reading zeros so it latched those to the outputs and shifted it into the next in line.

A key pressed with its shift register output (yellow) and the bit clock (blue) is below.

Good Keypress

Parts

40
QtyValueFootprintReferences
4100nFCapacitor_SMD:C_0603_1608MetricC1, C2, C4, C8
41uFCapacitor_SMD:C_0603_1608MetricC7, C10, C11, C12
45002TestPoint:TestPoint_Keystone_5000-5004_MiniatureJ4, J5, J6, J7
222Resistor_SMD:R_0603_1608MetricR1, R2
24.7uFCapacitor_SMD:C_0603_1608MetricC3, C5
25.1kResistor_SMD:R_0603_1608MetricR4, R5
25001TestPoint:TestPoint_Keystone_5000-5004_MiniatureJ8, J9
10532610671Connector_Molex:Molex_PicoBlade_53261-0671_1x06-1MP_P1.25mm_HorizontalJ1
1100Resistor_SMD:R_0603_1608MetricR7
110129383-908001ALFConnector_PinHeader_2.54mm:PinHeader_2x04_P2.54mm_Vertical_SMDJ2
110kResistor_SMD:R_0603_1608MetricR3
110nFCapacitor_SMD:C_0603_1608MetricC6
11MResistor_SMD:R_1206_3216MetricR6
11nFCapacitor_SMD:C_1206_3216MetricC9
1500mAFuse:Fuse_1206_3216MetricF1
1AP2112K-3.3Package_TO_SOT_SMD:SOT-23-5U2
1KMR231NG ULC LFSButton_Switch_SMD:SW_Push_1P1T_NO_CK_KMR2SW1
1MountingHole_PadMountingHole:MountingHole_2.2mm_M2_PadH1
1SMAJ5.0CADiode_SMD:D_SMAD1
1STM32F072CBT6Package_QFP:LQFP-48_7x7mm_P0.5mmU1
1SolderJumper_3_Bridged12Jumper:SolderJumper-3_P1.3mm_Bridged12_RoundedPad1.0x1.5mmJP1
1SpeakerBuzzer_Beeper:Buzzer_CUI_CPT-9019S-SMTLS1
1USB4105-GF-AConnector_USB:USB_C_Receptacle_GCT_USB4105-xx-A_16P_TopMnt_HorizontalJ3
1USBLC6-2SC6Package_TO_SOT_SMD:SOT-23-6U3

The 37 most common of 40 parts.

Questions

How big is the Kunlun STM32 MCU Board PCB?

It measures 40 × 40 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Kunlun STM32 MCU Board use?

40 parts, built around the STM32F072CBT6, AP2112K-3.3, USBLC6-2SC6 and 10129383-908001ALF. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Kunlun STM32 MCU Board KiCad files?

From the project802/kunlun repository on GitHub, at the commit this page was made from: the board is mcu board redesign/kicad/Kunlun STM32 MCU Board.kicad_pcb and its schematic kicad/Kunlun.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Kunlun STM32 MCU Board design in my own project?

Its repository states no licence, so its author keeps all rights: ask project802 before reusing the design.

Similar boards

  • 2 layers50 × 18 mmMajestouch stm32, the printed circuit board in 3D

    Majestouch stm32

    mbtech-nl/majestouch-stm32

    Drop-in replacement controller for the full-size Filco Majestouch: STM32F072, QMK with NKRO over USB. KiCad 9 board, hand-solderable.

    20 parts2MIT
  • 2 layers51.4 × 39.9 mmClock, the printed circuit board in 3D

    Clock

    FBanna/Clock_pcb

    My Clock CAD files

    136 parts
  • 4 layers49.6 × 40 mmFsoc rx, the printed circuit board in 3D

    Fsoc rx

    SharbelMarshi/txrx-optical-communication-kicad

    A Free-Space Optical Communication link KiCad project

    62 parts1
  • 2 layers25 × 129.5 mmSoily, the printed circuit board in 3D

    Soily

    danstiner/embedded

    +-----------+-----+----------------------+--------------------+------------------------------------------------------------------------+ | Reference | Qty | Value | Part Number | Footprint |…

    54 parts
  • 4 layers78.5 × 55 mmRUDRAKINUXIS Lite, the printed circuit board in 3D

    RUDRAKINUXIS Lite

    RaviKachhwaha/RUDRAKINUXIS-Lite

    It is a high-performance 600W (20V–25.2V 6S) FOC BLDC ESC for UAVs & robotics. Powered by STM32G431 CORDIC MCU, it features 16 AWG wire-reinforced 2oz copper pads for motor/power, an integrated flight controller bus…

    111 parts
  • 4 layers27.9 × 48.3 mmEsp32c3-devkit, the printed circuit board in 3D

    Esp32c3-devkit

    speck0413/ai-native-eda

    Intent-level PCB layout for AI agents

    41 partsMIT
  • 4 layers80 × 80 mmKonoha, the printed circuit board in 3D

    Konoha

    aisuneko/konoha

    4-port USB3.0 pure Type-C Hub powered by CH634X

    97 parts1CERN-OHL-S-2.0
  • 4 layers92.1 × 56.7 mmMAIA, the printed circuit board in 3D

    MAIA

    vrmay23/MAIA

    ADAS for blind dogs!

    124 parts1