qmk / qmk_firmware

Open-source keyboard firmware for Atmel AVR and Arm USB families
https://qmk.fm
GNU General Public License v2.0
17.8k stars 38.15k forks source link

Consider adding Keychron K* keyboards #7370

Closed mdreizin closed 1 year ago

mdreizin commented 4 years ago

I am a user of Keychron K2 keyboard I only know that it uses ARM M0 MCU. I am not an expert and it would be nice to know if it is possible to create QMK-based firmware for this keyboard or not?

digdog commented 3 years ago

There're many data sheet and sw tools available for download from Sonix's Trad. Chinese pages: http://www.sonix.com.tw/article-tw-4315-30347 (SN32F248B) http://www.sonix.com.tw/article-tw-4315-30346 (SN32F247B) http://www.sonix.com.tw/article-tw-4315-30345 (SN32F246B) http://www.sonix.com.tw/article-tw-4315-30348 (SN32F2451B)

P.S. NuPhy's NuType F1 60% RGB kb is also using same SN32F240B_32.hex firmware. And in their facebook user group, their marketing said they're considering open source the firmware.

raqbit commented 3 years ago

@digdog I must say, NuPhy's site looks... familiar :smile:

Perhaps some of the people working on the NuType are/were involved with both products? (Or they may have taken inspiration from Keychron)

image


The Windows updater for my Keychron K4 RGB w/ Optical switches contains firmware (Intel hex) for the "SN32F260":

[SpecialPID0]
VID=0x05AC
PID=0x024F # It's pretending to be an Apple USB keyboard
ChipName=SN32F26x
FWName=SN32F260.hex
FWType=HEX
CodeSecurity=1

So it looks like the Keychron K4 RGB-Optical is using the same chip as the Wormier K66 RGB, as far as I can tell.

MingyaoLiu commented 3 years ago

The Drevo Seer Pro 60% is using the SN32F240B_32.hex firmware. File inside updater file states:

ISPTitle=DREVO Seer PRO Firmware Update_FW V1.10
ISPProgramText=ISP Program
ISPWarningMSG=
ISPWarningMSG2=
ISPMSGFontColorR=255
ISPMSGFontColorG=255
ISPMSGFontColorB=0
ISPMSGFontColorSize=25
StartButtonString=Start
ISPStartMSG=Start update...
ISPSuccessMSG=Update successfully
ISPFailMSG=Update fail
ProgramOneTime=0
ACPowerCheck=0
ACPowerCheckWarningMsg=Please connect AC-adapter
CheckDeviceCmd=AA42895AFF7162CC
CheckBootLoaderID=1
DeviceChangeCheck=0
CurVersion=0x0109
ISPFWUpdatedMsg=Firmware is already updated
ShowMessageBox=0

[SpecialPID]
Count=3                         

[SpecialPID0]                       
VID=0x0C45                      
PID=0x8006                      
ChipName=SN32F24xB                  
FWName=SN32F240B_32.hex         
FWType=HEX                      
CodeSecurity=1                      

[SpecialPID1]
VID=0x05AC                      
PID=0x024F                      
ChipName=SN32F24xB                  
FWName=SN32F240B_32.hex             
FWType=HEX                      
CodeSecurity=1  

[SpecialPID2]
VID=0x05AC                      
PID=0x0256                      
ChipName=SN32F24xB                  
FWName=SN32F240B_32.hex             
FWType=HEX                      
CodeSecurity=1          

I really want to remap the Fn key, but have no luck using the Drevo Power Console software.

ervinpm commented 3 years ago

+1 would like to see this working for the velocifire m2. I wonder if asking the manufacturer for source codes would help?

stdvar commented 3 years ago

+1 would like to see this working for the velocifire m2. I wonder if asking the manufacturer for source codes would help?

No hope. Asked. They don’t have plans for making boards configurable. Nor they will release sources.

SmileYzn commented 3 years ago

MotoSpeed CK62 is very similiar to TKL61WS but TKL61WS as a lot of better layer than CK62.

