-
Notifications
You must be signed in to change notification settings - Fork 201
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
There is a better idea, Implementing HID KM with ESP32C3 BLE. #164
Comments
Sounds nice - I couldn't use it. It will be a different device for end users without security needs. My use case includes that I'm forbidden by rules at my work to use any keyboard that is connected wireless. Making your project secure includes having a secure bluetooth stack which until now proved many times to be a wrong assumption. Another point for me would be the needless use of batteries. That is not sustainable. There is no reason I can see that your idea couldn't work with one computer being connected through usb providing the power needed to drive your board (or just use an external usb power adaptor which in on most desks anyway. I'd build or buy one for testing if it would work without a battery just for the fun of it and maybe to give it to my son to switch between his mobile and his desktop. On my desktop I couldn't use it for security reasons. |
@chri2 If for absolute safety, then wireless and lithium batteries are indeed not a good idea. Both will have certain security risks. |
Maybe this project could be a base for your idea: https://github.com/Noskcaj19/hardware-kvm |
This is a cool idea - I've investigated ESP32 initially but it didn't have usb. My plan is to expand the nunmber of devices one can control, my initial thoughts were most people who would use this need 2, a small number might need 3 and very few people need 4 or more. I agree this would be a desirable feature for sure, I occasionally needed a third output, maybe something happens later this year :) Some of the technical limitations mentioned were actually chosen on purpose, like omitting Bluetooth - I simply don't believe there is a vendor who could implement this in a way that stands the test of time (https://github.com/engn33r/awesome-bluetooth-security for reference). Bluetooth stacks are often written by coders faced with unrealistic timelines and then never ever patched after vulnerabilities are discovered. The protocol itself is a bit too complicated for a secure implementation. If you're still interested in helping out, I'd be curious how cheap this board could be made, i.e. what the ultimate price point is for small(er) batches. I'll be working on a new PCB variant when time permits... |
Firstly, I would like to share a simplified version of the deskhop project that was created using the Raspberry Pi PICO development board and RP2040 * 2. The PCB was redesigned and streamlined to match the metal casing. Flashing the firmware of the desktop hop project has a very good effect. I found a similar project for ESP32C3 BLE: USB-HID-BLER, URL: https://github.com/dnstzzx/usb-hid-bler
Regarding small batch costs: I don't know if you're interested in helping write software? I can provide you with hardware. |
I really like your board and box! Unfortunately I don't have the time resources to rework it with ESP32, but if you want to work towards redesigning some of the existing hardware please let me know :) |
In general, seamless switching of a Bluetooth keyboard and mouse between devices sounds cool |
That's pretty cool, I like the board! Maybe consider adding digital isolators to the outputs? What's the availability of those WCH9329 and what's the chip next to the left USB-A connector? |
1、 The CH9329 is currently in mass production and can be easily purchased, with a price of about |
I found this bluetooth-usb-peripheral-relay project (Bluetooth to USB HID relay using a Raspberry Pi Zero ) earlier today on ycombinator, which reminded me that I recently wanted to check for a new deskhop firmware. So here we are - maybe interesting for you :) |
Yeah 115200 is pretty sluggish, but I've ordered one sample chip to play around with it and test how feasible it would be. Interesting concept you've got here. I'm toying with the idea of putting a very low cost linux system-in-package like the f1c100s to handle all the incoming usb host work leveraging the linux kernel drivers for all the strange usb hardware out there and some super-cheap usb-capable microcontrollers for the outputs. |
Yes, this is exactly what I had in mind (plus some usb isolators :-))) and I have to say I'm impressed how quickly and accurately you manage to iterate through designs. This would allow for just 1 master without the complicated logic to sync with the other node, and modular slaves in any quantity desired. I'm not sure how much more expensive it would get though, albeit f1c100s is quite affordable from what I've seen. For the USB MCU, something affordable like STM32F042 with internal flash and no requirements on external quartz oscillator. I'm waiting for one f1c100s board in the mail already, so then I'll try playing with it and see how quickly I can get it to boot and how reliable it would be. I think this would resolve any compatibility issues people might have and also allow for virtually unrestricted number of outputs. |
The F1C100S typically takes 3-5 seconds to boot and enter the system. (Set the boot wait time to 0, and try to keep the drivers as minimal as possible). Below is a rough diagram I’ve drawn. It uses STM32F042F6P6 * 4 as the MCU connecting 4 PCs, with ADUM1201BR*4 as isolators for serial communication. The F1C100S serves as the main controller, and the USB-OTG interface is connected to a USB-HUB chip, which provides 4 USB-HOST interfaces for connecting keyboards/mice. An additional Type-C interface is included for power supply, while also connecting to the CH340N chip for a serial bridge, which links to UART0 of the F1C100S for debugging. Regarding configuration via a web page, I think the STM32F042's USB can virtualize CD-ROM/HID/keyboard/mouse at the same time, using the CD-ROM to store the web page and using HID for communication. All UARTs of the STM32F042 can be connected to UART1 of the F1C100S, with different addresses used to distinguish them in the custom communication protocol. Finally, there's one question: The F1C100S can only download firmware via USB-OTG, but currently the USB-OTG is occupied by the USB-HUB. How should we download the firmware? (Should we add an SD card and use it to boot the system? I don't think this is a good solution.) The overall cost, including PCB + materials + metal enclosure + production cost = (approximately $15). |
As for the boot time, I am secretly hoping to get it down to 1 or 1,5 seconds, otherwise it would be just too annoying. For the firmware, I'll see what's possible once I receive the chip - with the post office acting up these days, it might take a while. I think TI ISO7721DR is cheaper than ADUM. One isolator could be removed and the soc connected to that output port side without isolation, maybe even powered by it. I wonder if there are more affordable SOCs like Nuvoton NUC980 series that have a bunch of usbs so one could remove a bunch of chips and maybe replace them with one usb isolator per port maybe. Or ditch everything and leave just one FPGA and synthesize a risc-v + 2 USB host controllers and a couple of devices :) |
The NUC980 is quite expensive at around $8; at this price, you could buy 11 STM32F042s. The isolation chips for the USB bus are much more expensive than the UART isolation chips (ISO7721DR / ADUM). |
Well, my idea is to make it as cheap as theoretically possible without sacrificing safety or usability. I've also noticed nxp i.mx6ulz running around 4$ in quantities, and can boot sub-second. I'll see what f1c100s can pull off in terms of speed and power consumption. Do you know is there any documentation for f1c100s? I was only able to find https://linux-sunxi.org/F1C100s with a 21 page document. It would ideally fit into a 15$ budget altogether. Do you think that's doable? Many thanks for your kind help! |
The NXP i.MX6ULZ chip is quite difficult to purchase in China, and it comes with a very high price. Additionally, it requires extra components such as DDR memory and a power management chip, which further increase the overall cost. The BGA packaging also adds to the production costs. Using this project for firmware compilation, I have tested and confirmed that the compilation can be successfully completed.
linux kernel version: 5.4.180 |
F1C100S+xt25f128 (16MB NorFlash), prune uboot, prune kernel, modify partition size, currently the fastest startup speed takes 8 seconds. 18.mp4 |
Having a Linux kernel is desirable in this case because a lot of the specialty HID drivers, fixes and workarounds you basically get for free (as well as reliable HUB operation). Faster boot can be achieved with some tricks (well, a LOT of them) - you have SPL loading the kernel directly as opposed to loading the main u-boot, that saves you ~ 0.2 sec. Slimming the kernel way down (since all you need is usb, serial and running a single binary from ramdisk) helps, also providing the loop calibration values explicitly (lpj) saves a bit of time, reducing serial output to quiet, skipping some generic code in SPL, doing MMC with 52 mhz, etc... the time spent in BROM you can't do much about, but the rest is lightning-fast and I'd say could be doable. |
If that's the case, using the F1C100S as the main controller is indeed sufficient. Before that, I need you to provide an example firmware with very simple functionality. The USB-OTG interface is set to USB HOST mode and can be connected to a keyboard/mouse to print all HID reports to UART0.This makes it easier for me to test some hardware functions. |
I think that would work. Maybe not dealing with flash completely and just putting a microSD card reader in there would not be a bad idea? A corrupted storage or even initial bootstrap is quite complicated with an SPI flash. MicroSD is something you can easily remove, plug into a PC and fix whatever needs fixing. Images would be read-only and run from RAM completely, so only initial boot would be doing any reading. The chip has 3 UARTs internally, and leaving one for console/debug makes sense. I'd probably go with uart0 = console, uart1 = outputs 1 and 3, uart2 outputs 2 and 4. This way on a 2-port variant you can have completely dedicated bandwidth, and on a 4-port you can differentiate using addresses, yet never have neighbors on a same port. This needs some more testing and proof of concept - I'm not sure what the highest serial baudrate is and if driver behaves OK, hardware docs specify a divisor register but there are also open questions regarding DMA support, usb otg functionality etc... I'll try testing the usb and some serial experiments soon :) |
Currently, I am designing a hardware PCB.
Specifications: https://www.stcaimcu.com/data/download/Datasheet/STC8H-EN.pdf Would you be willing to use the STC8H2K08U? This could save approximately $2 in costs. If you have any other better suggestions, please let me know. |
Wouldn't it be more convenient (from the cable management perspective) to put all the connectors on one side? |
@ak66666 Thank you for your suggestion. I will carefully consider placing all cables on one side. |
@hrvach Do you have any thoughts on the suggestion of placing all cables on one side? Insert the log of USB HUB
Log of inserting mouse on USB HUB
Log of inserting a USB flash drive into a USB HUB
|
No, thank you, I am looking forward to get your device when it becomes available. |
@qq8322302 I am waiting on a sample of WCH IC - CH32V203 that one is supposed to be both cheap and widely available there, I'll see if I can get one working to do anything meaningful. As far as STC8H2K08U goes, never heard of that one before. Can you point me out to e.g. Aliexpress page where a sample could be ordered? I'm open to trying out anything. Regarding MMC/USB - as long as initial MMC boot works with USB devices still plugged in, it's fine. I have to test this situation locally, been busy with other bugfixes... My idea is to use the MMC only for a super fast initial boot, loading kernel + micro ramdisk with just a single tiny binary to RAM and execute from there. All connectors on one side is more difficult to route and easier to confuse inputs with outputs. Design of the enclosure would also play a role here. I'd personally put 2 mouse/keyboard ports on one side and 4 outputs on another, so they are grouped by function and type, also aligning with the intuition most people have. Imagine your grandma looking at 6 USB ports and trying to figure out what to plug in where. :) |
The price of CH32V203F6P6 is basically the same as that of STM32F070F6P6, and a 3.3V power supply still requires a 5V to 3.3V LDO. STC8H2K08U: https://nl.aliexpress.com/item/1005007265779986.html?algo_pvid=8ff68981-eee4-43fc-abb3-8773e392f0c3 |
I missed this entired thread and was getting more hyped the more I read, amazing! All the improvements could be applied to the actual model? Replace micro usb with usb C is definivetly an improvement (trying to get rid of all non-USBC/A usbs here at home :P). |
https://www.etsy.com/ca/listing/1763041320/deskhop-jr-a-keyboard-and-mouse-switch |
This looks pretty awesome! Any chance to try out the 32v203 version, since tinyusb has support for that one? Would your email be 8322302@qq dot com? |
I am debugging CH32V203F6P6, which only has one UART and shares pins with USB. WCH FAE recommends replacing it with CH32X035F7P6. I need to purchase some again and I will test it after a few days. |
sysimage-sdcard.zip |
hi |
Will the support external power for USB devices? |
Hello,hrvach:
I am an electronics enthusiast from China and came across your project by chance. It is a fantastic project that can solve many operational problems with multiple hosts.
I have an idea now, to use ESP32C3 BLE to simulate keyboard, mouse, and communication with multiple devices, and to add lithium batteries to get rid of wiring harnesses.
My thoughts:
ESP32C3 serves as the main controller, and after turning on BLE, it broadcasts four names: KM1, KM2, KM3, and KM4. Four PCs are connected to each of these four BLE names.
The IO of ESP32C3 can use software to simulate USB-HOST mode for connecting keyboards and mice.
(ESP32C3's ble_hid_device_demo: esp-idf-v5.2.1/examples/bluetooth/bluedroid/ble/ble_hid_device_demo)
(ESP32C3 software simulation USB-HOST: https://github.com/sdima1357/esp32_usb_soft_host )
ESP32C3-FH4, In China, it only costs RMB 5 yuan, and materials such as batteries and casings are also very cheap. I can design and produce PCB hardware, but my software level is not very good. I wonder if you are interested in researching together?We look forward to your reply.
The text was updated successfully, but these errors were encountered: