Please comment if I'm missing anything else that may be helpful to include.
Some initial thoughts:
If the ID pin on the USB Micro-B is shorted
Shorted to what? Ground? Yes. +5V? No. It matters. Especially to someone who might be building a DIY cable. It should be left floating (i.e. not connected to anything) when peripheral mode is required.
In the event that software is configured in peripheral mode, shorting the ID pin on the USB cable will override the software settings.
Have you actually tested that? My experience is that when you force the mode to either host or peripheral the ID pin in the microUSB socket is ignored. It is only when you set dr_mode=otg or don't include dr_mode at all (because the default is otg) that the ID pin functions.
I'd also like to point out that just loading the dwc2 devicetree overlay doesn't do anything useful. Yes, it can put the controller into device mode but it doesn't present any usable USB device to either the USB host or to Linux on the Pi. Further configuration is needed for that.
For example:
USB Ethernet Gadget A Beginner's Guide
USB Mass Storage Gadget - A Beginner's Guide
Full disclosure: I wrote those.
Finally, it's not just the zero series that can work as USB devices. A, A+, 3A+, 4B, 400, Pi5, 500, and CM series can too. 4B and later via their USB C ports The others via their single USB A ports. None of these can detect and swap between roles as their connectors do not have an ID pin. IIRC on the A, A+, and 3A+ the ID pin on the SoC is permanently pulled low so if you want to use dwc2 in peripheral mode you must include dr_mode=peripheral when loading the overlay. On 4B and later it's floating so you need dr_mode=host otherwise you get device/peripheral mode. CM series behaviour is entirely dependent on the design of the carrier board.
Statistics: Posted by thagrol — Thu Feb 06, 2025 12:22 am