Keyboard stuck in Bootloader mode

I have managed to get the keyboard working (at least with my computer, haven’t tested it with DevTerm yet).

Here’s what I did:

  1. Connected to the keyboard via ST-Link using the flat cable connector (see pinout above, you’ll need only SWCLK, SWDIO and nRST ones. In case your ST-Link needs VTRef, connect it to any 3.3V source.)
  2. I noticed that the SWD frequency should not exceed 100kHz for it all to work reliably. Also, only ST-Link v2 worked for me for some reason, but not v3.
  3. Installed the SM32Duino core as hinted at here.
  4. Cloned the STM32Duino bootloader source code. It seems to be the bootloader that was used originally.
  5. Modified config.h with the following:
diff --git a/config.h b/config.h
index b377f98..f8ce81a 100644
--- a/config.h
+++ b/config.h
@@ -156,7 +156,7 @@
 // Use Boot1 PB2 as the button, as hardly anyone uses this pin as GPIO
 // Need to set the button input mode to just CR_INPUT and not CR_INPUT_PU_PD because the external pullup on the jumplink is very weak
        #define BUTTON_INPUT_MODE       CR_INPUT
-    #define BUTTON_BANK GPIOB
+    #define BUTTON_BANK GPIOD
     #define BUTTON_PIN 2
     #define BUTTON_PRESSED_STATE 1

Reasoning for the change: the state of the BUTTON determines whether the bootloader will jump to the user code or wait indefinitely.
6. Compiled the bootloader: make generic-pc13 (where pc13 stands for the pin with the LED). Important: you should use the gcc version that was installed with the STM32duino core.
7. Used STM32CubeProgrammer to flash the resulting *.bin file to the keyboard.
8. Set the switch labeled “2” to the “ON” position. The keyboard should load to the DFU mode after reset, the green LED will be blinking.
9. Compiled the stock keyboard firmware or the custom one. Do not use the binaries that are provided with the stock firmware, they already contain the bootloader inside them.
10. Flashed the firmware with dfu-util: dfu-util -a 2 -D devterm_keyboard.ino.bin
11. Set the switch back to the “OFF” position and restarted the keyboard. The green LED flashed for a bit and then turned off, and the keyboard was functional.

I did not perform any deep analysis of the source code, so I’m not sure whether if this is a correct solution and I have no idea if the second switch is used in the keyboard firmware at all. But it worked for me.

UPD: It is working with DevTerm as well.

3 Likes