BeauSlim
Posts: 130
Joined: Mon Jul 31, 2017 10:02 am

USB Gadget mode on new 3 A+?

Mon Dec 03, 2018 8:45 pm

Since the new A+ only has one USB port, I'm wondering if it supports gadget mode like the Zero/W does. For example, so you can connect to a PC for Ethernet over USB.

DirkS
Posts: 10651
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: USB Gadget mode on new 3 A+?

Mon Dec 03, 2018 8:58 pm

Theoretical: yes. In practice: dunno.

There's a problem. (see viewtopic.php?f=63&t=227044#p1392654)
USB boot is enabled by default (like on the 3B+) and apparently that's not compatible with gadget mode.

W. H. Heydt
Posts: 14836
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: USB Gadget mode on new 3 A+?

Tue Dec 04, 2018 5:31 am

Search on using gadget mode with the A+. The Pi3A+ should be able to do it the same way. Because the two boards have "normal" USB-A connectors, they lack the extra line that permits the system to switch between master and slave the way the Pi0/Pi0W do. So you're going to be either a master USB device or a slave USB device and the only way to switch is to edit cmdline.txt (IIRC) and possibly config.txt.

But other than those considerations...yes, you should be able to run a Pi3A+ in gadget mode.

drgeoff
Posts: 12057
Joined: Wed Jan 25, 2012 6:39 pm

Re: USB Gadget mode on new 3 A+?

Tue Dec 04, 2018 11:11 am

@W. H. Heydt
You should read what DirkS linked to.
Quis custodiet ipsos custodes?

hippy
Posts: 10219
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: USB Gadget mode on new 3 A+?

Tue Dec 04, 2018 1:25 pm

drgeoff wrote:
Tue Dec 04, 2018 11:11 am
@W. H. Heydt
You should read what DirkS linked to.
Everyone needs to bear in mind that "USB Boot" means two things; "USB Host Boot" where a Pi can boot from a USB memory stick or HDD, which works on Pi 3A+, and "USB Device Boot" where the Pi connects to a PC without an SD Card and can have bootcode.bin etc pushed into it over USB, which doesn't currently work on a Pi 3A+.

But "USB Device Boot" not currently working does not preclude the Pi 3A+ being used in gadget mode. The Pi 3A+ must be booted from SD Card and the configuration must be set-up to explicitly enable gadget mode because the OTG ID signal on the 3A+ is tied to 0V so, by default, it only enables host mode.

You will also need to find or build a USB-A to USB-A cable to use gadget mode on a Pi 3A+. The power line in that should be cut if the Pi is powered by its own external PSU.

fruitoftheloom
Posts: 27025
Joined: Tue Mar 25, 2014 12:40 pm

Re: USB Gadget mode on new 3 A+?

Tue Dec 04, 2018 1:41 pm

hippy wrote:
Tue Dec 04, 2018 1:25 pm
drgeoff wrote:
Tue Dec 04, 2018 11:11 am
@W. H. Heydt
You should read what DirkS linked to.
Everyone needs to bear in mind that "USB Boot" means two things; "USB Host Boot" where a Pi can boot from a USB memory stick or HDD, which works on Pi 3A+, and "USB Device Boot" where the Pi connects to a PC without an SD Card and can have bootcode.bin etc pushed into it over USB, which doesn't currently work on a Pi 3A+.

But "USB Device Boot" not currently working does not preclude the Pi 3A+ being used in gadget mode. The Pi 3A+ must be booted from SD Card and the configuration must be set-up to explicitly enable gadget mode because the OTG ID signal on the 3A+ is tied to 0V so, by default, it only enables host mode.

You will also need to find or build a USB-A to USB-A cable to use gadget mode on a Pi 3A+. The power line in that should be cut if the Pi is powered by its own external PSU.

An alternative is to use a USBNET Cable:

viewtopic.php?t=131042

User avatar
thagrol
Posts: 5215
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: USB Gadget mode on new 3 A+?

Tue Dec 04, 2018 1:49 pm

On the A+ USB gadget mode can be enabled by adding

Code: Select all

dtoverlay=dwc,dr_mode=peripheral
to /boot/config.txt I'd expect the 3A+ to be the same.

You'l then need to load the required g_* module.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

BeauSlim
Posts: 130
Joined: Mon Jul 31, 2017 10:02 am

Re: USB Gadget mode on new 3 A+?

Tue Dec 04, 2018 11:24 pm

Thanks to all for the info and clarification of the caveats. Since I'll be running from SD and not looking to have it boot from the USB, it sounds like it will work for my application.

StephenDone
Posts: 1
Joined: Wed Apr 10, 2019 1:55 pm

Re: USB Gadget mode on new 3 A+?

Wed Apr 10, 2019 2:01 pm

thagrol wrote:
Tue Dec 04, 2018 1:49 pm
On the A+ USB gadget mode can be enabled by adding

Code: Select all

dtoverlay=dwc,dr_mode=peripheral
to /boot/config.txt I'd expect the 3A+ to be the same.

You'l then need to load the required g_* module.
Thank you @thagrol.

I can confirm that the addition of the dr_mode to my dtoverlay config allowed an sdcard previously used in a Pi Zero and configured as an HID keyboard to work just as before in a PI 3A+. My line was...

Code: Select all

dtoverlay=dwc2,dr_mode=peripheral
I.E. the PI 3A+ definitely does support USB OTG. But yes, it does not work until you add this extra config option.

Cheers

Steve

malina123
Posts: 1
Joined: Wed Nov 20, 2019 4:55 pm

Re: USB Gadget mode on new 3 A+?

Wed Nov 20, 2019 4:59 pm

Would it be possible to have RPI 3 A+ act both as a host for a USB device (a keyboard) and as a USB OTG device (pass modified text to some other device)?

Unfortunately, I wasn't able to understand that based on this and linked threads.

User avatar
thagrol
Posts: 5215
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: USB Gadget mode on new 3 A+?

Thu Nov 21, 2019 10:47 am

malina123 wrote:
Wed Nov 20, 2019 4:59 pm
Would it be possible to have RPI 3 A+ act both as a host for a USB device (a keyboard) and as a USB OTG device (pass modified text to some other device)?

Unfortunately, I wasn't able to understand that based on this and linked threads.
No. There is only one USB controller. It can do either host or device mode but not both at the same time.

I understand there are such thing as SPI USB controllers though I've not experience of them. Adding one of those might help.

The only pi that can do simultaneous host and device/gadget mode is the 4B. Host on the four USB A ports, device/gadget mode on the USB C port.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

Return to “Advanced users”