How to enable USB OTG mode on a Pi Zero

In order to boot into USB OTG mode, connect your Pi Zero through the OTG socket with your host PC. If everything was configured correctly, the usb0 ethernet device should pop-up during boot (check it with ‘dmesg’):

[ 4.541481] dwc2 20980000.usb: DWC OTG Controller
[ 4.541600] dwc2 20980000.usb: new USB bus registered, assigned bus number 1
[ 4.541707] dwc2 20980000.usb: irq 33, io mem 0x00000000
[ 4.542289] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 4.542321] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 4.542344] usb usb1: Product: DWC OTG Controller
[ 4.542362] usb usb1: Manufacturer: Linux 4.4.21+ dwc2_hsotg
[ 4.542381] usb usb1: SerialNumber: 20980000.usb
[ 4.543838] hub 1-0:1.0: USB hub found
[ 4.543970] hub 1-0:1.0: 1 port detected
[ 4.743067] using random self ethernet address
[ 4.743122] using random host ethernet address
[ 4.743151] using host ethernet address: AA:BB:CC:DD:EE:FF
[ 4.744726] usb0: HOST MAC aa:bb:cc:dd:ee:ff
[ 4.744876] usb0: MAC 8e:fd:db:d9:2a:f7
[ 4.744969] using random self ethernet address
[ 4.745009] using random host ethernet address
[ 4.745172] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
[ 4.745199] g_ether gadget: g_ether ready

On your host-PC, a new network device, named usb0 should also appear (sudo ifconfig):

usb0 Link encap:Ethernet HWaddr AA:BB:CC:DD:EE:FF
 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 RX packets:463 errors:0 dropped:0 overruns:0 frame:0
 TX packets:3491 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:120418 (117.5 Kb) TX bytes:1696381 (1.6 Mb)

To configure the USB ethernet connection, open NetworkManager’s connection editor and chose usb0 (AA:BB:CC:DD:EE:FF)  from the drop-down menu. On the IPv4 tab, select ‘Link-Local’.  Pressing ‘connect’ establishes a connection to the Pi Zero and you should see that usb0 has an IP address (‘sudo ifconfig’):

usb0 Link encap:Ethernet HWaddr AA:BB:CC:DD:EE:FF
 inet addr 169.254.9.176 Bcast:169.254.255.255 Mask:255.255.0.0
 inet6 addr: fe60::84b:81ff:fed7:b55f/64 Scope:Link
 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 RX packets:472 errors:0 dropped:0 overruns:0 frame:0
 TX packets:3578 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:123658 (120.7 Kb) TX bytes:1717736 (1.6 Mb)

Now you can login to your Pi Zero with:

ssh pi@raspberrypi.local
or
ssh pi@169.254.64.64

Leave a Reply

  Subscribe  
Notify of