hansemro / re-masterkeys

Reverse Engineering of the Cooler Master Masterkeys line of keyboards
1 stars 0 forks source link

Custom firmware for disabling RGB LEDs on Masterkeys Pro S RGB #1

Open david-xi-long opened 1 year ago

david-xi-long commented 1 year ago

Hi, I'm trying to figure out if there is a way to modify the firmware so that RGB is disabled on the entire board. I scratched the board and a wire came out, so now only the red RGB controller works properly. When the RGB should be off, it stays on and flickers rapidly so I'd like to turn it off.

I've never done anything like this before, so any help is appreciated.

hansemro commented 1 year ago

Easiest way to disable hardware is to either cutoff power or disable clock.

One way to disable MBI RGB controller is to disable the Global Clock (GCLK). This is achieved by disabling HT32 MCU's GPTM1 timer which drives this clock signal here: https://github.com/hansemro/pok3r_re_firmware/blob/b899b4e856734d5e2f4375fe53e9baf4d993390f/disassemble/cmprosrgb/v122/cmprosrgb_v122.txt#L8320C24-L8323

Although unclear from the annotation alone, r1 register (2nd argument to TM_Cmd) determines whether the timer is enabled or not. By setting r1 to 0, we can prevent the timer from enabling. So the new snippet should look like the following:

/*0x6eac*/      movs r1, #0         ; r1 = 0
/*0x6eae*/      ldr r0, [pc, #0x40] /* r0 = GPTM1_BASE_6ef0 */
/*0x6eb0*/      bl TM_Cmd

This ends up being a single byte patch at address 0x3AAC of the 1.2.2 binary from 0x01 to 0x00. You can use a hex editor to apply this patch or rebuild the binary from assembly (assuming you have baremetal arm-none-eabi toolchain installed).