raspberry-piusbhidusb-otg

pi-zero usb otg port identified as unknown device during boot


I currently have a pi zero which acts as a bluetooth keyboard which - when attached to a computer - types text read from the SD card. I followed this tutorial https://www.rmedgar.com/blog/using-rpi-zero-as-keyboard-setup-and-device-definition. I use only the USB "Data" port, to power it up and to send data.

This setup works really fine on nearly all computers I tested it on, just on some Windows 7 systems it is not working at all. The system where it is not working on identify the pi zero as "Unknown device" and then never "re-identify" it as the keyboard which it is supposed to be.
All other systems first identify the device as "Unknown device" and after some seconds "re-identify" it as the actual keyboard. IMO the problem is the one mentioned by scruss in this post: https://raspberrypi.stackexchange.com/questions/60056/cant-see-raspberry-pi-zero-via-usb-otg-on-windows-10

I'm looking for a possibility to fix this problem. Is there some possibility to configure the pi zero in a way that during boot it does not identify as any USB device. Maybe that during boot the data USB port acts only as a power USB port. Or can I turn the USB port off and on after a boot so that form the computers point of view it looks like the usb devices is removed and reattached??


Solution

  • I fixed that with the help of a colleague. The solutions seems super simple - just remove the usb gadget and add it again. The code necessary is equally simple:

    #Remove usb gadget    
    echo "" > UDC
    #Add it again
    ls /sys/class/udc > UDC