The Raspberry Pi Zero supports USB On-The-Go, which allows the device to emulate various types of USB devices. This story will run through the process of configuring your Raspberry Pi Zero as an Ethernet device, and bringing it up onto your network with a single USB cable, with the help of an OpenWrt router (or really, any Linux-based device).
I can build a custom image with drivers for usb-ethernet and enable WiFi for the LAN interface
Ultimately, this device will connect to 4G/5G over USB (via Android phone), and use built-in WiFi for LAN.
- Go to https://chef.libremesh.org
- Build an image for Pi Zero, add these packages to the ones already listed:
- kmod-usb-net kmod-mii kmod-usb-core kmod-nls-base kmod-usb-net-cdc-ether kmod-usb-net-rndis
- base-files bcm27xx-gpu-fw busybox ca-bundle cypress-firmware-43430-sdio cypress-nvram-43430-sdio-rpi-zero-w dnsmasq dropbear e2fsprogs firewall fstools ip6tables iptables iwinfo kmod-brcmfmac kmod-fs-vfat kmod-ipt-offload kmod-nls-cp437 kmod-nls-iso8859-1 kmod-sound-arm-bcm2835 kmod-sound-core kmod-usb-hid libc libgcc libustream-wolfssl logd luci mkf2fs mtd netifd odhcp6c odhcpd-ipv6only opkg partx-utils ppp ppp-mod-pppoe procd ucert uci uclient-fetch urandom-seed wpad-basic-wolfssl kmod-usb-net kmod-usb-net-rndis kmod-usb-net-ipheth usbmuxd kmod-usb-net-cdc-ether kmod-usb-ohci kmod-usb-uhci kmod-usb2 libimobiledevice-utils libusbmuxd-utils coreutils-nohup bash dnsmasq-full curl ca-certificates ipset ip-full iptables-mod-tproxy iptables-mod-extra libcap libcap-bin ruby ruby-yaml kmod-tun
Connect a monitor/keyboard, enter commands:
uci set wireless.radio0.disabled=0
uci show wireless (to see changes)
uci commit
reboot
Then WiFi is enabled in the LAN zone, with no password.
Edit: Building image with extra packages is so you can use USB tethering for WAN, it’s not possible to download those packages before you have a WAN connection.
2nd: Create a file called 99_wifi_on
in /extracted_imagebuilder_folder/files/etc/uci-defaults
with this contents
uci set wireless.@wifi-device[0].disabled="0"
uci set wireless.@wifi-iface[0].disabled="0"
uci commit wireless
and then add FILES=”files” in your ImageBuilder command
This should add a file that on first boot enables wifi. You should see a OpenWrt wifi network with no password when it’s fully powered up.
See this for a more rich file about enabling wifi on first boot https://openwrt.org/docs/guide-user/installation/flashing_openwrt_with_wifi_enabled_on_first_boot 40
See this for including files in Image Builder images https://openwrt.org/docs/guide-user/additional-software/imagebuilder#custom_files