thagrol / Guides

405 stars 35 forks source link

Setting dtoverlay=dwc2 at runtime? #18

Closed johngebbie closed 1 year ago

johngebbie commented 1 year ago

Hi thagrol. I'm writing a simple command for the the Rasperry Pi USB On-The-Go functionality, so you can do echo "type Hello!" | gadget and the like. I was wondering if it's possible to have the script configure everything at runtime, so you don't need to put dtoverlay=dwc2,dr_mode=peripheral and modules-load=dw2,g_hid in the /boot files.

I know there's modprobe and there seems to be a dtoverlay util on Rasperry Pi Os but not elsewhere (my Pi is on Void Linux). I also found this page, where (right at the bottom) they use the /sys file system: https://www.96boards.org/documentation/consumer/dragonboard/dragonboard410c/guides/dt-overlays.md.html

Here's my little project is here if you're interested: https://git.sr.ht/~geb/gadget

thagrol commented 1 year ago

Closing this as it's not really a "Guides" issue. However...

As far as I know "dtoverlay=dwc2" must be in config.txt. Without it A model Pi and zeros get the host only dwc driver. 2711 based Pi (4B and later) don't get the controller enabled at all.

Also AFAIK, the dtoverlay util on RPiOS cannot change the base device tree setup by the bootloader. It can load (and unload) additional overlays but I have not tested this with dwc2 and USB gadgets.

I can make no comment on that board nor on its support.

For one way to setup a USB gadget vis configfs (/sys/...) see https://github.com/thagrol/usb-gadget/blob/master/set_id.py