ESPRESSObin: Moving to OpenWRT
Backstory: I’ve been maintaining a build of LEDE for the ESPRESSObin single board computer. Things have changed for the better, so its now time to sunset the build.
Introduction
If you’re reading this far beyond July 2018, this post’s instructions are probably really out of date!
If you don’t know of the ESPRESSObin, it’s a single board computer with properties that make it ideal for a customizable home router.
This LEDE custom build was made to take advantage of the Cake queuing discipline, which attempts to stabilize latency during high bandwidth usage. At the time it was made, OpenWRT did not support Cake, but the newer LEDE fork did.
I didn’t advertise it anywhere (same as the ESPRESSObin case which weirdly ended up on hackaday), but several users found it useful enough to give it a spin.
OpenWRT is now supporting the ESPRESSObin upstream, so I am quite pleased to sunset my own build and build scripts. Everything, it appears, (including Cake SQM) is now supported by people far more qualified to do it. Please use upstream builds for security updates and timely updates in general.
The following are instructions that I followed to migrate my personal ESPRESSObin to OpenWRT (which has now merged with LEDE). Hopefully these instructions help anyone wishing to similarly migrate.
Note: Instructions will vary as time moves along. The source of truth in the far future will always be the ESPRESSObin wiki, OpenWRT, and any associated git commits.
Updating U-Boot (Optional)
Since the ESPRESSObin started shipping (with version: U-Boot 2015.01-armada-17.02.0-g48dc978
), U-Boot has been updated quite a bit. As of this writing, the one currently available (without compiling, from the ESPRESSObin website) is U-Boot 2017.03-armada-17.10.1-gaee49fc
.
The changes are quite numerous and hard to condense. For a way to visualize the changes, try the following commands:
git clone https://github.com/MarvellEmbeddedProcessors/u-boot-marvell
git log --graph --oneline origin/u-boot-2015.01-armada-17.02 origin/u-boot-2017.03-armada-17.10
To update, download the U-Boot images from http://espressobin.net/tech-spec/ and select U-Boot 2017.03-armada-17.10.
The 1GB and 2GB (DDR3) versions are both inside the zip file.
To figure out which ESPRESSObin flavor you have: U-Boot usually prints your DRAM size during initial boot; just as power is applied.
Tip: To scroll up in a screen session, hit CTRL+[ and use your arrow keys/PGUP/PGDOWN – to exit, tap ESC a few times)
With power removed and USB cable connected to a computer:
sudo screen /dev/ttyUSB0 115200
After the session is established, apply power and wait for things to scroll by:
U-Boot 2015.01-armada-17.02.0-g48dc978 (May 18 2017 - 17:28:01)
I2C: ready
DRAM: 1 GiB
[ .. continues to boot .. ]
DRAM: 1 GiB
implies that we use espressobin-bootloader-cpu-1000-ddr3-2cs-1g-atf-ga3306ab-uboot-gaee49fc-20180129-REL.bin
from the .zip file (N.B. there is another 1G image in the zip, with the extension -DBG.bin
).
Next: Grab an empty/sacrificial USB stick, or microSD card.
Follow the Update the Bootloader instructions on the ESPRESSObin wiki (if you have problems getting it to recognize a SD card, try the USB stick method; it can still be a little fickle and might need to be retried a few times).
Installing OpenWRT
The OpenWRT website has a stable release for the ESPRESSObin.
They’re filed by architecture, and ESPRESSObin lives in releases/$version/targets/mvebu/cortexa53/
.
Grab 18.06.1’s (or later) globalscale-espressobin-ext4-sdcard.img.gz
and verify it against the sha512 checksum.
$ wget https://downloads.openwrt.org/releases/18.06.1/targets/mvebu/cortexa53/openwrt-18.06.1-mvebu-cortexa53-globalscale-espressobin-ext4-sdcard.img.gz
$ sha256sum openwrt-18.06.1-mvebu-cortexa53-globalscale-espressobin-ext4-sdcard.img.gz
af71b6a01bb5ac6812c5cc6c0d16deda2d9f2bf65ebcf7ab3db3d2e300277eee openwrt-18.06.1-mvebu-cortexa53-globalscale-espressobin-ext4-sdcard.img.gz
Insert the microSD card that OpenWRT will live on, and write the image out, carefully noting the block device:
sudo lsblk
# [ ... locate your microSD card's sd[a|b|c|e|f] block device ... ]
# [ ... dmesg can also give hints as to what was just plugged in, if on Linux ...]
sudo su
zcat openwrt-18.06.0-rc2-mvebu-cortexa53-globalscale-espressobin-ext4-sdcard.img.gz > /dev/sdSomeLetterHereFromAbove
eject /dev/sdSomeLetterHereFromAbove
Tap CTRL+D or use the ‘exit’ command to leave the root shell.
Grab the ESPRESSObin, insert the microSD card, and microUSB cable (for console). Run this first before applying power:
# /dev/ttyUSB0 might be different on your machine, dmesg will
# likely have more information if that is the case
screen /dev/ttyUSB0 115200
# If screen exits immediately, run it with sudo
sudo screen /dev/ttyUSB0 115200
After the serial console is established, apply power. If the ESPRESSObin boots directly to Linux, great! If not, some boot settings may need to be adjusted; you might see something on the order of:
# [ .. lots of messages ..]
# [ .. some errors .. ]
Bad Linux ARM64 Image magic!
From this git commit, the magic appears to be (with an updated U-Boot – for older U-Boot versions, scroll down in the commit log):
Marvell>> setenv bootcmd "load mmc 0:1 0x4d00000 boot.scr; source 0x4d00000"
Marvell>> saveenv
Marvell>> reset
Add Cake
Once OpenWRT boots, press [Enter]
to get a console, and connect an Ethernet cable to the WAN port. If the WAN cable connects to a 192.168.1.x
network, you may want to disable OpenWRT’s LAN interface (using ifdown lan
) or move the address temporarily in /etc/config/network
so that downloads complete reliably.
To get packages, run opkg update
, then run opkg install luci-app-sqm luci-ssl luci kmod-sched-cake
to install the Cake SQM scripts, as well as luci management tooling to manage it.
Wireguard (Optional)
The LEDE distribution included wireguard – its available through opkg:
root@OpenWrt:/# opkg install wireguard
Installing wireguard (0.0.20180718-2) to root...
Downloading http://downloads.openwrt.org/releases/18.06.1/packages/aarch64_cortex-a53/base/wireguard_0.0.20180718-2_aarch64_cortex-a53.ipk
Installing ip-tiny (4.16.0-4) to root...
Downloading http://downloads.openwrt.org/releases/18.06.1/packages/aarch64_cortex-a53/base/ip-tiny_4.16.0-4_aarch64_cortex-a53.ipk
Installing wireguard-tools (0.0.20180718-2) to root...
Downloading http://downloads.openwrt.org/releases/18.06.1/packages/aarch64_cortex-a53/base/wireguard-tools_0.0.20180718-2_aarch64_cortex-a53.ipk
Installing kmod-udptunnel6 (4.14.63-1) to root...
Downloading http://downloads.openwrt.org/releases/18.06.1/targets/mvebu/cortexa53/packages/kmod-udptunnel6_4.14.63-1_aarch64_cortex-a53.ipk
Installing kmod-udptunnel4 (4.14.63-1) to root...
Downloading http://downloads.openwrt.org/releases/18.06.1/targets/mvebu/cortexa53/packages/kmod-udptunnel4_4.14.63-1_aarch64_cortex-a53.ipk
Installing kmod-wireguard (4.14.63+0.0.20180718-2) to root...
Downloading http://downloads.openwrt.org/releases/18.06.1/targets/mvebu/cortexa53/packages/kmod-wireguard_4.14.63%2b0.0.20180718-2_aarch64_cortex-a53.ipk
Configuring kmod-udptunnel4.
[ 374.869219] kmodloader: loading kernel modules from /etc/modules.d/*
[ 374.881598] wireguard: WireGuard 0.0.20180718 loaded. See www.wireguard.com for information.
[ 374.890172] wireguard: Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
[ 374.900714] kmodloader: done loading kernel modules from /etc/modules.d/*
Configuring kmod-udptunnel6.
[ 374.940244] kmodloader: loading kernel modules from /etc/modules.d/*
[ 374.949342] kmodloader: done loading kernel modules from /etc/modules.d/*
Configuring kmod-wireguard.
[ 374.999050] kmodloader: loading kernel modules from /etc/modules.d/*
[ 375.007124] kmodloader: done loading kernel modules from /etc/modules.d/*
Configuring ip-tiny.
Configuring wireguard-tools.
Configuring wireguard.
Be sure to grab the luci management modules too:
root@OpenWrt:/# opkg install luci-app-wireguard
Installing luci-app-wireguard (git-18.228.31946-f64b152-1) to root...
Downloading http://downloads.openwrt.org/releases/18.06.1/packages/aarch64_cortex-a53/luci/luci-app-wireguard_git-18.228.31946-f64b152-1_all.ipk
Installing luci-proto-wireguard (git-18.228.31946-f64b152-1) to root...
Downloading http://downloads.openwrt.org/releases/18.06.1/packages/aarch64_cortex-a53/luci/luci-proto-wireguard_git-18.228.31946-f64b152-1_all.ipk
Configuring luci-proto-wireguard.
Configuring luci-app-wireguard.
Conclusion
That’s it! Now that ESPRESSObin is supported in OpenWRT’s mainline, you’ll be able to update it as releases come out.
I’d like to thank any current users of the LEDE build – more work than i’ll admit was put into unraveling the build system and figuring out how to containerize it in a repeatable fashion.
It is awesome that others got to benefit from it, even if it was only for a short time.
Until next time.