Here is the link for TKL61WS : https://www.velocifiretech.com/product/m2-wireless-mechanical-keyboard/

teknogeek commented 3 years ago

What's very surprising to me is that I just launched Drevo Power Console with my Keychron K6 plugged in, and it recognized it and even let me change RGB settings (?!):

img

However, it seemed to mess up the RGB profiles and caused the "switch profile" button to forget all the RBG profiles but the one set in the software:

img

I wouldn't really recommend trying this, since I had to reflash the OEM firmware to get RGB working properly again.

teknogeek commented 3 years ago

Also, the same behavior above is seen when using the Ninja71 keyboard software as well

CalcProgrammer1 commented 3 years ago

I made significant progress on the Sonix USB layer in chibios. I got the USB interrupt handling transactions larger the endpoint size which allows raw HID interface to work (as the descriptor exceeds 64 bytes when the raw HID interface is enabled). I brought up endpoint interrupt processing based on direction which allows raw HID transactions to work. I am using this to bring up OpenRGB control on the Redragon K556. I will post more soon.

marksard commented 3 years ago

I have DREVO Calibur V2 TE. I open it up and look at PCB, there is HFD2201KBA. I think it would be great if I could mod this chip.

CalcProgrammer1 commented 3 years ago

Made big progress on the Sonix port. OpenRGB interface is running fairly smoothly and I can run animations from the PC side. Cleaned up the RGB matrix code a bit, only minor glitching when the USB is loaded.

Posted a demo on Reddit, github link in comments to my branch:

https://www.reddit.com/r/MechanicalKeyboards/comments/jwrgeu/porting_qmk_to_the_sonix_sn32f248b_redragon_gmmk/

IslamAlam commented 3 years ago

Working based on the @CalcProgrammer1 branch to batch it for the BlitzWolf BW-KB1 which uses the same MCU.

QMK Branch: https://github.com/IslamAlam/qmk_firmware/tree/blitzwolf_kb1/keyboards/blitzwolf/kb1

This the reverse engineering of the PCB of the keyboard and matrix connection. https://github.com/IslamAlam/blitzwolf-bw-kb-1

It would be great to make the Bluetooth functional as well, based on my test for the PCB layout: The Bluetooth module communicates with the MCU is SPI.

The Bluetooth module "CYW20730A2KFBG with integrated ARM Cortex™-M3 " support version 5 and is identical to Broadcom Part Number: BCM20730A2KFBG. It is used only for Bluetooth communication.

IslamAlam commented 3 years ago

I am having an issue with the driver: Windows (gives the error "Unknown USB Device (Device Descriptor Request Failed") and Linux recognize the keyboard in the boot mode. I am using the branch from @CalcProgrammer1 & @jath03
https://github.com/CalcProgrammer1/qmk_firmware/pull/1#issuecomment-735383389

raqbit commented 3 years ago

Working based on the @CalcProgrammer1 branch to batch it for the BlitzWolf BW-KB1 which uses the same MCU.

QMK Branch: https://github.com/IslamAlam/qmk_firmware/tree/blitzwolf_kb1/keyboards/blitzwolf/kb1

This the reverse engineering of the PCB of the keyboard and matrix connection. https://github.com/IslamAlam/blitzwolf-bw-kb-1

It would be great to make the Bluetooth functional as well, based on my test for the PCB layout: The Bluetooth module communicates with the MCU is SPI.

The Bluetooth module "CYW20730A2KFBG with integrated ARM Cortex™-M3 " support version 5 and is identical to Broadcom Part Number: BCM20730A2KFBG. It is used only for Bluetooth communication.

Did anyone figure out if the bluetooth module on the Keychron boards is similar to the one present on other keyboards with the HFD2201KBA mcu? Perhaps this bluetooth module is offered as an add-on together with the mcu, firmware & protocol which is apparently shared between a whole bunch of mechanical keyboards, as we've discovered here.

