Hi all,
I'm planning to setup a Pi Zero W as a Bridge for a ZeroTier network. To do this I'm planning to install OpenWRT on the PI0W, then hook it up to the ZeroTier networks as a bridge device. Sofar so good.
Now the triky bit: Is it possible to configure the WiFi parameters before I boot the device?
This is possible with Raspberry OS (Raspbian), by adding a file, "wpa_supplicant.conf", to the /boot [FAT32] on the SD-Card (and add an empty file called "ssh", to enable ssh after booting).
p.s.
This is what the wpa_supplicant.conf file looks like:
/etc/config/wireless is generated on firstboot conditions of OpenWrt, its contents depend on the detected wireless hardware. While I don't know about its structure (the necessary device path and maybe MAC addresses) on this particular hardware, you can fetch it from a working/ fully configured RPi-0W once and then re-use it afterwards (at least for the same major OpenWrt version).
--
injecting files into ext4 based images would be easier than properly initializing an overlay on top of squashfs outside of the firstboot environment.
@yonz2 Are you aware of the "image builder"? This is precisely what it can be used for.
For example to generate a RPi image:
#!/bin/bash
#Documentation: https://openwrt.org/docs/guide-user/additional-software/imagebuilder
OUTPUT="$(pwd)/images"
BUILDER="https://downloads.openwrt.org/releases/21.02.0/targets/bcm27xx/bcm2708/openwrt-imagebuilder-21.02.0-bcm27xx-bcm2708.Linux-x86_64.tar.xz"
# download image builder
if [ ! -f "${BUILDER##*/}" ]; then
wget "$BUILDER"
tar xJvf "${BUILDER##*/}"
fi
mkdir "$OUTPUT"
cd openwrt-*/
# list all targets for this image builder, consider 'make help' as well
# make info
# clean previous images
make clean
make image PROFILE="rpi" \
PACKAGES="luci-base luci-ssl luci-mod-admin-full luci-theme-bootstrap" \
BIN_DIR="$OUTPUT"
Add your WiFi parameters after OpenWRT creates the /etc/config/wireless by creating a script that waits for that file, modifies the contents and triggers a wifi restart or reboot.