devuan on the orange pi zero

i've started watching the single board computer scene again. in particular those based on the rk3399 soc (includes, among other things, six 64-bit arm cores!) look quite nice, especially with the mainlining of panfrost, but i digress. i was inspired to take out my old orange pi zero, and slap a linux distribution onto it, for fun.

the orange pi zero

this sbc sports the allwinner h2+ soc, which includes 4 cortex-a7 cores (32-bit armv7-a). the 512 mb ddr3 memory cost me $8.5 + $4 shipping in late 2017 - the base price has since risen to $10.5 at the time of writing. for $4 more, there is the more recent orange pi zero plus, which is largely the same board with two welcome improvements: a wifi module that isn't the xr819 (more on this later), and the h5 soc (includes 4 cortex-a53 cores - 64-bit armv8-a).

image bootstrapping

armbian, the predominant community and distribution supporting most hobbyist sbcs, is too featureful for my needs. i am only concerned with running a headless, server-like linux system, with no reason other than for fun and amusement. thankfully, devuan provides images and bootloaders (u-boot) for some allwinner boards, including the orange pi zero.

once you've downloaded and verified the integrity of an image, burn it. for example:

    xzcat devuan_ascii_2.0.0_armhf_sunxi.img.xz | sudo tee /dev/mmcblk0 > /dev/null

then write the board-specific u-boot blob (devuan's sunxi image covers allwinner boards generically) starting at an 8 kb offset (this is where the SPL starts for sd or emmc boot on allwinner boards). for example:

    sudo dd if=orangepi_zero_defconfig.bin of=/dev/mmcblk0 bs=1024 seek=8

note that the usual conv=notrunc is not needed, since it doesn't affect block devices.

finally, sync and remove the storage media. or wait - can't be bothered to walk all the way to the router with the board and your laptop and yada yada? then keep it in, and keep reading.

now xr819 works on armbian OOTB, but not on devuan - you'll have to DIY, which looks too scary for me. i have a few usb wifi adapters, most of them based on the mediatek mt7601u. in that case, download debian's nonfree firmware, mount the sd card, and copy the respective firmware over, for example:

    cp firmware-nonfree-20161130/mt7601u.bin /mnt/lib/firmware/

the major downside to this approach is you exchange better wifi for the only remaining usb port (assuming the other one is being used for power).

serial console

conveniently, there is a 3-pin uart header next to the ethernet port, which i wired to a common pl2303-based usb-to-serial board with three dupont jumpers. watch dmesg when you plug it in to see what tty device it shows up as, then connect to it. in particular, i'm quite fond of tio.

at long last, supply at least 1A @ 5V to the board and watch boot messages fly until you are greeted with login (root/toor)! proceed to connect to internet, install htop, and stare with admiration.