Enabling USB Ethernet on the Pi0w with an install of LEDE.
It’s a little convoluted and I’m open to learning about optimisations.
- Raspberry Pi Zero W
- 512mb or greater MicroSD card
- Micro USB Cable
- Keyboard and display with adapters to connect up with micro USB and mini HDMI
- https://downloads.lede-project.org/releases/17.01.4/targets/brcm2708/bcm2708/lede-17.01.4-brcm2708-bcm2708-rpi-ext4-sdcard.img.gz (LEDE Disk image compatible with Raspberry Pi Zero W. This is .gz zipped and will need extracting to the .img before flashing to the MicroSD card).
I use Win32 Disk Imager, I assume you're already familiar with the image flashing process.
Running the commands.
uci set wireless.radio0.disabled=0
uci commit
reboot
*I originally tried this with the aluminium Apple keyboard (A1243) and the Pi0w refused to recognise it.
The previous commands should have enabled WiFi on the LEDE install and created a new unsecure wireless network called LEDE to connect to.
- Once connected to the LEDE WiFi your device should have an IP address in the 192.168.1.x range. Open your web browsers and navigate to http://192.168.1.1
- Follow the instructions to set a password for the root user (so you can ssh into the Pi later)
- c. Navigate to [Network > Wireless] then click the “Scan” button. Select your local WiFi with an active internet connection and provide the key needed for the router to connect.
- Navigate to [System > Reboot] then click the “Perform reboot” button. When the Pi comes back up it should now connect to your local WiFi network and the LEDE network will no longer be visible.
The following commands can either be entered on the keyboard connected to the Pi or via a SSH session. This loads the drivers for USB Ethernet then shut down the Pi.
opkg update
opkg install kmod-usb-gadget-eth
opkg install kmod-usb-dwc2
halt
At this point the keyboard and monitor should no longer be needed.
With the MicroSD card back in the computer open the config.txt file in the root of the SD card.
At the end of the file add dtoverlay=dwc2
to a new line, save, eject the MicroSD card and reinsert it into the Pi0w.
At this point the Computer should detect the Pi0w as a USB Ethernet device. Once the correct drivers are loaded it should receive an IP address from the DHCP server running on the Pi0w allowing further SSH and LuCI configuration.
Before and after. The original Raspberry Pi Model B made a great portable router but the smaller size and single cable to the computer should make the Raspberry Pi Zero W much more practical. Also configured with a USB WiFi adapter you can choose between USB Ethernet and a WiFi hotspot.
https://lede-project.org/docs/user-guide/usb_gadget
http://www.circuitbasics.com/raspberry-pi-zero-ethernet-gadget/
https://gist.github.com/gbaman/975e2db164b3ca2b51ae11e45e8fd40a
https://forum.lede-project.org/t/raspberry-pi-zero-w-ethernet-gadget-issue/2609
https://lede-project.org/packages/pkgdata/kmod-usb-dwc2
I use my Pi-Router as an ad-blocker and a WiFi hotspot, I found these links useful.
https://github.com/openwrt/packages/tree/master/net/adblock/files
https://forum.lede-project.org/t/adblock-support-thread/507
https://www.andrewklau.com/openwrt-and-a-4-usb-wifi-adapter/
By default when the device boots the usb mac address is randomly generated. This link explains how to add static mac addresses. https://github.com/adron-s/QCA953x-usb-device-mode The file you need to edit is /etc/modules.d/52-usb-gadget-eth