G_Ether for USB with Dietpi on Pi Zero?

I wanna get this working after getting a few Pi Zeros at microcenter. Is there a way to do this on Dietpi?

Hi,

hmm, please what is “G_Ether” ?

Gigabit Networking? Like this? http://www.jeffgeerling.com/blogs/jeff-geerling/getting-gigabit-networking

If so, yes.

Virtualized ether net over USB.

Then how do I set it up?

any update?

Try:
https://gist.github.com/gbaman/975e2db164b3ca2b51ae11e45e8fd40a

That’s what I was referring to. But when I attempt to use that bootline, it doesn’t seem to load the module (g_ether) last I tried.

On a running DietPi system, you have to edit:

nano /Dietpi/config.txt and add:

## for USB Ethernet driver
## Open up "/boot/cmdline.txt" and add "modules-load=dwc2,g_ether" after "rootwait"
dtoverlay=dwc2

as well. If you edit SD-Card in a card-reader on your host computer, you have to edit:

  • Open up the “boot” partition and edit “config.txt”, adding “dtoverlay=dwc2” to the bottom
  • Open up “cmdline.txt” and add “modules-load=dwc2,g_ether” after “rootwait”

After restart have a look in dmesg

[    5.194515] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
[    5.195979] g_ether gadget: g_ether ready
[    5.197409] dwc2 20980000.usb: dwc2_hsotg_enqueue_setup: failed queue (-11)
[    5.201958] dwc2 20980000.usb: bound driver g_ether
[    5.389216] dwc2 20980000.usb: new device is high-speed
[    5.481414] dwc2 20980000.usb: new device is high-speed
[    5.518094] dwc2 20980000.usb: new address 31
[    5.574640] g_ether gadget: high-speed config #2: RNDIS
....

… and have a look at: Raspberrt Pi Zero USB Device? - #2 by k-plan

pi@RPi-Zero-W_Radio:~ $ ifconfig usb0

usb0      Link encap:Ethernet  Hardware Adresse 5a:a6:ce:db:b8:8f
          inet Adresse:192.168.7.2  Bcast:192.168.7.255  Maske:255.255.255.0
          inet6-Adresse: fe80::58a6:ceff:fedb:b88f/64 GĂźltigkeitsbereich:Verbindung
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metrik:1
          RX packets:288 errors:0 dropped:0 overruns:0 frame:0
          TX packets:280 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:1000
          RX bytes:20557 (20.0 KiB)  TX bytes:75423 (73.6 KiB)

… and from now on never again use dietpi-config ==> Network to change your network settings

hi all i have zero pi

i add
“config.txt”, adding “dtoverlay=dwc2” to the bottom
and add “modules-load=dwc2,g_ether” after “rootwait”

also add ssh file on sd card

but nothing work

its wordk fine on Raspbian

Was anyone able to get this to work? I have the same issue.

# cat /boot/dietpi/.version 
G_DIETPI_VERSION_CORE=8
G_DIETPI_VERSION_SUB=16
G_DIETPI_VERSION_RC=2
G_GITBRANCH='master'
G_GITOWNER='MichaIng'

It seems g_ether gets loaded fine:

