Pi Router
Raspberry Pi router builds for various custom router configurations.
Some of the targets include:
- Waveshare CM4-DUAL-ETH-4G/5G-BOX, with a Sierra Wireless EM7565 4G LTE modem.
- Radxa Dual 2.5G Router HAT for Pi 5
- 52Pi U2500 Dual M.2 NVME USB3.0 To 2.5g Ethernet HAT for Pi 5
After borrowing my Dad's Cradlepoint IBR900, I decided I wanted to build a few routers of my own, based on Raspberry Pis running open source software.
For 4G or 5G access (as a backup to a standard wired ISP connection), I am testing with SixFab SIM cards.
I use OpenWRT, but with custom compiled configurations, which you can then flash to a Raspberry Pi's internal storage or a microSD card.
Bring up the build environment
-
Install Docker (and Docker Compose if not using Docker Desktop).
-
Bring up the cross-compile environment:
docker-compose up -d -
Log into the running container:
docker attach openwrt-build
You will be dropped into a shell inside the container's /build/openwrt directory. From here you can work on compiling OpenWRT.
After you
exitout of that shell, the Docker container will stop, but will not be removed. If you want to jump back into it, you can rundocker start openwrt-buildanddocker attach openwrt-build.
Configure a custom OpenWRT build
These instructions currently assume you're using a Raspberry Pi CM4 and targeting the Waveshare CM4-DUAL-ETH-4G/5G-BOX.
The container should have OpenWRT's source code checked out inside he /build/openwrt directory. If you would like, run git pull inside the directory to make sure the latest OpenWRT changes are present.
First, run the following command to open menuconfig and select options:
make menuconfig
Choose the Raspberry Pi BCM 2711 for the CM4 as the target platform:
- Target System:
Broadcom BCM27xx - Subtarget:
BCM 2711 Boards (64 bit)
Then select additional packages and configuration. for the Waveshare board, I added the following options:
TODO: This section currently installs practically all the different potential points of entry for QMI, MBIM, etc. modes. For final production use, I probably only need to install a small subset of the packages for the wireless 4G modem, depending on how I want to use it.
- USB Ethernet support for RTL8153: Kernel modules > USB Support >
kmod-usb-net-rtl8152 - USB 2.0 and 3.0 Support: Kernel modules > USB Support >
kmod-usb2(andkmod-usb3) - Enable the LuCI Web UI with https: LuCI > 1. Collections >
luci-ssl - 4G LTE support for Sierra Wireless EM7565: Kernel modules > USB Support >
kmod-usb-net-sierrawireless1. MBIM/QMI support:- Utilities >
usb-modeswitch - Utilities > Terminal >
minicom - Network > WWAN >
uqmi - Kernel modules > USB Support >
kmod-usb-net-cdc-mbim - Kernel modules > USB Support >
kmod-usb-net-qmi-wwan - Kernel modules > USB Support >
kmod-usb-serial-option(optional - for AT commands) - Kernel modules > USB Support >
kmod-usb-serial-qualcomm - Kernel modules > USB Support >
kmod-usb-serial-sierrawireless - Kernel modules > USB Support >
kmod-usb-wdm1. ModemManager setup: - Network >
modemmanager - LuCI > 5. Protocols >
luci-proto-modemmanager
- Utilities >
(Make sure to choose the [*] built-in option, not [M] module option for each of the above selections.)
TODO: I currently don't have all the /etc/config/network, /etc/config/dhcp, and /etc/config/wireless files set up in this repo—I should do that so I don't have to sit there configuring the router on first boot.
Then, if you would like to customize Linux kernel options, run the following command (this is often not necessary):
make -j $(nproc) kernel_menuconfig
Add WiFi Support (for some CM4 modules)
TODO: See Get onboard Raspberry Pi CM4 WiFi module working. Some alpha CM4 modules have a different wireless chipset that requires copying three firmware files over from Raspberry Pi OS to the custom buildroot files directory.
TODO: Also need to make sure the config.txt change is made to use the external antenna (otherwise internal antenna gets zero signal).
Compile OpenWRT
And finally, compile OpenWRT and build the image:
make -j $(nproc)
Flash the OpenWRT Image
After make is finished, you should have a file named openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz inside /build/openwrt/bin.
You will need to flash that image file to the Raspberry Pi to boot OpenWRT.
There is also a
ext4-sysupgradeimage file; this file can be used to upgrade an already-built OpenWRT system.
First, inside the Docker container, copy the build files out to the shared images folder:
cp /build/openwrt/bin/targets/bcm27xx/bcm2711/*.img.gz /images
Then, use Raspberry Pi Imager, Etcher, or some other image-writing tool to write the uncompressed .img file to a microSD card or the Pi's eMMC directly.
First Boot
Plug in a USB-C power supply, and plug the ETH0 port into your computer (preferred) or network (this can cause issues). The default OpenWRT configuration sets up the router at 192.168.1.1, so visit that URL in the browser: https://192.168.1.1
On the first visit, you'll get an HTTPS certificate warning, which you can ignore. On the login page, use root for the username and leave the password field blank.
You should set a strong password for the root account immediately, to keep your router secure!
TODO.
Author
Jeff Geerling