-
-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KVM Switch (Disable CDC Serial for better BIOS/UEFi/Custom compatibility) #225
Comments
After editing a few files die arduino keyboard is at least passed through the kvm and made available to the clients. I compared a few settings/values with this tool: https://www.thesycon.de/eng/usb_descriptordumper.shtml between the micro and a standard usb keyboard. Possible reasons
What i've done so far. I don't know if all these steps are nessessary but i will document them for anyone who finds this by googling.
I guess that SET_PROTOCOL / GET_PROTOCOL are not correctly working. I've tried using an LED to see if it enters Bootmode but it seems it doesn't use it. Tried a few things to force by editing values but it wasn't working and maybe i did somethiong wrong. Small Update: To get Passthrough in the KVM working CDC needs to be disabled. The bootloader can be there so its still possible to upload sketches without external Programmer, you just need to reset the Board manually by hitting Reset. |
So the solution is to remove the CDC device? That seems correct, as the arduino reports itself as kinda "mixed device" which is not a keyboard 100%. Some devices might not like this behavior and expect a pure keyboard. |
No. From what i've seen the CDC doesn't matter. Maybe it doesn't matter at all how many devices are registered as long as one device follows exactly the boot specifications in the USB Doc. |
Short update: I got a Teensy and configured it as keyboard, mouse Joystick and it works on my KVM device. |
Uhm... I dont know why it does not work. If you have any update, please let me know. |
Well, as i said. The current implementation does not follow the requirements for a real boot keyboard. I guess you are from germany so maybe its better to explain it in german. |
Yeah, I think the arduino implementation is tight to 64bit report descriptors. I dont know if that is the main issue. The classes might be another problem, however there are quick and dirty workarounds to change them and remove the CDC endpoint. But yes, if you have any detail to add in german, please do so. |
Hi @bitboy85 - thanks for documenting all this ; would be great if we can get the final summary to get it working (with or without disabling CDC) . 🚀 |
Just for information, it may be useful to someone. The patch for disabling the CDC is incorrect. As it is written, it leaves the first endpoints in non-configured state. I found out that this prevents Apple UEFI from detecting the keyboard to allow the user to enter the menu. This is probably why KVM switches go crazy. I figured out how it works and wrote a fixed version of the patch that is guaranteed to disable the CDC and leave no artifacts. |
I had no time digging further into this so i decided to use a teensy board with a working boot keyboard. So the above is more or less the final summary. As said above i got stuck at using a packet size of 8 Bit which is required by the usb standard. And i have no idea how to implement 2 devices. Maybe this isn't even possible with the current version of the provided usb libraries. In case of teensy it is possible to use Serial, keyboard, mouse and joystick in one device so i guess it doesn't matter at all if CDC is used or not. |
Thank you for the update @bitboy85 ; I've ordered the Teensy for now . Appreciate all the help you have given! |
Just for comparison: A working teensy implementation looks like this:
|
And here an arduino micro. I guess the bold part is wrong. Somewhere in the usb boot documentation i read that a boot Interface (sry, in earlier posts i wrote device) must have a packet size of 8 byte. But i'm unable to figure out where in the code this value is set.
|
Sry for spamming but i thinks its better to post where i get before i can't remember what i've done. So first things first:
If i read the usb documentation correctly, the modifiers keys are represented by a single byte.
So now we have an issue with file Bootkeyboard.cpp; Line 73 this creates the Endpoint and its attributes, at least it should. You can change USB_EP_SIZE and the following 0x01 (is it interval?) to whatever value you want, it does NOT change attributes in the endpoint descriptor, its overwritten somewhere This leads us to the file /arduino/avr/cores/arduino/USBAPI.h. As you can see this file does not belong to the HID-project as it comes with arduino by default. Sadly, in the file is the following quote:
Well it is possible to hack a size of 8 into it (which will additionally require changes in USBCORE.cpp) but just forcing the size to be 8 will not magically make the paket an 8 byte sized one. So it still does not work with the kvm switch. |
based on https://github.com/gdsports/usb-metamorph/tree/master/USBSerPassThruLine CDC_DISABLED is also used in ArduinoCore-samd for the same purpose. You can emulate a USB Boot Keyboard with compatible Arduinos (like the Leonardo or the SparkFun Pro Micro), but by default it won't work with some hosts (definitely my Aten KVM switch, AFAIK also some BIOSes, old Windows versions and some accessibility devices), because they get confused by the "modem" and CDC devices used to provide a serial console over USB. This change makes it relatively easy to disable the CDC at compiletime. Disabling it of course means that the serial console won't work anymore, and that you can only flash directly after resetting the board. See also NicoHood/HID#225 and arduino/Arduino#6387 and https://forum.arduino.cc/index.php?topic=545288.msg3717028#msg3717028
Sometimes Arduino-based USB devices don't work because some hardware (like KVM switches) gets confused by the CDC sub-devices. This change makes it relatively easy to disable CDC at compiletime. Disabling it of course means that the serial console won't work anymore, so you need to use the reset button when flashing. CDC_DISABLED is also used in ArduinoCore-samd for the same purpose. based on https://github.com/gdsports/usb-metamorph/tree/master/USBSerPassThruLine See also NicoHood/HID#225 and arduino/Arduino#6387 and https://forum.arduino.cc/index.php?topic=545288.msg3717028#msg3717028
Out of interest, which KVM switch do you own? |
Its a Startech 4 Port KVM https://www.startech.com/de-de/server-management/sv431dpua It seems it depends on the usb implementation of the hardware manufacturer if it works or not. HID-project also seems to work in some BIOSes and in some not. |
To everyone who still has problems with keyboard in bios: |
If there is some cheap KVM that does not work, I could buy it. Aten is too expensive for me :) |
The way to fix the issue is to disable CDC, I don't think you can do much within this lib. |
@DanielGibson Thanks for reminding me of this. I totally forgot about this one. Can you ping me once it is merged, so we can add that to the example sketch and the wiki as well? That information should not get lost. |
Thank you all for commenting in that PR, hopefully this helps reminding the Arduino maintainers of the issue :) I'll try to remember to ping you (but now that you've commented on it you'll probably get an e-mail from Github when it gets merged?) |
@NicoHood arduino/ArduinoCore-avr#383 (CDC_DISABLED) has been merged |
So what should we do now? How would be disable it from the arduino ide? |
Good question - can you somehow set a compilerflag in the arduino-ide? It'd be Though I guess until the next Arduino (core? ide?) release (presumably 1.8.4) that actually ships these changes they won't be accessible to most users anyway |
Years ago it was not possible to pass custom defined variables to the compiler. I am not sure if it works nowadays. Can you find that out maybe? Then we have a solution till the next release. |
It depends on the build environment. There is no problem for Platformio to pass parameters. Arduino IDE: https://forum.arduino.cc/t/arduino-ide-where-can-i-pass-defines-to-the-compiler/680845/3 |
@NicoHood @DanielGibson @mdevaev got some problems with HID Keyboard on Arduino Leonardo. Found this issue, tried to define CDC_DISABLED at build_flags. From this moment Leonardo is programmed by usbasp. |
@bitboy85 Do you remember which Teensy you have used? |
No, can't remember. As an alternative you may have a look at rpi pico. |
@bitboy85 ok will check and report later |
If you are interested, I studied the TinyUSB stack for compliance with the HID standard and it passed all my tests with a rush. However, I had to write a custom keyboard event handler: https://github.com/pikvm/kvmd/blob/master/hid/pico/src/ph_usb.c |
I'm trying to use an Arduino micro as Bootkeyboard to control a KVM Switch. It seems the Keyboard is not recognized at all.
Are there different modes i could try?
The KVM support a Hotkey which is 2x CTRL_LEFT + 1 to 4 would be glad getting it to work so i can enter the same input on multiple pcs.
The code works fine on Windows and could be visualized with the on screen keyboard.
The text was updated successfully, but these errors were encountered: