I was just reading some USB docs today (because that's what I do for fun, of course) and I saw this mention of USB initialization. Maybe this explains why you've had some trouble getting USB enumeration to work reliably?
A USB device must indicate its speed by pulling either the D+ or D- line high to 3.3 volts. ... These pull up resistors at the device end will also be used by the host or hub to detect the presence of a device connected to its port. Without a pull up resistor, USB assumes there is nothing connected to the bus. ... For example Philips Semiconductor has a SoftConnectTM technology. When first connected to the bus, this allows the microcontroller to initialise the USB function device before it enables the pull up speed identification resistor, indicating a device is attached to the bus. If the pull up resistor was connected to Vbus, then this would indicate a device has been connected to the bus as soon as the plug is inserted. The host may then attempt to reset the device and ask for a descriptor when the microprocessor hasnít even started to initialise the usb function device.
The new version of the usb adapter board arrived, and seems pretty good. adb passthrough works and I can chain 2 of these together to use both a usb keyboard and a usb mouse. pre-adb checks out too.
I recently got another usb keyboard. Oddly, this one enumerates fine much more reliably than the keyboard I was testing with, but after enumeration, I don't get any usb packets from it. Pretty odd. I haven't dug all that deep to figure out why.
So, it's basically that and enumeration reliability that are the remaining issues.
If anyone wants to give it a shot as-is, I can send off some adapter boards. I've only got one of the f4 discovery boards left that I can send, so that's available too.
I'd be very, very interested in buying a couple of your adapters should you decide to build some of them - both the PS/2 and the USB models look extremely useful for resuscitating our beloved, old Macs which have lost their own original keyboard and mouse!
Thanks! The PS2 version is fairly stable at this point, and several people are using them. I've got the parts to build some adapter boards handy, but I'll need to order more discovery boards if you're interested.
The USB version seems to be working ok with mice for me, but I think the keyboard part needs some extra tuning. I'm not quite confident in the keyboard part yet.
The problem with the USB adapter is it doesn't reliably detect when a keyboard or mouse is plugged into it. The ADB and pre-ADB code is the same as the PS2 adapter, so that works OK. I've had some luck just resetting the adapter until the device is detected, although I'm still a little concerned about the real cause of the problem.
This weekend, I tried redoing the entire USB stack around another USB HID host library I came across, but the same problem remained. Still a todo item I guess.
Is it possible to detect when a PS2 keyboard/mouse is present, or only when one is actively sending data? If you can check for PS2 presence, then you could try this ugly band-aid: if no PS2 keyboard/mouse is present AND no USB devices are detected, make the firmware reboot itself after 5 seconds. That wouldn't interfere with anything, and if repeated manual resets eventually lead to successful USB detection, the reboot loop will stop.
If the presence of a PS2 keyboard/mouse can't be detected passively, then you could add a manual jumper or switch to choose between PS2 or USB peripherals. Then only do the reboot loop hack if USB is selected but no peripherals are detected.
Even on reset, with the device connected, it doesn't detect correctly. I should investigate, but I'm eyeing ChibiOS, which supports the STM32F4. I haven't tried ChibiOS before, so it seems like an opportunity to mess with something new, while potentially fixing an issue.
I am thinking about converting my ADB keyboards/mice wireless, switchable.
Is there any documentation out there on ADB and its structure? I am sure there is, just not sure where.
I was thinking about having a single keyboard, and single mouse since I have a rather small desk. But I may be bouncing between my file server, and a machine that I am working on. So i can switch between the two machines via a bluetooth link between the keyboard, and a BT ADB receiver hanging off the back of the machine, well, each machine. I just press a button, pick the link and links up
I started messing around with creating a 3D printed case for the ps2 adapter:
I was thinking about making it fully enclosed around the adapter board, but with connectors out both sides plus the top, the top part becomes kind of wire-frame-like and not very sturdy. It doesn't seem to buy a whole lot to enclose the top, since it's basically all connectors.