If this is the case, am I correct that the only differentiating parts between all of these keyboards are the matrix layout, status indicator LEDs & the option switches on the side?

Perhaps it's also a good idea to create an overview document somewhere to showcase which keyboards are known to share the same chip, which way their matrix is laid out, if they have Bluetooth & which other differentiating features they have.


I also noticed how the CYW20730A2KFBG Bluetooth module advertises to be Bluetooth 5.1 compliant in its datasheet, which is only advertised for all new recently released versions of Keychron keyboards which were only recently released. Is this just a marketing thing (and do "old" Keychron keyboards have Bluetooth 5.1 support) or is Bluetooth 5.1 disabled on the stock firmware in the "old" keyboards? Can anyone with a Bluetooth 5 capable host confirm this?

IslamAlam commented 3 years ago

s? Can anyone with a Bluetooth 5 capable host confirm this?

I can confirm that the new version of the blutooth module is capable to support 5 different hosts 👍 I am not sure if the old module was supporting that or the company upgraded the chip itself to be compatible with Bluetooth 5.

stdvar commented 3 years ago

Made big progress on the Sonix port. OpenRGB interface is running fairly smoothly and I can run animations from the PC side. Cleaned up the RGB matrix code a bit, only minor glitching when the USB is loaded.

Posted a demo on Reddit, github link in comments to my branch:

https://www.reddit.com/r/MechanicalKeyboards/comments/jwrgeu/porting_qmk_to_the_sonix_sn32f248b_redragon_gmmk/

Thanks for the USB updates. Do you have an issue when keyboard doesn't wake PC up from sleep? Trying to figure out where to look for solutions/updates. Thanks.

dexter93 commented 3 years ago

Working based on the @CalcProgrammer1 branch to batch it for the BlitzWolf BW-KB1 which uses the same MCU.

QMK Branch: https://github.com/IslamAlam/qmk_firmware/tree/blitzwolf_kb1/keyboards/blitzwolf/kb1

This the reverse engineering of the PCB of the keyboard and matrix connection. https://github.com/IslamAlam/blitzwolf-bw-kb-1

It would be great to make the Bluetooth functional as well, based on my test for the PCB layout: The Bluetooth module communicates with the MCU is SPI.

The Bluetooth module "CYW20730A2KFBG with integrated ARM Cortex™-M3 " support version 5 and is identical to Broadcom Part Number: BCM20730A2KFBG. It is used only for Bluetooth communication.

Hi @IslamAlam . newbie to qmk here

tore down my keychron k4 today and had a look inside. Our boards are very close https://github.com/dexter93/keychron-k4

I have already mapped the key matrix to the mcu pins. How did you map those to rows and cols on qmk? Docs are a bit chaotic..

Appreciate any help

edit: I figured it out. led matrix is next, but the board layering is a mess so getting to those pins is not going to be fun

jedifindtrick commented 3 years ago

Working based on the @CalcProgrammer1 branch to batch it for the BlitzWolf BW-KB1 which uses the same MCU. QMK Branch: https://github.com/IslamAlam/qmk_firmware/tree/blitzwolf_kb1/keyboards/blitzwolf/kb1 This the reverse engineering of the PCB of the keyboard and matrix connection. https://github.com/IslamAlam/blitzwolf-bw-kb-1 It would be great to make the Bluetooth functional as well, based on my test for the PCB layout: The Bluetooth module communicates with the MCU is SPI. The Bluetooth module "CYW20730A2KFBG with integrated ARM Cortex™-M3 " support version 5 and is identical to Broadcom Part Number: BCM20730A2KFBG. It is used only for Bluetooth communication.

Hi @IslamAlam . newbie to qmk here

tore down my keychron k4 today and had a look inside. Our boards are very close https://github.com/dexter93/keychron-k4

I have already mapped the key matrix to the mcu pins. How did you map those to rows and cols on qmk? Docs are a bit chaotic..

Appreciate any help

I have a K6 and K8 (both ISO Nordic) that i'm very comfortable with tearing down and taking pictures of. I can't do much in the way of mapping stuff, but let me know if you need anything.

