MNT Reform Keyboard 4.0 (Standalone) firmware backup/change howto

Hello Folks

My mnt-reform v4 keyboard standalone arrived.
I noticed that there isn’t an insert key and I want to change the left ctrl for the hyper key.

And I would like to change the rgb backlight color but this isn’t top priority.

MNT Reform Standalone Keyboard Manual (V4)

This manual has only a few details about the v4 keyboard

I found the gitlab repo and clone it:

git clone https://source.mnt.re/reform/reform.git
cd reform2-keyboard4-fw
# the README.md file has only instructions to build but I don't understand how to make the changes ?

Where can I find information about which packages do I need to backup the current firmware. I’m using GNU/linux :stuck_out_tongue:
The mnt-reform v4 keyboard standalone has an option called “usb flashing mode”. is this the option for flashing in this model ?

How can I help with the documentation ? I would like to learn how to modify a few keys and help with the README.md

Thanks

The reform-standalone-keyboard-v4.pdf makes reference to the v4 path but there is not any instructions for the packages need it to flash it.

While exploring the Reform git repository, I found a README.md file for the reform2-keyboard-fw repository

cd ~/mnt-keyboard4/reform
git branch --show-current
echo "##############"
exa . | rg 2-keyboard

results:

master
##############
reform2-keyboard-case
reform2-keyboard-editor
reform2-keyboard-fw
reform2-keyboard-lettering
reform2-keyboard-pcb
reform2-keyboard3-pcb
reform2-keyboard4-fw
reform2-keyboard4-pcb
cd ~/mnt-keyboard4/reform
git branch --show-current
echo "##############"
batcat -p reform2-keyboard-fw/README.md

results:

master
##############
# MNT Reform 2.0 Keyboard Firmware

## Code Structure

- `constants.h`: Define which keyboard variant you want to build for
- `keyboard.c`: Main entrypoint that includes the chosen matrix file (keyboard layout)
- `matrix.h`: Keyboard layout definition (default)
- `matrix_*.h`: Alternative layouts
- `backlight.c`: Keyboard backlight control
- `menu.c`: OLED Menu handling
- `oled.c`: OLED graphics control
- `remote.c`: Communication with MNT Reform motherboard LPC
- `hid_report.c`: USB HID raw report handler (commands sent by OS)
- `powersave.c`: Low power/sleep mode
- `descriptors.c`: USB HID descriptors
- `i2c.c`: Soft I2C master implementation (for OLED)
- `serial.c`: Soft UART implementation
- `font.c`: Bitmap data for OLED font and icons

## Dependencies

### Debian/Ubuntu

apt install gcc-avr avr-libc dfu-programmer

## Hacking

To change the keyboard layout, adjust the `matrix` arrays in `keyboard.c`.

## Building

Build the firmware by running `make`. The firmware can then be found in
keyboard.hex. To build for the different layouts of the MNT Reform keyboards 2
or 3, define the `KBD_VARIANT_2` or `KBD_VARIANT_3` preprocessor variables,
respectively, using the `REFORM_KBD_OPTIONS` argument to `make`.

    make REFORM_KBD_OPTIONS=-DKBD_VARIANT_2_US # default for keyboard 2.0 (US)
    make REFORM_KBD_OPTIONS=-DKBD_VARIANT_2    # default for keyboard 2.0 (non-US)
    make REFORM_KBD_OPTIONS=-DKBD_VARIANT_3_US # keyboard 3.0 layout (US)
    make REFORM_KBD_OPTIONS=-DKBD_VARIANT_3    # keyboard 3.0 layout (non-US)

