The NanoPi R1 has proven itself to be a very capable SBC, and with FriendlyELEC’s fork of OpenWRT it stands to be an even better router.
The idea here in my MDroid build is to combine the GLiNet router and the Raspberry Pi into one data-logging super-router. The problem is that most software is not directly compatible with OpenWRT for a number of reasons. MDroid-Core (written in go) needs to be cross-compiled for MUSL instead of the glibc compiler you’d find on your standard Linux architecture. Here’s how to do it.
This short guide assumes you’re cross-compiling on Mac OSX for the Sunxi prebuilt OpenWRT (Allwinner H3 ARMv7).
Start on your Mac, since this will take a long time:
# Set up the MUSL compiler, this can easily take over an hour
# This has been adapted from the great guide here, for Mojave and later versions of Homebrew
brew tap FiloSottile/musl-cross
brew install FiloSottile/musl-cross/musl-cross --without-x86_64 --with-arm-hf
While we’re brewing on OSX, log into the router itself and install a number of packages:
opkg update && opkg install python python-pip curl libustream-openssl ca-bundle git golang
# I also install for the other aspects of MDroid and some homely packages:
opkg install python-setuptools gpsd gpsd-clients fdisk nano tmux bash htop
pip install canard python-can pyserial requests
At the time of writing this will install Go version 1.10 which is officially unsupported by InfluxDB, but I haven’t ran into any problems so far.
Once brew has finished all the makes, run the following on your Mac to reload c libraries and compile MDroid-Core with MUSL:
git clone https://github.com/MrDoctorKovacic/MDroid-Core
env CC=arm-linux-musleabihf-gcc GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=1 go build -o MDroid-Core-MUSL ./main.go
scp this over to the OpenWRT router and run it with the standard arguments. Tada!