Open qq8322302 opened 1 month ago
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. If it's for convenience and a clean desktop, then wireless and lithium batteries will definitely be more convenient. This involves different usage scenarios.
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
This project is to convert wired keyboard and mouse to BLE. I built a simple circuit and tested it. The mouse can be used normally, but the keyboard cannot be used.
I have already drawn the PCB according to my idea, and it will take about a week to produce it. I will test it first when the time comes.
There are the following software issues that need to be addressed:
Regarding small batch costs: PCB+materials+shell+production, about RMB 55 yuan. ( 8$ or 8€ )
I don't know if you're interested in helping write software? I can provide you with hardware.
Additionally, for users who prioritize safety and do not want to use BLE, we can use wired USB. I also have a better idea that can be extended to hardware solutions with 4 or even 8 hosts. It can be expanded using RP2040 1+analog switch+CH9329 N, and the price is also not expensive. RP2040 is connected to a keyboard and mouse, and at the same time, it is connected to 4 analog switches through UART * 1. By selecting which CH9329 to communicate with through GPIO, it can easily communicate with 1 out of N PCs. The disadvantage is that it can only communicate with one CH9329 at a time and cannot communicate simultaneously. If interested, I can also create this form of hardware, but I also need your software support.
UPDATE
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 :)
I have done some research on the ESP32C3 and wanted to implement deskhop functionality, but it turned out to be quite difficult and challenging. Additionally, the security of BLE is not very high, so I decided to abandon the ESP32C3-BLE. I have redesigned a new board as described above, using 1RP2040 + 4CH9329, which can control up to 4 devices. The hardware is already in production and should be available around the 8th. This hardware architecture can easily control 4 devices or even more, with theoretical support for up to 254 devices. Additionally, the software code modifications for deskhop functionality are minimal; it only requires replacing the USB devices section with UART. Currently, I am trying to modify your software, but it's somewhat challenging for me. Would it be possible to invite you to collaborate on the software development?
The prototype of this circuit board is already in production and should arrive in my hands around November 8th.
[All of the above content was translated using translation software from Chinese to English, so there may be some inaccuracies in expression.]
In general, seamless switching of a Bluetooth keyboard and mouse between devices sounds cool
I am trying to modify the deskhop software, but it will take some time. PCB size: 94mm * 49mm
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 $0.3-0.4$ (RMB: 2-3). 2、 The chip next to the left USB-A connector is a USB-HUB chip, which is used to expand the USB-HOST port of the RP2040. In the Pico-PIO-USB project, I was unable to make it support two USB-HOST ports, so I used a USB-HUB chip for expansion. If you know how to make the Pico-PIO-USB support two USB-HOST ports, please let me know, and I will modify the PCB, which could save one USB-HUB chip. 3、 The two buttons are for reset and boot, used to download firmware during the debugging process. A yellow wire is the UART-TX, used to monitor communication data during debugging. 4、 The two USB-A ports do not require an additional ESD chip, as ESD protection is already integrated into the USB-HUB chip. 5、 4*CH9329 USB buses might require an additional ESD chip, but I don’t think this is very important. 6、 I do not plan to add digital isolators because, after adding them, the four CH9329 Type-C ports would no longer be able to power the RP2040, which would require an additional power supply for the device. Once the software for the RP2040 Type-C port is debugged, I intend to remove it and not use it for power. If digital isolators must be added, then four would be required to isolate all four CH9329 chips. Additionally, the RP2040’s Type-C port would need to be retained for power supply purposes.
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 :)
Here’s the English translation:
I have modified some of the software functions on the original board, and now it is able to support the communication between 4 PCs. Due to issues with the USB hub chip and other factors, I redesigned the PCB, adding digital isolation chips to isolate the 4 PCs from the board. The board is powered via TYPE-C from the RP2040. The CH9329 has a maximum UART baud rate of 115200, so the theoretical maximum mouse report rate is around 400Hz. During testing, I found that when a 1kHz mouse was connected, the movement became sluggish. Optimization will be needed in the software for this in the future.The new PCB is expected to arrive in about 7 days, and I will conduct testing once it arrives.
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.
Is it as I understand it from the image above? Using the Linux kernel driver to handle USB transactions is a great idea, as it allows for better compatibility with various devices. The MCU here would also need to develop its own software. If you need such hardware, I can also make it for you.
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). I suggest you first test with the F1C100S to check its compatibility with various unusual keyboard devices when used as a USB host.
Below is a rough diagram I’ve drawn. It uses STM32F042F6P6 4 as the MCU connecting 4 PCs, with ADUM1201BR4 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 ISO7721DR and ADUM are roughly the same price, mostly around $0.36 each, so four would cost about $1.44. The F1C100S is approximately $2.2, and a metal case is about $2. Four STM32F042s would cost around $3. The factory production cost per unit is $3 (for a small batch of 30-50 units, the more you produce, the cheaper it gets). The Type-C connector + resistors and capacitors + flash + USB hub + power IC + PCB is about $3.4...
The isolation chips for the USB bus are much more expensive than the UART isolation chips (ISO7721DR / ADUM). I'm not sure what your ideal price point is. Perhaps we can look into streamlining or removing some components to reduce costs. Could you share your target price or the budget constraints you're working within?
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.