# dmesg | grep -i g_ether
[    0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_hdmi=0 bcm2708_fb.fbwidth=720 bcm2708_fb.fbheight=480 bcm2708_fb.fbdepth=16 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:8E:56:89 vc_mem.mem_base=0x1fa00000 vc_mem.mem_size=0x20000000  root=PARTUUID=28e34a08-02 rootfstype=ext4 rootwait modules-load=dwc2,g_ether net.ifnames=0 logo.nologo console=tty1
[    0.000000] Unknown kernel command line parameters "modules-load=dwc2,g_ether", will be passed to user space.
[    2.116820]     modules-load=dwc2,g_ether
[    7.602963] g_ether gadget.0: Ethernet Gadget, version: Memorial Day 2008
[    7.603004] g_ether gadget.0: g_ether ready
[    7.603036] dwc2 20980000.usb: bound driver g_ether

and:

# lsmod | grep g_ether
g_ether                 5277  0
usb_f_rndis            19705  2 g_ether
u_ether                15032  3 usb_f_ecm,g_ether,usb_f_rndis
libcomposite           55842  3 usb_f_ecm,g_ether,usb_f_rndis

The usb0 network device shows up:

# ifconfig usb0
usb0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 7a:51:89:fd:eb:cc  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

But ifconfig usb0 up does nothing at all.

The adapter I’m using is actually the official Chromecast ethernet adapter, which tends to work out of the box on Raspbian, according to:
https://forums.raspberrypi.com/viewtopic.php?t=131379

My lsusb output does NOT match that of the above forum post:

# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
# lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc2/1p, 480M

This is missing the Bus 001 Device 002: ID 0bda:8152 Realtek Semiconductor Corp. and Driver=r8152 output.

The r8152 driver seems to be available on the system:

# modinfo r8152 | grep -v alias
filename:       /lib/modules/6.1.21+/kernel/drivers/net/usb/r8152.ko.xz
version:        v1.12.13
license:        GPL
description:    Realtek RTL8152/RTL8153 Based USB Ethernet Adapters
author:         Realtek linux nic maintainers <nic_swsd@realtek.com>
firmware:       rtl_nic/rtl8156b-2.fw
firmware:       rtl_nic/rtl8156a-2.fw
firmware:       rtl_nic/rtl8153c-1.fw
firmware:       rtl_nic/rtl8153b-2.fw
firmware:       rtl_nic/rtl8153a-4.fw
firmware:       rtl_nic/rtl8153a-3.fw
firmware:       rtl_nic/rtl8153a-2.fw
srcversion:     40CCD8C744B36693E1F6DB3
depends:        
intree:         Y
name:           r8152
vermagic:       6.1.21+ mod_unload modversions ARMv6 p2v8 

I did modprobe r8152 and that seems to have loaded the driver:

# lsmod | grep r8152
r8152                  99047  0

but there is still no change to lsusb output.

When I connect this adapter to a Chromecast and to my network, everything works, so my network and the adapter seem to be fine.

Any help will be much appreciated.

I think the USB of the RPi0 is USB 2.0…so even the add on modules won’t be able to push gigabit ethernet…I got a Power over ethernet module and it’s only a 10/100, unless there is a USB C or Micro USB ethernet dongle possibly…but all I have seen have been 10/100

Raspberry Pi Documentation - Raspberry Pi hardware

Raspberry Pi 4

The Raspberry Pi 4 contains two USB 3.0 ports and two USB 2.0 ports which are connected to a VL805 USB controller. The USB 2.0 lines on all four ports are connected to a single USB 2.0 hub within the VL805: this limits the total available bandwidth for USB 1.1 and USB 2.0 devices to that of a single USB 2.0 port.

On the Raspberry Pi 4, the USB controller used on previous models is located on the USB type C port and is disabled by default.

Raspberry Pi Zero, 1, 2 and 3

The USB controller on models prior to Raspberry Pi 4 has only a basic level of support for certain devices, which presents a higher software processing overhead. It also supports only one root USB port: all traffic from connected devices is funnelled down this single bus, which operates at a maximum speed of 480Mbps.
*> *
> The USB 2.0 specification defines three device speeds - low, full and high. Most mice and keyboards are low speed, most USB sound devices are full speed and most video devices (webcams or video capture) are high speed.

Generally, there are no issues with connecting multiple high speed USB devices to a Raspberry Pi.

The software overhead incurred when talking to low and full speed devices means that there are limitations on the number of simultaneously active low and full speed devices. Small numbers of these types of devices connected to a Raspberry Pi will cause no issues.

oooh…
[OpenWrt Wiki] USB Guest configuration

He wants to be able to plug the RPi0 into usb then be able to use it as an “ethernet device” plugged into another computer
something like this would help
Raspberry Pi Zero Series Addon Board USB Connector V1.1 RPi0 Adapter | Satistronix Group

I am just trying to get Pi Zero to work with the Chromecast ethernet adapter, which supposedly works out of the box on Raspbian. The adapter connects to the micro-USB data port with OTG, provides power and ethernet-over-usb, which should work through g_ether in Linux. It isn’t working on DietPi.

maybe @MichaIng could have a look

Did you create an interface config for it? Like

echo -e 'allow-hotplug usb0\niface usb0 inet dhcp' > /etc/network/interfaces.d/usb0.conf
ifup usb0

I remember trying it before and I just tried it again but it doesn’t work. See below:

~# cat /etc/network/interfaces.d/usb0.conf 
allow-hotplug usb0
iface usb0 inet dhcp
~# ifup usb0
ifup: interface usb0 already configured
~# ifconfig usb0
usb0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 46:fb:1c:6b:92:03  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

I checked my router’s logs and it doesn’t see any DHCP requests from that MAC address.

So far I assumed, because the Chromecast ethernet adapter connects to the USB OTG data port on Pi Zero to supply power and ethernet, that the Pi Zero then operates as USB guest and would have to use g_ether. Perhaps that is incorrect.

So I removed dwc2 and g_ether and uncommented allow-hotplug eth0 in /etc/network/interfaces and then tried ifup eth0, but that didn’t work either. I failed with message Cannot find device "eth0".

ifdown usb0
ifup usb0

The usb0 interface is mandatory, eth0 is for native Ethernet adapters only, not for USB gadget devices.

I started all over again with a fresh install, and this time around it all works ‘out of the box’. Not really sure what I did wrong the first time around. The chromecast ethernet connection shows up as eth0, as below:

~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether e8:c7:4f:05:4e:98 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.121/24 brd 192.168.1.255 scope global dynamic eth0
       valid_lft 43164sec preferred_lft 43164sec
    inet6 fd1f:babd:316b:10:eac7:4fff:fe05:4e98/64 scope global dynamic mngtmpaddr 
       valid_lft forever preferred_lft forever
    inet6 2a02:8010:6807:10:eac7:4fff:fe05:4e98/64 scope global dynamic mngtmpaddr 
       valid_lft 47584sec preferred_lft 47584sec
    inet6 fe80::eac7:4fff:fe05:4e98/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:3a:3a:a2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.210/24 brd 192.168.1.255 scope global dynamic wlan0
       valid_lft 43174sec preferred_lft 43174sec
    inet6 fd1f:babd:316b:10:ba27:ebff:fe3a:3aa2/64 scope global dynamic mngtmpaddr 
       valid_lft forever preferred_lft forever
    inet6 2a02:8010:6807:10:ba27:ebff:fe3a:3aa2/64 scope global dynamic mngtmpaddr 
       valid_lft 47584sec preferred_lft 47584sec
    inet6 fe80::ba27:ebff:fe3a:3aa2/64 scope link 
       valid_lft forever preferred_lft forever

Thanks for your support @MichaIng !

For the benefit of those stumbling upon my posts in this thread: one doesn’t need g_ether if you are just trying to use the Chromecast ethernet adapter to get an ethernet connection.

2 Likes

Unexpected but good to know that this is possible. Great that it works now :slightly_smiling_face:.

Just updating this thread with the setup for G_Ether, which was the original topic here.

  1. In /boot/config.txt, add dtoverlay=dwc2 on a line by itself, say at the end of the file.
  2. In /boot/cmdline.txt, add modules-load=dwc2,g_ether after rootwait, with a space in between.
  3. (Option A.) For a static address, create a file like so:
    # cat /etc/network/interfaces.d/usb0.conf
    allow-hotplug usb0
    iface usb0 inet static
        netmask 255.255.255.0
        address 169.254.0.1
    
    Configure your host with a corresponding static address such as 169.254.0.2/24.
    (Option B.) For DHCP, do echo -e 'allow-hotplug usb0\niface usb0 inet dhcp' > /etc/network/interfaces.d/usb0.conf
  4. Reboot, and you should be able to ssh root@<ip>, where <ip> is either the static address or the DHCP address/name.

This has been tested with the static IP setup, macOS host and Raspberry Pi Zero. A USB cable connects the mac to Zero’s data port, which also powers it (nothing in the Zero power port).

2 Likes