# Connecting to Raspberry Pi Zero W over USB Ethernet



## jdoolin (Jan 25, 2022)

I have a Raspberry Pi Zero W with a minimal Raspbian installed, and I have connected a ZeroStem (https://zerostem.io/) to it.  It's basically a shim that allows you to plug the Pi in directly to a USB port and it will show up as a serial or ethernet device. I've already gotten it working as a serial device no problem, but I haven't been able to get my FreeBSD 13 laptop to talk to the Pi over USB Ethernet. 

The Pi has a USB ethernet device and I've given it a static IP on the usb0 interface:


```
$ ifconfig usb0
usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.7  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::621f:26ab:3e2d:4440  prefixlen 64  scopeid 0x20<link>
        ether d2:63:09:b1:67:76  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0
192.168.2.0     0.0.0.0         255.255.255.0   U         0 0          0 usb0
```

The device shows up as follows in FreeBSD:


```
Jan 25 10:33:28 isis kernel: ugen0.2: <Linux 5.10.63+ with 20980000.usb RNDIS/Ethernet Gadget> at usbus0
Jan 25 10:33:28 isis kernel: cdce0 on uhub0
Jan 25 10:33:28 isis kernel: cdce0: <RNDIS Communications Control> on usbus0
Jan 25 10:33:28 isis kernel: cdce0: No valid alternate setting found
Jan 25 10:33:28 isis kernel: device_attach: cdce0 attach returned 6
Jan 25 10:33:28 isis kernel: cdce0 on uhub0
Jan 25 10:33:28 isis kernel: cdce0: <RNDIS Ethernet Data> on usbus0
Jan 25 10:33:28 isis kernel: cdce0: faking MAC address
Jan 25 10:33:28 isis kernel: ue0: <USB Ethernet> on cdce0
Jan 25 10:33:28 isis kernel: ue0: Ethernet address: 2a:6e:88:22:ab:00
```

I then assigned a static IP address to the ue0 interface:


```
$ ifconfig ue0
ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether 2a:6e:88:22:ab:00
    inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
$ netstat -4rn
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            192.168.1.1        UGS       wlan0
127.0.0.1          link#2             UH          lo0
192.168.1.0/24     link#3             U         wlan0
192.168.1.11       link#3             UHS         lo0
192.168.2.0/24     link#4             U           ue0
192.168.2.1        link#4             UHS         lo0
```

Yet the two devices cannot see each other (ping, ssh, etc).  This process actually works fine on a Linux laptop, so I wondered if I was missing something on the FreeBSD side of things.  A search turns up a few somewhat related results, including the following thread:

Thread usb-to-ethernet-interface-not-getting-fully-enabled.69383/

where in this post, ralphbsz seems to be suggesting that it is simply not supported by FreeBSD.  

So before I spend much more time on it myself, it might be good to know if that's the case.


----------



## covacat (Jan 25, 2022)

well i have a pi zero and i can connect it with a micro usb cable to my mac and use ue0


----------



## jdoolin (Jan 25, 2022)

covacat said:


> well i have a pi zero and i can connect it with a micro usb cable to my mac and use ue0


Yeah, it's known to work fine in macOS and Linux.  Those I've gotten to work, but I haven't gotten it to talk to FreeBSD yet.


----------



## covacat (Jan 26, 2022)

my pi runs freebsd


----------

