GridCoin-Mining on an old Raspberry Pi 1B? Just 512 MiB of RAM and barely 1000Mhz? Yes, it is possible. You just cannot compile it on your Pi. But it does work for staking. A how-to. And yes, this totally just a project for fun, because you cannot mine efficiently on this device!
Table of Contents
Choosing your Raspberry Pi for GridCoins
A word in advance: You cannot run
gridcoinresearchd on a Raspberry Pi Zero. It is just too slow for the job and has too few RAM. But a Raspberry Pi Model 1 (Revision B) can barely do it.
You will also need a 16 GiB+ memory card, because the base system uses slightly over 4 GiB and the current blockchain data is about 4.4 GiB at the time of writing. Thus, 8 GiB is not sufficient.
Choosing the distro
As I like clean DIY systems, I chose Arch Linux ARM. It is easy to install and set up. I will not give an explanation how to do this, though. There is another reason – now you can say this:
Compiling: DistCC vs chroot vs qemu-arm
There are several approaches how you can compile a demanding application on another PC if your target computer (here: our Raspberry Pi 1) is too weak.
The Pi failed with distcc
My first attempt was to use distcc, because you can use all the tooling you know from your favourite Arch installation. You would also need a toolchain suitable for armv6hf (or armv7hf which can compile to arm6 as well). While there are toolchains available, my Raspberry Pi got stuck in distributing the compilations. So I ditched this approach.
If you want to try this for yourself, I can recommend this tutorial.
Qemu-arm for those who can
There are multiple tutorials on the web about emulating the Raspberry Pi 1 using Qemu, but I think the overhead is not really needed, so I skipped this option. Also, I tried the chroot approach first, and it worked for me. So I did not look into this anymore.
For the reasons mentioned above, I decided to go with a simple chroot approach. Because I use Manjaro at the moment, I have the manjaro-chroot helper script at hand, which is basically the same as the arch-chroot helper script.
To create a suitable
chroot environment, install the static emulation binaries, also provided by
$ yay -S qemu-user-static
Next, download and extract the arch base image (or mount any any existing sd card partition) to the root folder:
$ curl -LOJ http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz $ bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
To be able to execute multiple concurrent invocations of foreign invocations, copy the
qemu-arm-static binary into the
chroot environment and register the binary format with the host kernel:
$ cp -a /usr/bin/qemu-arm-static archlinux-armv6hf/usr/bin/ $ echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register
And then chroot into your target environment:
$ manjaro-chroot archlinux-armv6hf /bin/bash # mount -o bind various file systems before this command if you do not use manjaro or arch
If you are using the arch base image, don’t forget to initialize pacman using the commands provided on the archarm wiki. Open the “Installation” tab.
Now you can actually use and build the chroot as follows:
pacman -Syu pacman -S --needed base-devel boost qt5-charts qt5-tools qrencode libzip su - alarm -c "git clone https://aur.archlinux.org/gridcoinresearch.git" su - alarm -c "cd $PWD && makepkg --ignorearch --nosign"
You might notice the “
--ignorearch” parameter. armv6 is not included in the list of supported architectures, because the raspberry pi is too weak to build the GridCoin software. It can bareley run it. Make sure you have a maximum amount of 64 MiB assigned to the graphics card, have your processor speed up to 1000 Mhz and use a swap partition of at least 512 MiB, better 1024 MiB.
Also notice that
uname -a will show something with
armv7l. You can safely ignore this, because the architectures are compatible as long as you don’t temper with your
/etc/makepkg.conf. That said, you can of course add something like
MAKEFLAGS="-j$(($(nproc)+1))" if you are on a somewhat modern PC. 🙂
Finishing the package and installing
Log out from the chroot environment and copy the created package to your raspberry pi. You can now run gridcoinresearchd as on any other architecture.
$ pacman -U gridcoinresearchd-22.214.171.124-1-armv6h.pkg.tar.xz
The first start should be done like this:
$ gridcoinresearchd -snapshotdownload
This will ensure you do not collect all the blockchain data from the peers. Instead, you will download a snapshot which is 90% up to date.
Happy staking! 🙂