So I’ve researched the topic a bit and it seems that there is open issue in Zig (move -mcpu to be part of the target triple · Issue #4584 · ziglang/zig · GitHub) that kinda blocks incorporating ARMv6l architecture to our build pipelines, as we rely on Zig to cross-compile.
We’ll put this on the roadmap and monitor if this is resolved. Right now, the only workaround that comes to mind would be to build Husarnet from source ON the Raspberry Pi. This is gonna be tedious and time-consuming, as Pi Zero is obviously not the most powerful computer out there, but definitely possible.
In case you want to try it, I provide the instructions below, along with my remarks. I did it today and it worked, although the whole process took a good couple of hours.
I assume you don’t want to go through all this trouble; in that case I’d suggest to just wait until we support ARMv6l. But I am sharing the instructions to anyone interested.
Building Husarnet from source on Raspberry Pi Zero
- Install dependencies from APT:
sudo apt update && sudo apt install git cmake ninja-build
Install Go language compiler version 1.20+ according to the instructions on Download and install - The Go Programming Language. Don’t install the one in APT repository, it’s outdated.
Resize swap. Compiling needs a lot memory and 512MB of RAM might not be enough and the compiler might utilize swap. Resize it to 1GB or sth like this (change
sudo dphys-swapfile swapoff
sudo nano /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
- Clone and enter the repository:
git clone https://github.com/husarnet/husarnet
- Create CMake file for the architecture. Using editor of choice (
nano), create file
daemon/arch_armv6l.cmake and paste following contents:
Save the file and exit.
- Generate build files via CMake:
cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=../daemon/arch_armv6l.cmake -DCMAKE_INSTALL_PREFIX=./out -DBUILD_SHARED_LIBS=false ../daemon
It may appear that cmake is stuck on this part:
-- Detecting CXX compile features - done
No worries, this alone can easily take like 15-20 minutes (depending on internet connection, because it downloads dependencies here)
- Build husarnet-daemon:
cmake --build .
This is actual compilation step. It’s slow. You will see various warnings, no worries. Took around 2 hours on my device.
- Install husarnet-daemon to /usr/bin/
If the daemon compiled correctly, you will see the file
build/ directory. Copy it to
cp husarnet-daemon /usr/bin/
- Build husarnet (i.e. the CLI):
go generate && go build -o husarnet .
- Install husarnet to /usr/bin/
Similarly, we copy the binary to /usr/bin:
cp husarnet /usr/bin/
- Install the service in systemd:
sudo husarnet daemon service-install
- Test the installation:
You now have Husarnet on your RPi Zero.
Note that in order to verify if compilation is working, I was using headless setup (no GUI) using Raspberry Pi OS Lite:
rpi@rpizero:~ $ uname -a
Linux rpizero 6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023 armv6l GNU/Linux
rpi@rpizero:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 11 (bullseye)
That’s all there is to it.
This post might be helpful for anyone interested in trying out building husarnet for the architecture that is not currently supported by us, or just tinkering with husarnet source code. If you have any problems, feel free to post on the forums.
ympek, Husarnet team