dexter93 commented 3 years ago

Working based on the @CalcProgrammer1 branch to batch it for the BlitzWolf BW-KB1 which uses the same MCU. QMK Branch: https://github.com/IslamAlam/qmk_firmware/tree/blitzwolf_kb1/keyboards/blitzwolf/kb1 This the reverse engineering of the PCB of the keyboard and matrix connection. https://github.com/IslamAlam/blitzwolf-bw-kb-1 It would be great to make the Bluetooth functional as well, based on my test for the PCB layout: The Bluetooth module communicates with the MCU is SPI. The Bluetooth module "CYW20730A2KFBG with integrated ARM Cortex™-M3 " support version 5 and is identical to Broadcom Part Number: BCM20730A2KFBG. It is used only for Bluetooth communication.

Hi @IslamAlam . newbie to qmk here tore down my keychron k4 today and had a look inside. Our boards are very close https://github.com/dexter93/keychron-k4 I have already mapped the key matrix to the mcu pins. How did you map those to rows and cols on qmk? Docs are a bit chaotic.. Appreciate any help

I have a K6 and K8 (both ISO Nordic) that i'm very comfortable with tearing down and taking pictures of. I can't do much in the way of mapping stuff, but let me know if you need anything.

each board should be individual and since the wiring is the mapping, some tracing will have to be done. Time will tell.

In other news, the K4v1 seems to be flashable and recoverable to factory firmware

Chibios seems to be working. Will update when I have something that's functional, at the moments it's a random light display :)

dilutedspine commented 3 years ago

I have a K4 v2 I'm willing to pop open to take images of for you guys as well if need be.

teknogeek commented 3 years ago

Looking at the chip pictures I took inside my K6 when I modded it, looks like it's running the same chips as the K4 per @dexter93's repo

domoaligato commented 3 years ago

Made big progress on the Sonix port. OpenRGB interface is running fairly smoothly and I can run animations from the PC side. Cleaned up the RGB matrix code a bit, only minor glitching when the USB is loaded.

Posted a demo on Reddit, github link in comments to my branch:

https://www.reddit.com/r/MechanicalKeyboards/comments/jwrgeu/porting_qmk_to_the_sonix_sn32f248b_redragon_gmmk/

I believe this was a K2 RGB right? Is there anyway I could help with my K8 RGB or K2 white led? I have a vm setup with a build environment for builds supporting my Ctrl, Zeal60, and OG Red Scarf i. I can take pictures of the board components of either if that will help. Open RGB looks awesome btw. I can't wait to try it out and ditch asus armory crate and corsair icue.

dexter93 commented 3 years ago

Heyo,

QMK is working on the K4 and the keyboard seems happy with it.

https://github.com/dexter93/qmk_firmware/tree/keychron_k4

stdvar commented 3 years ago

Heyo,

QMK is working on the K4 and the keyboard seems happy with it.

https://github.com/dexter93/qmk_firmware/tree/keychron_k4

@dexter93 , this is awesome! good job! a few questions:

dexter93 commented 3 years ago

Heyo, QMK is working on the K4 and the keyboard seems happy with it. https://github.com/dexter93/qmk_firmware/tree/keychron_k4

@dexter93 , this is awesome! good job! a few questions:

  • do you have chatter?
  • do you observe keyboard doesnt wake up pc and occasionally crashes if key is pressed when pc is in sleep?

No chatter. Sometimes it locks up on a row if I type too fast ( probably the debouncer needs adjusting) Not sure on sleep/wake mode. haven't tested yet

raqbit commented 3 years ago

Heyo,

QMK is working on the K4 and the keyboard seems happy with it.

https://github.com/dexter93/qmk_firmware/tree/keychron_k4

Very cool!

Does this mean that the only missing feature in the QMK build is now bluetooth support?

parkerlreed commented 3 years ago

Anything for the K2 or K6? Would very much love to try this out (The K6 is currently a spare board)

