How to CPU mine DigiByte with your Rock64 - v2/v3

In one of the last stories we learned how to create a DigiByte Full node with a Rock64. Now you’re standing with this brand new node and wondering if you could make it mine some $DGB? Or simply, you just own a Rock64 and are wondering why it wouldn’t mine a bit, yes every coin count! Here is a small step by step guide.

The Rock64 has a Quad-Core ARM Cortex a53 64-bit that you could easily be used to catch few more $DGB

CPU mining are you serious?

The Rock64 grabbed few shares and is running actually at about 2,45 MH/s with skein algo

Ok seriously, you won’t do any profit of it, far from it. But CPU mining is fun and still support the network.

How to buy the right hardware?

Rock64 do exists with different RAM option, you may experiment with different RAM options, event I never tried them before.

First of all, you need to get a Rock64 with 4GB RAM form here : https://store.pine64.org/?product=rock64-media-board-computer

I advice you to add these :

  • Rock’s 5V 3A Switching Power Supply (beware it is a specific power supply)
  • A nice casing for protection and show off
  • 16GB Class10 Micro SD card
  • A Micro SD card reader for your PC
  • HDMI cable
  • Network cable to connect it to your router
  • A temporary computer screen or TV
  • A temporary Keyboard and Mouse

I ordered mine directly from https://pine64.org and it was a fast and a smooth experience.

Let’s begin

Now it’s time to launch the PIN64 Installer and to plug your Micro SD into your PC.

  • First step Choose your OS, at this stage, you’ll have to select “Rock64 -v3/v2 and Armbian Ubuntu 18.04 Bionic Desktop(Rock64 mciroSD / eMMC). If you want to play more easily with your Rock64 I recommend you to choose the desktop edition and not the minimal one.
Choose the desktop edition if you like to connect graphically to your Rock64
  • And choose your SD card by clicking on connect a Drive
  • Last step Flash! Introduce your password if asked and the software will download the OS and flash your sd card for you. This step can be a bit long depending on your Internet connection.

Booting up your Rock64

The wallpaper of your OS

There are two solid lights displayed on the board (a white and a red), nothing will flicker but your OS should display the boot sequence on the screen.

Soon you’ll be asked for a password, the default user and password are

  • user : root
  • password : 1234

Choose your password wisely, it shouldn’t be easy to guess as your Rock64 could be Internet facing, and write it down somewhere, you don’t want to loose it.

After this step you’ll have to choose a user name and a specific password for it. I did choose drake for my user, so when this guide will reference drake you should input your user name.

Time to connect your Rock64 through an SSH connection

sudo ifconfig
Output for ifconfig

You’ll have to enter the password of your account and should receive an output looking like the one just above. We are looking for the IP address of the eth0 network card.

If you’re using a Mac or a Linux a SSH client is available directly in your Terminal window by entering

ssh drake@192.168.100.204

Where drake will be your Rock64’s user name and 192.168.100.204 should be replaced with the Rock64’s address IP. You’ll be asked if you accept the connection, just answer yes and provide the user’s password. You should see something like this:

First SSH Connexion to the Rock64

If you’re using a PC, you should download Putty from here: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

In Putty fill-in the Rock’s IP address choose SSH and click on Open.

How to manage your Rock64 remotely with a graphical interface?

https://link.medium.com/DbcoJR0gtW

Increasing the Swap Space

The Armbian Debian has been set with 1GB swap memory. We’ll increase it by 8GB: just copy/paste these 3 commands

sudo fallocate -l 8G /swap
sudo mkswap /swap
sudo swapon /swap

We can verify this using this command

free -hm
9GB Swap Space, more than what we need :)

Make it mine !

sudo apt-get install git automake autoconf pkg-config libcurl4-openssl-dev libjansson-dev libssl-dev libgmp-dev make g++sudo apt-get install zlib1g-dev

Now we are downloading the software we need:

cd ~
git clone https://github.com/tpruvot/cpuminer-multi.git
cd cpuminer-multi/
Downloading the cpuminer we’ll use

