gokrazy on the Banana Pi BPI-R1

recently ported gokrazy to the Banana Pi BPI-R1 (Allwinner A20, armv7). For those who don’t know it: gokrazy is a minimal Linux-based OS that runs only Go binaries. No shell, no package manager, no C runtime – just your Go programs, supervised by a Go init system. The whole system boots from a single SD card image.

It’s not my project, but I think it deserves more attention. The idea is simple: you define your Go packages in a JSON config, run gok overwrite, and get a bootable image. Updates happen over HTTP. There’s a built-in web interface that shows process status. That’s it.

What I did

The BPI-R1 uses an Allwinner A20 SoC, which requires U-Boot and an MBR partition layout (no GPT – the boot ROM doesn’t support it). I packaged a Linux 6.12 kernel, U-Boot, and the device tree into a Go module that gokrazy can consume as a KernelPackage. The kernel is significantly more recent than what most BPI-R1 guides out there suggest (many are still on 4.x or 5.x branches).

Since gokrazy has no modprobe, I also wrote a small loadmodules tool that loads kernel modules at boot via finit_module(2). WiFi (RTL8192CU) works this way.

Repos

Getting started

Minimal config.json for a BPI-R1 instance:

{
    "Hostname": "bpi-r1",
    "DeviceType": "bpi_r1",
    "KernelPackage": "github.com/consolving/gokrazy-kernel-a20",
    "FirmwarePackage": "",
    "EEPROMPackage": "",
    "SerialConsole": "ttyS0,115200",
    "Packages": [
        "github.com/consolving/gokrazy-kernel-a20/cmd/loadmodules"
    ]
}

Then:

GOARCH=arm gok -i bpi-r1 overwrite --full /dev/sdX

To deploy your own Go programs to the system, have a look at the gokrazy docs on adding packages and package configuration. It boils down to adding your Go import path to the Packages list and running gok update.

Why

I wanted a minimal, reproducible appliance OS for a home router project on cheap ARM hardware. gokrazy fits that niche perfectly. The BPI-R1 has a built-in 5-port switch and WiFi, which makes it a decent (if dated) platform for this.