jedifindtrick commented 3 years ago

Anything for the K2 or K6? Would very much love to try this out (The K6 is currently a spare board)

I am working on adapting it for the K6 (iso), but i'm still new to this so i'm going to have someone who knows this better look it over first.

chyyran commented 3 years ago

What's missing for bluetooth to work?

dexter93 commented 3 years ago

Anything for the K2 or K6? Would very much love to try this out (The K6 is currently a spare board)

I am working on adapting it for the K6 (iso), but i'm still new to this so i'm going to have someone who knows this better look it over first.

Sounds awesome. Feel free to ping me in the qmk discord.

What's missing for bluetooth to work?

These boards are using the BCM20730 as the bluetooth HID module with an unknown firmware. While the HID protocol is open and faily documented, the SPI command set that it's using to communicate with our Sonix MCU is currently unknown.

The BCM module has provisions to directly get the keyboard matrix data, but it seems that we're not using it. Instead it's relying on the MCU to get the data. If we can get the communication protocol, we can probably make them talk and have bluetooth functionality.

I have found no traces of the bluetooth firmware in the OEM firmware flasher, so it's probably set at the factory. Interfacing the BCM directly seems to be using proprietary methods and Broadcom is pretty strict when it comes to releasing those. I have had no success dumping the firmware so far. There is a chance the firmware is a generic chinese one that is being distributed to vendors, since there are so many keyboards with that chip. Further investigation is needed.

raqbit commented 3 years ago

Anything for the K2 or K6? Would very much love to try this out (The K6 is currently a spare board)

I am working on adapting it for the K6 (iso), but i'm still new to this so i'm going to have someone who knows this better look it over first.

Sounds awesome. Feel free to ping me in the qmk discord.

What's missing for bluetooth to work?

These boards are using the BCM20730 as the bluetooth HID module with an unknown firmware. While the HID protocol is open and faily documented, the SPI command set that it's using to communicate with our Sonix MCU is currently unknown.

The BCM module has provisions to directly get the keyboard matrix data, but it seems that we're not using it. Instead it's relying on the MCU to get the data. If we can get the communication protocol, we can probably make them talk and have bluetooth functionality.

I have found no traces of the bluetooth firmware in the OEM firmware flasher, so it's probably set at the factory. Interfacing the BCM directly seems to be using proprietary methods and Broadcom is pretty strict when it comes to releasing those. I have had no success dumping the firmware so far. There is a chance the firmware is a generic chinese one that is being distributed to vendors, since there are so many keyboards with that chip. Further investigation is needed.

So I'm guessing the next step would be to sniff the SPI bus between the MCU and the Bluetooth module to reverse engineer the protocol? Or do you think it would still be easier to try and figure out how to dump the firmware of the Bluetooth module and get the protocol that way?

IslamAlam commented 3 years ago

Working based on the @CalcProgrammer1 branch to batch it for the BlitzWolf BW-KB1 which uses the same MCU. QMK Branch: https://github.com/IslamAlam/qmk_firmware/tree/blitzwolf_kb1/keyboards/blitzwolf/kb1 This the reverse engineering of the PCB of the keyboard and matrix connection. https://github.com/IslamAlam/blitzwolf-bw-kb-1 It would be great to make the Bluetooth functional as well, based on my test for the PCB layout: The Bluetooth module communicates with the MCU is SPI. The Bluetooth module "CYW20730A2KFBG with integrated ARM Cortex™-M3 " support version 5 and is identical to Broadcom Part Number: BCM20730A2KFBG. It is used only for Bluetooth communication.

Hi @IslamAlam . newbie to qmk here

tore down my keychron k4 today and had a look inside. Our boards are very close https://github.com/dexter93/keychron-k4

I have already mapped the key matrix to the mcu pins. How did you map those to rows and cols on qmk? Docs are a bit chaotic..

Appreciate any help

edit: I figured it out. led matrix is next, but the board layering is a mess so getting to those pins is not going to be fun