Hopefully, we are using a Rock64 and it is pretty easy to compile the tool:

./autogen.sh./configure --disable-assembly CFLAGS="-Ofast -march=native" --with-crypto --with-curl

Next we can run make and make install to finish this part:

sudo make
sudo make install

To make it easy to start the miner, just create a symbolic link this way:

sudo ln -s ~/cpuminer-multi/cpuminer /usr/bin/cpuminer

CPU mining on a Pool

Configuring the miner

cat << EOF > ~/start_cpuminer.sh
cpuminer --algo=skein -o stratum+tcp://eu.miningfield.com:3394 -O username.worker_name:worker_password
EOF

Running your miner

After few instants you should already see some shares accepted

Overclocking the Rock64

By default your Rock64 has a max CPU frequency set to 1.3GHz max. Check your current CPU frequency with:

cpufreq-info -c 0
Actually this Rock64 can go up to 1.30GHz

No need to reboot, we can slightly bump this settings while mining to 1.51GHz using these commands:

sudo sed -i "s/MAX_SPEED=.*/MAX_SPEED=1512000/" /etc/default/cpufrequtilssudo systemctl restart cpufrequtils

Now the Rock64 can increase itself its CPU frequecy up to 1.51GHz if it needs it.

Now the Rock64 can run at 1.51GHz
You can directly notice the bump in KH/s (about 15% more hashes)

If you want to try different settings, you can get the list of the accepted frequencies by using this command:

cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies
Rock’s available scaling frequencies

If you like to go back to the previous settings, just use these commands:

sudo sed -i "s/MAX_SPEED=.*/MAX_SPEED=1296000/" /etc/default/cpufrequtilssudo systemctl restart cpufrequtils

Check the temperature of your Rock64

sudo armbianmonitor -m
87.7°C is too hot for you CPU, you better aim for 79°C max

I don’t have a big enough heatsink on my CPU and the 1512000 max-speed setting was a bit too much, so I did choose 1392000 setting which my Rock64 seems to appreciate much more.

Graphically monitor your Rock64 with SSH and s-tui

It is pretty straightforward to install, just enter these commands to install and detect the sensors:

sudo apt-get install lm-sensors
sudo sensors-detect

Say yes to all questions and carry on with these commands that will install s-tui:

sudo apt-get install python3-pip stress
sudo apt-get install python3-dev
sudo -H pip3 install --upgrade setuptools
sudo -H pip3 install ez_setup
sudo -H pip3 install s-tui

Now it has been installed, to launch it:

sudo s-tui

If you want to have all the information, you have to run s-tui with sudo.

Too bad the Rock64 has no Power sensor

Make your CPUminer restart automatically after a reboot

First of all we create the service file by using this command, don’t forget to adapt this command with your username:

sudo cat << EOF > ~/cpuminer.service
[Unit]
Description= CPUminer (digibyte)
After=syslog.target network.target
[Service]
Type=simple
User=drake
PAMName=login
ExecStart=/home/your_user_name/start_cpuminer.sh
[Install]
WantedBy=multi-user.target
EOF
The service file has been created in your home folder

Then we change the owner and move the file in the right place:

sudo chown root:root cpuminer.service
sudo mv ~/cpuminer.service /etc/systemd/system/
sudo chmod 755 /etc/systemd/system/cpuminer.service
chmod 755 ~/start_cpuminer.sh
You can check if the file is at the right place with this command:sudo ls -ail /etc/systemd/system/
The file should be displayed here

Adapt your start_cpuminer.sh to start the cpuminer few minutes after the reboot

Just add this line befor the cpuminer command to your start_cpuminer.sh

nano ~/start_cpuminer.sh#! /bin/bashsleep 15m #Waits 15 minutes for DigiByte Core to startup

Verify that your service is runing

sudo service cpuminer stop
sudo service cpuminer start
sudo service cpuminer status
The cpuminer.service is active and running, in 15 minutes the cpuminer will start

Conclusion

IT Guru • Defender against the Digital Dark Arts🛡 • Blockchain Advocate 🔑️. https://xn--l9hygo898lbsb.y.at