Raspberrt Pi Zero USB Device?

Just wondering if dietpi is able to be used with the raspberry pi zero as a usb device and share my internet connection with it?

Yes.

In short:

  • Flash your SD card
  • 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”

Hint:

  • Per default where is no Bonjour running on DietPi or Windows host
  • You will need a fix ip adress on DietPi usb0 interface
  • You will need a USB Ethernet / RNDIS Gadget driver for Windows and Mac hosts
  • You will need a Internet Sharing on your Windows/Mac host

1.)

or: Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way! · GitHub



2.) Advanced Networking (Fixed IP)
nano /etc/network/interfaces and add:

## USB0 Ethernet
allow-hotplug usb0
iface usb0 inet static
        address 192.168.7.2
        netmask 255.255.255.0
        network 192.168.7.0
        broadcast 192.168.7.255
        gateway 192.168.7.1 ## ONLY if you have internet connection via usb0

or: DietPi-Cloudshell | Alternative Display

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



3.) USB Ethernet / RNDIS Gadget driver (Windows)
http://domotique.caron.ws/cartes-microcontroleurs/raspberrypi/pi-zero-otg-ethernet/


4.) Internet Sharing

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

vaxoiva
The ssh file btw is not required, nor used. DietPi has SSH enabled by default, but should not play a role here?

The part

## USB0 Ethernet
allow-hotplug usb0
iface usb0 inet static
        address 192.168.7.2
        netmask 255.255.255.0
        network 192.168.7.0
        broadcast 192.168.7.255
        gateway 192.168.7.1 ## ONLY if you have internet connection via usb0

should be added as separate drop-in config, e.g. /etc/network/interfaces.d/usb0
You can then disable Ethernet and WiFi within dietpi-config, so the other two interfaces are down.

AFAIK dtoverlay load required modules by default, so modules-load=dwc2,g_ether should not be required. Not sure about the g_ether option, at least for the overlay it is not supported:

Name:   dwc2
Info:   Selects the dwc2 USB controller driver
Load:   dtoverlay=dwc2,<param>=<val>
Params: dr_mode                 Dual role mode: "host", "peripheral" or "otg"

        g-rx-fifo-size          Size of rx fifo size in gadget mode

        g-np-tx-fifo-size       Size of non-periodic tx fifo size in gadget
                                mode

You should check which module is actually enabled by the overlay itself (e.g. lsmod, perhaps it is different on current Raspbian/RPi firmware versions. /etc/modprobe.d/ could be used to add options/params to the module.

Apart from that we would need to compare the Raspbian setup then. DietPi is based on the official Raspbian image, but perhaps some additional APT package is missing. Explicite modules load as said should not be required with dtoverlays.

Has anyone gotten this to work? I am thinking about using this distro on my pi zero w sens it’s a lighter weight distro. But I use it headless and in USB gadget mode so I can ssh to it with a Single USB connection. I have soldered on one of them USB gadget boards to it and it is already working with rasbian light. Thanks for any info.