I have used a multimeter to map the matrix manually from the ECU pins to each row and column.

If you have images for the board that might help too.

Anything for the K2 or K6? Would very much love to try this out (The K6 is currently a spare board)

I am working on adapting it for the K6 (iso), but i'm still new to this so i'm going to have someone who knows this better look it over first.

Sounds awesome. Feel free to ping me in the qmk discord.

What's missing for bluetooth to work?

These boards are using the BCM20730 as the bluetooth HID module with an unknown firmware. While the HID protocol is open and faily documented, the SPI command set that it's using to communicate with our Sonix MCU is currently unknown. The BCM module has provisions to directly get the keyboard matrix data, but it seems that we're not using it. Instead it's relying on the MCU to get the data. If we can get the communication protocol, we can probably make them talk and have bluetooth functionality. I have found no traces of the bluetooth firmware in the OEM firmware flasher, so it's probably set at the factory. Interfacing the BCM directly seems to be using proprietary methods and Broadcom is pretty strict when it comes to releasing those. I have had no success dumping the firmware so far. There is a chance the firmware is a generic chinese one that is being distributed to vendors, since there are so many keyboards with that chip. Further investigation is needed.

So I'm guessing the next step would be to sniff the SPI bus between the MCU and the Bluetooth module to reverse engineer the protocol? Or do you think it would still be easier to try and figure out how to dump the firmware of the Bluetooth module and get the protocol that way?

As far as I check the Bluetooth module can be connected to SWD for dumping the firmware. On the bottom right side, there are 4 pins, I expected that the 2 unlabeled connected are the IO and CLK for SWD. If that's the case, we only step from dumping the firmware.

jedifindtrick commented 3 years ago

As far as I check the Bluetooth module can be connected to SWD for dumping the firmware.

On the bottom right side, there are 4 pins, I expected that the 2 unlabeled connected are the IO and CLK for SWD.

If that's the case, we only step from dumping the firmware.

If you can point me in the direction of some instructions on how to do that I have a K8 just taking up space on a shelf right now that I wouldn't miss if I messed something up.

IslamAlam commented 3 years ago

As far as I check the Bluetooth module can be connected to SWD for dumping the firmware. On the bottom right side, there are 4 pins, I expected that the 2 unlabeled connected are the IO and CLK for SWD. If that's the case, we only step from dumping the firmware.

If you can point me in the direction of some instructions on how to do that I have a K8 just taking up space on a shelf right now that I wouldn't miss if I messed something up.

I have checked the Datasheet of the module: It seems there is no interface for the SWD. The chip does provide an EPROM for saving the configuration of light profiles, connected devices, etc. The EPROM is being connected to the other MCU via SPI.

So far the only way to program this chip is via a tool called BlueTool, which is mentioned here: CYW20730 - Downloading Firmware to CYW20730 Modules Using Bluetool The tool uses a UART to flash the firmware. Therefore, I expect the two pins in the image above are for the UART for flashing at the factory, not for SWD flashing like the other MCU.

The module, which is being used is assembled and solid by a company called Sziton: BT5GMD-B47P

I found a post about replacing the module with STM32 but it does not help at all.

Replacing keyboard MCU

What I can think of at the moment is either we get access to BlueTool or a similar software Or we try to spoof the SPI protocol and replicate it within the qmk_firmware. Not sure though what is the best approach.

Apperatelaly, this company was able to dump the firmware of the Bluetooth module: Case Study: Security of Modern Bluetooth Keyboards

New_Tales_of_Wireless_Input_Devices

doodhout commented 3 years ago

Guys (and girls if applicable), I just wanted to say I appreciate this effort very very much!

I'm using a K8 since a few days and my wish to map certain missing key(-combos) is strong. Sharpkeys can help me somewhat, but having full customisibility is really next level. I hope the effort will bear good results.

Thanks a bunch!

delingren commented 3 years ago

IMG_4905 I just purchased a Keychron C1 white backlights, their latest wired only TKL board. I am very interested in getting QMK on it. I suspect the microcontroller would be quite similar to other Keychron boards? Without Bluetooth, I suppose it should be easier.

