Raspberrt Pi Zero USB Device? Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
big4570

Raspberrt Pi Zero USB Device?

Post by big4570 »

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?
User avatar
k-plan
Posts: 416
Joined: Sun Feb 28, 2016 5:28 pm

Re: Raspberrt Pi Zero USB Device?

Post by k-plan »

big4570 wrote: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.)
https://learn.adafruit.com/turning-your ... net-gadget
or: https://gist.github.com/gbaman/975e2db1 ... e45e8fd40a



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

Code: Select all

## 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: http://dietpi.com/phpbb/viewtopic.php?f=9&t=524#p2280

... 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-microc ... -ethernet/


4.) Internet Sharing

https://learn.adafruit.com/turning-your ... net-tweaks
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal and Bitcoin.
vaxoiva
Posts: 2
Joined: Tue Jul 09, 2019 10:35 am

Re: Raspberrt Pi Zero USB Device?

Post by vaxoiva »

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

Image
Image

its wordk fine on Raspbian
User avatar
MichaIng
Site Admin
Posts: 2294
Joined: Sat Nov 18, 2017 6:21 pm

Re: Raspberrt Pi Zero USB Device?

Post by MichaIng »

@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

Code: Select all

## 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:

Code: Select all

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.
deepdivered
Posts: 1
Joined: Thu Oct 10, 2019 6:07 pm

Re: Raspberrt Pi Zero USB Device?

Post by deepdivered »

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.
Post Reply