I would like to see someone with a working example in bash reading and writing USB commands to Windows using this gadget and it will answer and help me learn.
Judging by its github repo, xg_multi is nothing more than a setup and management script for the USB gadget(s). As such it's extremely unlikely to be the culprit.
Forget xg_multi. You're getting too hung up on it being the problem and it almost certainly isn't.
Forget your various test code. There are problems with it that will stop it from working (see above).
Perform the minimal test as I outlined above and will repeat here:
- Remove everything related to xg_multi or flash a clean image and do not install it.
- Add the following to the end of your /boot/firmware/config.txt",dr_mode=peripheral" is not strictly required but it's useful for this test as it prevents any potential problem with the ID pin in the microUSB socket.
Code:
[all]dtoverlay=dwc2,dr_mode=peripheral - Add the following to the end of your /boot/firmware/cmdline.txtMake sure everything is still on a single line. (word wrap in the editor doesn't matter)
Code:
modules-load=dwc2,g_serial console=ttyGS0,115200 - Shutdown your Pi
- Plug it into your USB host and let it boot.
- On your USB host device:
- Open your preferred terminal comms application
- Connect to the serial port provided by the zero at 115200 and the default 8n1
- Hit return a time or two
You should see a login prompt and be able to login wit the normal username and password you use for the zero.
- Assuming the login is successful remove console=ttyGS0,115200 from /boot/firmware/cmdline.txt
This will free up /dev/ttyGS0 for other uses after a reboot. - Reboot the zero.
Assuming all goes well (and it should) we know the USB serial gadget is working correctly.
Any problems you get when running your code are 99.9% certain to be as a result of your code.
Does it need to be a separate shell script launched at boot ? I won’t have access to the device it needs to be all automated at power up.
Does what need to be a separate shell script?
For running stuff at system startup see Running A Program At Start Up A Beginner's Guide
And why are you reinstalling everything every time? Pulling power may corrupt your SD card but it may not and you can edit both config.txt and cmdline.txt on any computer that has an SD card reader and that understands FAT32 (yes, that includes Windows).
And, while I haven't done it recently, I have used WiFi , the serial gadget, and the ethernet gadget on a zeroW at the same time. I even wrote a book about it: USB Ethernet Gadget A Beginner's Guide
Statistics: Posted by thagrol — Fri Jan 30, 2026 12:47 am