I opened up the board and there is only one chip and the lettering on it shows (hard to see from the pic, I read with a magnifier):

HFD48KC900 2087NWCod

Google didn't return any results though. I'd be willing to poke around if anyone can give me some pointers. I'm using Macs but have a couple of spare PCs that I install Linux or Windows if need be. Thanks!

wurwik commented 3 years ago

I found on keychron web page Keychron K8 Bluetooth update manual with firmware, maybe it will help some how. https://www.keychron.com/pages/ota-tool-tutorial-for-keychron-k8-hot-swappable-keyboard

jedifindtrick commented 3 years ago

@dexter93 how did you manage to get the keyboard inti "flash mode" so to say? The sonix software that @IslamAlam mentions doesn't seem to be downloadable without an account and I can't get the keyboard to be recognised.

dexter93 commented 3 years ago

@dexter93 how did you manage to get the keyboard inti "flash mode" so to say? The sonix software that @IslamAlam mentions doesn't seem to be downloadable without an account and I can't get the keyboard to be recognised.

You need to get the Sonix MCU ISP Flash tool from here http://www.sonix.com.tw/article-en-4336-30356 Then in order to get the MCU in bootloader mode, follow this https://www.keychron.com/pages/special-instruction and short the boot pin to ground.

The keyboard will expose the VID/PID 0c45:7040 which you can use with the isp flash tool and the .bin qmk generates.

I have a more practical flash tool in the works that will use a button combo on boot to trigger the same mode eventually. But until I can iron out most issues, I won't bother releasing it.

IslamAlam commented 3 years ago

@dexter93 how did you manage to get the keyboard inti "flash mode" so to say? The sonix software that @IslamAlam mentions doesn't seem to be downloadable without an account and I can't get the keyboard to be recognised.

1- Download this flashing software for windows: SONiX_USB_MCU_ISP_Tool_V2.3.1.7-.zip

2- Put your keyboard in boot/recovery/flash mode via connecting boot pin to ground before connecting the keyboard via USB.

3- Then flash the binary via the software after setting the following configuration:

image image image image

jedifindtrick commented 3 years ago

That worked, after a bit of prodding and troubleshooting. I've manager to flash it, get everything working (except RGB on the bottom row, which stays white for some reason). I will upload pictures some time the coming days.

dexter93 commented 3 years ago

That worked, after a bit of prodding and troubleshooting. I've manager to flash it, get everything working (except RGB on the bottom row, which stays white for some reason). I will upload pictures some time the coming days. Welcome to qmk!

if you used my trees as a base.. it could be a myriad of reasons depending on which branches you picked. But if it's a whole row misbehaving it's usually a simple fix.

Getting the keyboard to work is one thing. Getting it to work properly is a whole different story. I'm working with @smp4488 to tidy up the matrix implementation and fix a pesky memory leak there that makes it hang randomly. then there's the whole low level driver stack which is barely functional for sonix chips in chibios..

Fun times ahead

dexter93 commented 3 years ago

As far as I check the Bluetooth module can be connected to SWD for dumping the firmware. On the bottom right side, there are 4 pins, I expected that the 2 unlabeled connected are the IO and CLK for SWD. If that's the case, we only step from dumping the firmware.

If you can point me in the direction of some instructions on how to do that I have a K8 just taking up space on a shelf right now that I wouldn't miss if I messed something up.

I have checked the Datasheet of the module: It seems there is no interface for the SWD. The chip does provide an EPROM for saving the configuration of light profiles, connected devices, etc. The EPROM is being connected to the other MCU via SPI.

So far the only way to program this chip is via a tool called BlueTool, which is mentioned here: CYW20730 - Downloading Firmware to CYW20730 Modules Using Bluetool The tool uses a UART to flash the firmware. Therefore, I expect the two pins in the image above are for the UART for flashing at the factory, not for SWD flashing like the other MCU.