Without any options, `KBD_VARIANT_2` is the default. To build for the
standalone keyboard for, define `KBD_MODE_STANDALONE` using
`REFORM_KBD_OPTIONS` like this:

    make REFORM_KBD_OPTIONS="-DKBD_VARIANT_2_US -DKBD_MODE_STANDALONE"
    make REFORM_KBD_OPTIONS="-DKBD_VARIANT_2 -DKBD_MODE_STANDALONE"
    make REFORM_KBD_OPTIONS="-DKBD_VARIANT_3_US -DKBD_MODE_STANDALONE"
    make REFORM_KBD_OPTIONS="-DKBD_VARIANT_3 -DKBD_MODE_STANDALONE"

For keyboard 3 there is also an option to swap Ctrl- and Hyper-Keys: `KBD_SWP_CTRL`.

To flash, put your keyboard into [flashing mode](https://mntre.com/reform2/handbook/parts.html#keyboard-firmware) and run:
`sudo ./flash.sh`
cd ~/mnt-keyboard4/reform
git branch --show-current
echo "##############"
apt show gcc-avr avr-libc dfu-programmer
# apt install -y gcc-avr avr-libc dfu-programmer

results:

master
##############
Package: gcc-avr
Version: 1:5.4.0+Atmel3.6.2-3
Priority: extra
Section: universe/devel
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Hakan Ardo <hakan@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 71.9 MB
Provides: c-compiler-avr
Depends: libc6 (>= 2.34), libgmp10, libmpc3 (>= 1.1.0), libmpfr6 (>= 3.1.3), zlib1g (>= 1:1.1.4), binutils-avr (>= 2.26.20160125+Atmel3.6.2)
Suggests: gcc-doc (>= 4:4.8), gcc (>= 4:4.8), avr-libc (>= 1:2.0.0+Atmel3.6.2)
Conflicts: avr-libc (<= 1:1.7.1-2)
Download-Size: 17.2 MB
APT-Sources: http://apt.pop-os.org/ubuntu jammy/universe amd64 Packages
Description: GNU C compiler (cross compiler for avr)
 This is the GNU C compiler, a fairly portable optimizing compiler which
 supports multiple languages.  This package includes support for C.

Package: avr-libc
Version: 1:2.0.0+Atmel3.6.2-3
Priority: extra
Section: universe/otherosfs
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Hakan Ardo <hakan@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 44.6 MB
Depends: gcc-avr (>= 5.4.0+Atmel3.6.2-1), binutils-avr (>= 2.26.20160125+Atmel3.6.2-1)
Download-Size: 4,859 kB
APT-Sources: http://apt.pop-os.org/ubuntu jammy/universe amd64 Packages
Description: Standard C library for Atmel AVR development
 Standard library used to the development of C programs for the
 Atmel AVR micro controllers. This package contains static
 libraries as well as the header files needed.

Package: dfu-programmer
Version: 0.6.1-1build1
Priority: optional
Section: universe/devel
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Rodolphe Pelloux-Prayer <rodolphe@damsy.net>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 82.9 kB
Depends: libc6 (>= 2.7), libusb-1.0-0 (>= 2:1.0.8)
Homepage: http://dfu-programmer.sourceforge.net/
Download-Size: 30.6 kB
APT-Sources: http://apt.pop-os.org/ubuntu jammy/universe amd64 Packages
Description: device firmware update (DFU) based USB programmer for Atmel chips
 A Linux based command-line programmer for Atmel chips with a USB
 bootloader supporting in-system programming.
 .
 This is a mostly Device Firmware Update (DFU)-1.0-compliant
 user-space application. This program was created because the Atmel
 FLIP program for flashing devices does not run on Linux and because
 standard DFU loaders do not work for Atmel chips.
cd ~/mnt-keyboard4/reform
git branch --show-current
echo "##############"
batcat -p reform2-keyboard4-fw/README.md

results:

master
##############
# MNT Reform Keyboard 4.0 Firmware

## Building

You have to pass 3 variables to `build.sh`:

- `-DKBD_MODE` can be `KBD_MODE_LAPTOP` or `KBD_MODE_STANDALONE`
- `-DKBD_VARIANT` can be `KBD_VARIANT_US` or `KBD_VARIANT_INTL` (for 102nd key instead of DEL next to left shift)
- `-DKBD_HID_FW_REV` is a string that is displayed as the revision on the OLED system status screen

Example:

./build.sh -DKBD_MODE=KBD_MODE_LAPTOP -DKBD_VARIANT=KBD_VARIANT_US -DKBD_HID_FW_REV=\"debug\"

Then I found MNT Reform Operator Handbook, 3rd Edition

  Keyboard Firmware

  You can update the firmware of the keyboard on MNT Reform itself, but make sure to read this section
  in full to avoid ending up in a situation where you have to disassemble the laptop.

  You’ll need an external USB keyboard to finish the process, as your laptop’s keyboard will stop
  responding after entering firmware update mode. Otherwise, you can only recover from this mode by
  opening the laptop and pressing the keyboard’s reset button or disconnecting and reconnecting the
  battery or keyboard cables.

  To be able to flash the firmware to the keyboard, its microcontroller has to be in this special
  programming mode. Since the 3.0 revision of the Keyboard, you can put it in programming mode by
  pressing the Circle key followed by the X key.

  For keyboard 4.0 (with RGB backlight), execute these commands:

  git clone https://source.mnt.re/reform/reform
  cd reform/reform2-keyboard4-fw
  ./download-fw.sh laptop-us
  sudo ./flash.sh

  Substitute laptop-us with laptop-intl if you have a non-US keyboard layout.

  For older keyboard versions (white backlight):

  git clone https://source.mnt.re/reform/reform
  cd reform/reform2-keyboard-fw
  ./download-fw.sh 3_US # or 3 if you have a
		      # non-US keyboard
		      # or 2 if you have an
		      # older pre-V3 keyboard
  sudo ./flash.sh

  You can find MNT Reform keyboard firmware sources for the current version with RGB backlight in the
  source folder reform2-keyboard4-fw.

  MNT Reform keyboard firmware sources for older versions of the keyboard are in the source folder
  reform2-keyboard-fw.
cd ~/mnt-keyboard4/reform
git branch --show-current
echo "##############"
exa -T reform2-keyboard4-fw/

results:

master
##############
reform2-keyboard4-fw
├── bitmap-font
│  ├── lcdfont
│  ├── lcdfont.c
│  ├── reform2kbdbitmapfont.xbm
│  └── reform2kbdbitmapfont.xcf
├── build.sh
├── CMakeLists.txt
├── flash-direct.sh
├── pico_sdk_import.cmake
├── README.md
└── src
   ├── azoteq.c
   ├── azoteq.h
   ├── font.c
   ├── iqs9150.c
   ├── iqs9150.h
   ├── IQS9150_init.h
   ├── keyboard.h
   ├── main.c
   ├── matrix.h
   ├── matrix_anri.h
   ├── menu.c
   ├── menu.h
   ├── oled.c
   ├── oled.h
   ├── reform2kbdbitmapfont.xcf
   ├── remote.c
   ├── remote.h
   ├── tusb_config.h
   ├── usb_descriptors.c
   ├── usb_descriptors.h
   ├── usb_hid_keys.h
   ├── ws2812.pio
   └── ws2812.pio.h

Are the following debian packages need it for the mnt-reform v4 keyboard too right ??

apt install -y gcc-avr avr-libc dfu-programmer

There isn’t a file called download-fw.sh in reform/reform2-keyboard4-fw
Is the MNT Reform Operator Handbook, 3rd Edition oudated ?

If I only want to update the firmware without changing any key yet what I should do ?

I pull recent changes from Reform / reform · GitLab

Is there any command to back up the current firmware ?

I have mnt-reform v4 keyboard standalone If I follow the mnt-reform v4 keyboard standalone README.md the command should be the following right?

./build.sh -DKBD_MODE=KBD_MODE_STANDALONE -DKBD_VARIANT=KBD_VARIANT_US - DKBD_HID_FW_REV=\"9e524c07\"

No, I guess not. Keyboard v4 uses the RP2040 which gets flashed differently and does not get built with gcc-avr.

You are not the first to find this problem. Lets finally create an issue for this:

It is probably easier to add this script to the git repo than to adjust the handbook because we cannot change the printed versions.

I received my own keyboard v4 only last week and I will have answers for you soon but am unfortunately currently tied up with family matters. Please ping me directly if you don’t have an answer for your remaining questions within a week. Sorry.

Howdy @josch,

Thanks for your reply! It’s interesting to hear that the documentation is outdated and doesn’t include instructions for flashing the v4 keyboard, but I just saw your link to the gitlabb issue, thanks for that.

It’s great to know you have a v4 keyboard now. I can wait a week, just take care of what you need to, and let me know when you have time to work on this.

I’m really looking forward to updating the firmware on the v4 keyboard and mapping the left Hyper key to act as the left Ctrl key.

Best

I don’t think outdated is the right word here. To fix it, how about not changing the documentation but fixing the tooling? I added the flash.sh and download-fw.sh scripts to reform-keyboard4-fw in this MR:

You earlier asked how to download the current firmware. This is how:

sudo picotool save out.uf2

I build it like this:

PICO_SDK_PATH=/usr/src/pico-sdk cmake -B build -DFAMILY=rp2040 -DKBD_MODE=KBD_MODE_LAPTOP -DKBD_VARIANT=KBD_VARIANT_INTL -DKBD_HID_FW_REV='"mycustom"' .
cmake --build build

Howdy @josch,

Thanks again for the update.

Regarding your comment, I agree that “outdated” might not be the best word, perhaps “incomplete” fits better.

I saw the MR add flash.sh and download-fw.sh (!89) · Merge requests · Reform / reform · GitLab

I installed picotool v2.1.1 (Linux, GNU-11.4.0, Release). Details are available at this link here.

To download the current firmware, I ran:

picotool info
# Output:
# Program Information
#  name:          reform2-keyboard4-fw
#  binary start:  0x10000000
#  binary end:    0x1000c63c

picotool save mnt-rfmv4-9e524c07_$(date +%F).uf2
# Saving file: [==============================] 100%
# Wrote 101888 bytes to mnt-rfmv4-9e524c07_2025-07-07.uf2

du -sh mnt-rfmv4-9e524c07_2025-07-07.uf2
# 100K    mnt-rfmv4-9e524c07_2025-07-07.uf2

At this time, the latest commit on the master branch is 1df8eaa6ae1d1e9c9822bc1ee03904f5eafc6cfd.

Since I only have the keyboard, I selected KBD_MODE_STANDALONE for building the firmware:

# From the reform/reform2-keyboard4-fw directory:
PICO_SDK_PATH=/opt/pico-build/pico-sdk cmake -B build -DFAMILY=rp2040 -DKBD_MODE=KBD_MODE_STANDALONE -DKBD_VARIANT=KBD_VARIANT_INTL -DKBD_HID_FW_REV='"1df8eaa6"' .
cmake --build build

du -sh reform2-keyboard4-fw/build/reform2-keyboard4-fw.uf2
# 96K reform2-keyboard4-fw.uf2

# Enter USB flashing mode and copy the firmware:
ls /media/$USER
# RPI-RP2
cp $HOME/reform/reform2-keyboard4-fw/build/reform2-keyboard4-fw.uf2 /media/$USER/RPI-RP2/

The keyboard now has the latest firmware changes.

Question:

How can I remap the Ctrl key to act as the Hyper key and vice versa (i.e., make the Hyper key act as Ctrl)?

Best

Which ctrl key? Here is how to swap it with the right ctrl key (the one on the last row):

--- a/reform2-keyboard4-fw/src/matrix.h
+++ b/reform2-keyboard4-fw/src/matrix.h
@@ -123,7 +123,7 @@
 
 // Sixth row
 #define MATRIX_DEFAULT_ROW_6 \
-  KEY_HYPER,\
+  KEY_RIGHTCTRL,\
   KEY_LEFTMETA,\
   KEY_LEFTALT,\
   KEY_SPACE,\
@@ -131,7 +131,7 @@
   KEY_SPACE,\
   KEY_SPACE,\
   KEY_RIGHTALT,\
-  KEY_RIGHTCTRL,\
+  KEY_HYPER,\
   KEY_LEFT,\
   KEY_DOWN,\
   KEY_RIGHT
@@ -187,7 +187,7 @@ uint16_t matrix_fn[KBD_MATRIX_SZ] = {
   KEY_PAGEUP,
   KEY_RIGHTSHIFT,
 
-  KEY_HYPER,
+  KEY_RIGHTCTRL,
   KEY_LEFTMETA,
   KEY_LEFTALT,
   KEY_SPACE,
@@ -195,7 +195,7 @@ uint16_t matrix_fn[KBD_MATRIX_SZ] = {
   KEY_SPACE,
   KEY_SPACE,
   KEY_RIGHTALT,
-  KEY_RIGHTCTRL,
+  KEY_HYPER,
   KEY_HOME,
   KEY_PAGEDOWN,
   KEY_END

Untested. But you just switch the definition of what is where in both matrices.

hey @josch ,

I swapped the KEY_LEFTCTRL and KEY_HYPER keys in the firmware. Specifically, I changed KEY_LEFTCTRL to KEY_HYPER and vice versa.

Additionally, I noticed that the keyboard variant KBD_VARIANT_INTL does not include a Delete key, so I switched to the KBD_VARIANT_US variant to have it available.

Below are the relevant changes I made in the file reform2-keyboard4-fw/src/matrix.h:

--- a/reform2-keyboard4-fw/src/matrix.h
+++ b/reform2-keyboard4-fw/src/matrix.h
@@ -68,7 +68,7 @@
 // Fourth row
-  KEY_LEFTCTRL,\
+  KEY_HYPER, \
   KEY_A,\
   KEY_S,\
   KEY_D,\
@@ -123,7 +123,7 @@
 // Sixth row
-  KEY_HYPER,\
+  KEY_LEFTCTRL, \
   KEY_LEFTMETA,\
   KEY_LEFTALT,\
   KEY_SPACE,\
@@ -187,7 +187,7 @@ uint16_t matrix_fn[KBD_MATRIX_SZ] = {
   KEY_PAGEUP,
   KEY_RIGHTSHIFT,
-  KEY_HYPER,
+  KEY_LEFTCTRL,
   KEY_LEFTMETA,
   KEY_LEFTALT,
   KEY_SPACE,

I also test Home, Page up, Page down and End keys an they are working really well for me with the new position for the KEY_HYPER.

Question:

How do I configure the Insert and Print Screen / SysRq keys? I did not find them defined in matrix.h.

Best

matrix.h includes usb_hid_keys.h which contains a long list of predefined scan codes, for example:

#define KEY_SYSRQ 0x46 // Keyboard Print Screen
#define KEY_INSERT 0x49 // Keyboard Insert
1 Like

Hey @josch ,

Thanks for pointing out that the file usb_hid_keys.h contains the definitions for KEY_INSERT and KEY_SYSRQ. That really helped clarify things.

I noticed in the matrix.h file, specifically in the section for “When holding down HYPER,” there are some key mappings that aren’t working for me, and a few seem repeated. However, it was useful because holding HYPER + F12 sends KEY_INSERT and holding HYPER + F11 sends KEY_SYSRQ. Here is the relevant snippet from matrix.h:

150 // When holding down HYPER
151 uint16_t matrix_fn[KBD_MATRIX_SZ] = {
152   KEY_ESC,
153   KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_BRIGHTNESS_DECREMENT,
154   KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_BRIGHTNESS_INCREMENT,
155   KEY_F3,
156   KEY_F4,
157   KEY_F5,
158   KEY_F6,
159   KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_SCAN_PREVIOUS,
160   KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_PLAY_PAUSE,
161   KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_SCAN_NEXT,
162   KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_MUTE,
163   KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_VOLUME_DECREMENT,
164   KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_VOLUME_INCREMENT,
165   KEY_CIRCLE,
166 
167   MATRIX_DEFAULT_ROW_2,
168   MATRIX_DEFAULT_ROW_3,
169   MATRIX_DEFAULT_ROW_4,
170 
171   KEY_LEFTSHIFT,

And here are the latest changes I made to matrix.h that swap KEY_LEFTCTRL for KEY_HYPER and add KEY_SYSRQ and KEY_INSERT explicitly:

index e75f9b9..7e6a309 100644
--- a/reform2-keyboard4-fw/src/matrix.h
+++ b/reform2-keyboard4-fw/src/matrix.h
@@ -68,7 +68,7 @@

 // Fourth row
 #define MATRIX_DEFAULT_ROW_4 \
-  KEY_LEFTCTRL,\
+  KEY_HYPER, \
   KEY_A,\
   KEY_S,\
   KEY_D,\
@@ -123,7 +123,7 @@

 // Sixth row
 #define MATRIX_DEFAULT_ROW_6 \
-  KEY_HYPER,\
+  KEY_LEFTCTRL, \
   KEY_LEFTMETA,\
   KEY_LEFTALT,\
   KEY_SPACE,\
@@ -160,8 +160,8 @@ uint16_t matrix_fn[KBD_MATRIX_SZ] = {
   KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_PLAY_PAUSE,
   KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_SCAN_NEXT,
   KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_MUTE,
-  KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_VOLUME_DECREMENT,
-  KEY_CONSUMER_PAGE|HID_USAGE_CONSUMER_VOLUME_INCREMENT,
+  KEY_SYSRQ,
+  KEY_INSERT,
   KEY_CIRCLE,

   MATRIX_DEFAULT_ROW_2,
@@ -187,7 +187,7 @@ uint16_t matrix_fn[KBD_MATRIX_SZ] = {
   KEY_PAGEUP,
   KEY_RIGHTSHIFT,

-  KEY_HYPER,
+  KEY_LEFTCTRL,
   KEY_LEFTMETA,
   KEY_LEFTALT,
   KEY_SPACE,

Question:

Is there an option to disable the LED light by default each time I plug the keyboard or power up my machine, also how to change the current led color to blue?

Best

1 Like

Just want to say that I was planning to attempt some of these exact changes on the firmware for an MNT Classic Reform, so it’s really handy to see how you did it here. Thanks!

1 Like

The code there needs to be upstreamed to OpenRGB.

@minute I can open a pull request with the current state on the OpenRGB git if you like. You said in June that you wanted to do it but I understand that you might have one or two more important things on your TODO list right now? :upside_down_face: In case you agree: Is the copyright holder you or @plom?

Last time I tried there were problems with the system freezing when too many updates to RGB color were done. @minute said that it was maybe “starving maybe usb or spi” – did anybody manage to look into it since then?

@josch, does the reform-openrgb code run on the machine that my keyboard is connected to or does it affect how the firmware is build?

@antti, I changed the default color for my standalone keyboard by modifying line 191 in reform2-keyboard4-fw/src/main.c - for (very) blue it would be led_set_rgb(0x0000ff); with 0000ff being the hex-code for blue. To disable the LED light initially you could simply put led_set_rgb(0x000000);.

Welcome to the forum!

Yes. It sends USB messages to the keyboard controlling the individual RGB LEDs. OpenRGB is not a firmware mod but is a (I think Qt?) GUI interface you can run on your Linux desktop.

1 Like