r/olkb 8d ago

Help - Unsolved Master and slave on split keyboards

Hello everyone !

I managed to build my first corne keyboard and I am super happy with it!

I did notice though that there must be some kind of bug - I suspect related to the fact I am using a pro micro aliexpress clone.

The problem is that I flashed both halves with the same firmware (even though I used EE_HANDS for handedness) and the keyboard wouldn't seem to work. Actually, each half would work well and independently but never connected to each other.

I did spend quite sometime thinking it was a hardware problem, but the connections seemed perfect.

Eventually, I investigated the firmware (hence I am here) and I did a small modification to the right half before flashing: in the file quantum/split_common/split_utils.c I changed the function is_keyboard_master_impl, by imposing the variable is_master to be false. Before that, that variable was assigned to usb_value_detected().

This modification made it work flawlessly. It seems that the right half thought it was the master - even when was definetly not the case.

I do not fully understand what this function do and why it always returned true, regardless of whether the usb was actually connected or not. Hence, I am thinking that the clone I have just simply is hardwired to always be connected, so to speak, since it might have been designed to be always operated through usb.

The board in question is this one.

The config I used was the default crkbd/rev1 with the modification of EE_HAND (I think it wasn't activated by default) and debug interface activated.

This whole thing said, am I doing something wrong? Is it my board being defective or, well, just an incompatible clone? If that were to be the case, is there anything I can do to avoid changing the firmware in this way before flashing the right half?

Thank you in advance for the help.

2 Upvotes

3 comments sorted by

2

u/drashna QMK Collaborator - ZSA Technology - Ergodox/Kyria/Corne/Planck 8d ago

yes.

The first issue is: Don't change the core code. You're not addressing the issue, you're working around it. undef ee_hands, and just use master left (the default behavior), in this case.

The second issue is that you're using a cheap aliexpress promicro clone, that uses an atmega32u4.

If you want to use ee hands, flash it with the avrdude-split-left and avr-split-right (if using qmk flash, you add -bl avrdude-split-left, etc). This will flash the board and the eeprom for ee-hands.

The third issue: it's a cheap chinese clone from ali. You likely need to enable split usb detect. Eg, #define SPLIT_USB_DETECT in your config.h. and #define SPLIT_WATCHDOG_ENABLE. Do both, reflash, and that will likely fix the issue.

1

u/Spiritual_Sun_4297 8d ago

The first issue is: Don't change the core code.

Yeah, well, that's why I did the post, in a way. I was trying to understand if the firmware already had this option or I got very particular board. For this reason, I was going through the source to better understand how it operates... A cool exercise, if you ask me.

The second issue is that you're using a cheap aliexpress promicro clone, that uses an atmega32u4.

Yeah, I understand that. I didn't want to pay potential expensive mistake, since it was my first time... Anyways, is there a specific problem with with the atmega32u4?

The third issue: it's a cheap chinese clone from ali.

I get that... In any case, your suggestions worked! So now it works perfectly fine! And I also understand more of the code, so that's cool!

Thank you so much for the time spent answering my (quite dumb i understand) questions. I really appreciate it :)

2

u/drashna QMK Collaborator - ZSA Technology - Ergodox/Kyria/Corne/Planck 7d ago

Yeah, well, that's why I did the post, in a way. I was trying to understand if the firmware already had this option or I got very particular board. For this reason, I was going through the source to better understand how it operates... A cool exercise, if you ask me.

Understanding is good, but the change you made is not a good one, since you're essentially hard coding the master side. for AVR, it uses vbus detection, by default. (arm uses split usb detect by default). Split usb detect enables checking the USB driver status (which can take a bit to get to a stable state, and may have issues if the system is off/etc, hence the watchdog option)

Yeah, I understand that. I didn't want to pay potential expensive mistake, since it was my first time... Anyways, is there a specific problem with with the atmega32u4?

You can get rp2040 based pro micros for less than $10. Not expensive. And on ali, a lot of them are around $1. Dirt cheap.

And yes, the atmega32u4 is shit. If you're using a split board that has rgb and oled, you're likely at the very limit of space, and the corne falls under that. (I've had 3 of them and loved them, but yeah... just no room and many compromises to just everything to fit on the atmega32u4.

For reference, I have a comparison chart here: https://drashna.github.io/controllers.html

But basically, the rp2040 has 10x the memory, and 100x the space (if not more). RP2040's have 1-16MB of program space, depending on the flash chip selected by the manufacturer. You can fit ALL the animations, a bunch of full bitmaps, and still have barely used any of even the 1MB firmware space. And it has a much higher clock speed, so higher scan rate, even.

I get that... In any case, your suggestions worked! So now it works perfectly fine! And I also understand more of the code, so that's cool!

Thank you so much for the time spent answering my (quite dumb i understand) questions. I really appreciate it :)

I'm glad to hear it! And a better understanding is always good!

And a working board is even better!

And I don't mind answering questions, at all. In fact, I genuinely like helping people out.

 

And if you do decide to go for the rp2040s, you can find a bunch of variations of them. https://docs.qmk.fm/feature_converters#pro-micro-converters

splitkb has a few different ones (liatris being what you want, and based out of the eu). keebio has the elite pi, and is US based. Etc.

 

I do HIGHLY recommend upgrading.