The module, which is being used is assembled and solid by a company called Sziton: BT5GMD-B47P

I found a post about replacing the module with STM32 but it does not help at all.

Replacing keyboard MCU

What I can think of at the moment is either we get access to BlueTool or a similar software Or we try to spoof the SPI protocol and replicate it within the qmk_firmware. Not sure though what is the best approach.

Apperatelaly, this company was able to dump the firmware of the Bluetooth module: Case Study: Security of Modern Bluetooth Keyboards

New_Tales_of_Wireless_Input_Devices

I managed to somehow get hold of the SPI communication protocol for the bluetooth mcu. It's not too bad, but QMK has very limited support atm. This is subject to change however when this https://github.com/qmk/qmk_firmware/pull/11521 and subsequent refactors take place. It will definitely be wiser time wise to rely on an api than write a driver completely from scratch or butcher up the adafruit ble drivers to work with it.

dexter93 commented 3 years ago

Re keychron and sn32: I opened up a issues tab on my fork so people can see what the current status is. k4 is up and k6 seems to be close

Any help is appreciated see https://github.com/dexter93/qmk_firmware/issues

jedifindtrick commented 3 years ago

Yeah i've got everything but some of the backlighting working as intended now. Well, if you don't count the memoryleaks.

S13391355 commented 3 years ago

Hey @jedifindtrick, I'm working on the K6 too. I've got the US hot-swappable version. I've managed to compile the firmware but I'm having trouble getting the keyboard into bootloader.

What did you do to get this to work?

Also, has anyone tried playing with the official k6 firmware updater as that doesn't need any physical interfering with the keyboard to flash the firmware?

jedifindtrick commented 3 years ago

Hey @jedifindtrick,

I'm working on the K6 too. I've got the US hot-swappable version.

I've managed to compile the firmware but I'm having trouble getting the keyboard into bootloader.

What did you do to get this to work?

I've been so busy that I forgot to upload the info regarding this. Just follow the instructions @dexter93 gave me, but short these pins instead. image

Also, has anyone tried playing with the official k6 firmware updater as that doesn't need any physical interfering with the keyboard to flash the firmware?

Yes, i've tried looking at that, even tried to flash the .hex-file in the updater, but my keyboard got recognised as a K1 when I tried that.

alex-dinh commented 3 years ago

Hey everyone, I was able to successfully flash QMK to my Keychron K8!

My fork can be found here: https://github.com/alex-dinh/keychron-k8

I modified the keymap that @dexter93 made for the K4 to work on the K8, and followed the flashing instructions provided by him, @IslamAlam, and @jedifindtrick: https://github.com/qmk/qmk_firmware/issues/7370#issuecomment-766408470

You can put your K8 into bootloader/flash mode by shorting the BOOT pin and the P7 pin, which are the two pins on the right closest to the spacebar switch on your PCB. (Luckily you can access these pins just by taking off your spacebar, no need to remove all the switches/caps) Then connect your USB cable. You'll know you're successful when the RGB doesn't light up but Windows makes the usb connection sound.

All the keys are working as expected and even the RGB works flawlessly when its on. The only bug is that when you toggle them off they flicker at a low brightness. Not sure what could be causing this as I only started working with QMK yesterday, but if anyone might have a fix for this please take a look into it!

Note: only tested on Windows 10 1709

I also tried making a VIA port as well but it didn't work, my keyboard didn't register any keypresses after flashing it. Reflashing my non-VIA firmware still worked, though.

Edit: RGB works flawlessly now

delingren commented 3 years ago

I don't have a K4 or K8 and I am not familiar with QMK codebase. But there seems to be some documentation in docs/feature_backlight.md. Did you try a different BACKLIGHT_DRIVER?

alex-dinh commented 3 years ago

@delingren I looked into it more, and it appears that dexter's K4 QMK uses custom RGB matrix code, instead of backlight, which is the feature intended for single color lighting. I have the RGB hotswap K8 so I'll see if I can poke around and get it working as intended.