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 snapshots and releases for the ESPRESSObin.

Releases for the ESPRESSObin are filed under releases/$version/targets/mvebu/cortexa53/.

Grab 18.06.0-rc2’s (or later) globalscale-espressobin-ext4-sdcard.img.gz and verify it against the sha512 checksum.

$ wget https://downloads.openwrt.org/releases/18.06.0-rc2/targets/mvebu/cortexa53/openwrt-18.06.0-rc2-mvebu-cortexa53-globalscale-espressobin-ext4-sdcard.img.gz
	
$ sha256sum openwrt-18.06.0-rc2-mvebu-cortexa53-globalscale-espressobin-ext4-sdcard.img.gz
d883824bb0e9a23b46437114cb3d03e096041dd4327f8b2e311dd3a3e7becf06  openwrt-18.06.0-rc2-mvebu-cortexa53-globalscale-espressobin-ext4-sdcard.img.gz

Insert the microSD card that OpenWRT will live on, and write it 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

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 your computers reside on 192.168.1.x, 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.

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.