Pages:
Author

Topic: [Guide] Futurebit Apollo BTC Custom Linux Install - Miner - page 2. (Read 500 times)

newbie
Activity: 10
Merit: 1
Alright n0nce, getting this tackled.  I have Umbrel installed onto Armbian, trying to get the miner setup now. 

I'm getting the error that the system can't access /dev/ttyACM.  When or where was this created?  I don't see it in the instructions and I don't have this file structure. 

Thanks!!
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
Some notes by MrMilk who followed my guide in December 2022; I feel they could come in very handy to whoever reads this! Smiley

Lessons learned:

- the OS might take much longer to load than expected. I etched Armbian_22.11.1_Orangepi4-lts_jammy_current_5.15.80_gnome_desktop.img.xz
to an SD card and it took over 3 minutes before any signs of life showed up on the HDMI-connected monitor. On second reboot, it too about 4 minutes before showing it is running. I assume that maybe my failed attempts to use an Ubuntu version were due to my impatience, I never waited that long to see if it would boot.

- for some reason, the Armbian_22.11.1_Orangepi4-lts_jammy_current_5.15.80_gnome_desktop.img.xz OS has no issues when connecting to GitHub to download the wiringOP thingamajigg (just like my Ubuntu laptop OS). Not asking for a password, just doing it like n0nce's instructions suggest. So for some reason, that previously tried bullseye-minimal armbian has some issue that will not be easy to solve for a noob when following n0nce's instructions.

- cannot use the binary file that n0nce has linked to, because I'm using a different OS than n0nce used. At least, I assume that is the case. I got around that issue by accessing the Apollo SD card with the FutureBit OS on it (in a card reader on my laptop). Find the appropriate file for the specific OS flavour, copy it to a USB memory stick, stick it into the Apollo and copy it into the /home folder. Then (for this specific case only):  
Code:
sudo mv rk3399-orangepi-4-lts.dtb /boot/dtb/rockchip/rk3399-orangepi-4-lts.dtb
Such fun typing this stuff without any typo's!

- that vim text editor will drive you nuts, unless you just use the few commands needed for the task: type 'i' to get it into insert mode, then edit the file as instructed by n0nce, then Esc button to end the insert mode, then :x! to save and exit. I got that tidbit of geek-speak from here: https://www.geeksforgeeks.org/getting-started-with-vim-editor-in-linux/

- whatever you do, do not try to use the built-in help of that vim editor unless you want to spend a lot of time getting nowhere while then fan is still howling!  Grin The creator of vim must be some evil genius type of person.....
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
GUI setup
To get the nice Web UI, we can just install it from GitHub, since jstefanop made it open source! \o/
https://github.com/jstefanop/apolloui

Attention: As of now, you need to actually get the apolloapi repo instead, since it handles the authentication to the web UI. Also the project(s) require a very old, potentially insecure version of NodeJS; namely NodeJS 9.x - use at your own risk. Do note that you can mine and run your nodes without any web UI at all..


[3] Input the following content. This is very much inspired by what the 'original Futurebit OS' ships.
Code:
#!/bin/bash

settings='-host stratum.kano.is -port 3333 -user username.worker -pswd x -brd_ocp 48 -osc 30 -fan_temp_low 70 -fan_temp_hi 90'

[...]
Just set desired mining speed and fan speed / temperature in the settings=... line of step 3 from above.


[1] Move to admin user account and clone the repo.
Code:
cd /home/admin
git clone https://github.com/jstefanop/apolloui.git
cd apolloui

[2] Install nodeJS, npm and yarn.
Code:
sudo apt install python -y
sudo apt install nodejs npm -y
sudo npm install yarn -g

[3] Build the software.
Code:
yarn
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
Service setup

[1] Create miner service file:
Code:
sudo vim /usr/lib/systemd/system/miner.service

[2] Contents should be like shown:
Code:
[Unit]
Description=Apollo Miner
After=network.target

[Service]
WorkingDirectory=/opt/miner/linux-aarch64
ExecStart=/opt/miner/linux-aarch64/miner_start.sh
ExecStop=/opt/miner/linux-aarch64/miner_stop.sh

# Make sure the config directory is readable by the service user
PermissionsStartOnly=true

# Process management
####################

Type=forking
Restart=on-failure

# Directory creation and permissions
####################################

# Run as root:root
#User=admin
#Group=sudo

# Hardening measures
####################

# Provide a private /tmp and /var/tmp.
PrivateTmp=true

# Mount /usr, /boot/ and /etc read-only for the process.
# Mounts everything read-only with the exception of /dev, /proc and /sys.
ProtectSystem=full

# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true

# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true

## More hardening
ProtectControlGroups=yes
ProtectHostname=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
ProtectProc=yes

RestrictNamespaces=yes
RestrictRealtime=yes

LockPersonality=yes

SystemCallArchitectures=native
SystemCallFilter=~@privileged @resources
SystemCallFilter=@system-service

CapabilityBoundingSet=CAP_SYS_ADMIN
CapabilityBoundingSet=CAP_SYS_RAWIO
CapabilityBoundingSet=CAP_MKNOD

[Install]
WantedBy=multi-user.target

[3] Enable & start service
Code:
sudo systemctl enable miner.service
sudo service miner start

[4] Check that the miner is running fine.
Code:
sudo service miner status

[5] after a few minutes or hours you can also see activity in your pool's dashboard.
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
Miner setup

Get latest binaries from: https://bitcointalksearch.org/topic/m.57091051
Log into your admin account.

[1] Download and unpack binary. Replace the URL below with whatever is latest at time of reading.
Code:
sudo mkdir /opt/miner && cd /opt/miner
sudo wget https://github.com/jstefanop/Apollo-Miner-Binaries/releases/download/1.1/Apollo-Miner_linux-aarch64.tar.xz
sudo tar xf Apollo-Miner_linux-aarch64.tar.xz

[2] Edit the miner_start.sh file.
Code:
cd linux-aarch64/
sudo vim miner_start.sh

[3] Input the following content. This is very much inspired by what the 'original Futurebit OS' ships.
Code:
#!/bin/bash

settings='-host stratum.kano.is -port 3333 -user username.worker -pswd x -brd_ocp 48 -osc 30 -fan_temp_low 70 -fan_temp_hi 90'

start_hashboards()
{
        while [ $1 ];
                do
                screen -dmS miner ./apollo-miner -comport $1 -ao_mode 1 $settings
                sleep 1
                shift
        done
}

#reset internal hashboard
gpio write 0 0
sleep .5
gpio write 0 1

sleep 30
#start internal hashboard
screen -dmS miner ./apollo-miner -comport /dev/ttyS1 -ao_mode 1 $settings

#find and start external hashboards
ports=$(ls /dev/ttyACM*)
start_hashboards $ports

echo "Started"

[4] Configure the 'settings' line of this file correctly, to point to your user account and worker name on a pool of your choice. Then hook up the hashboard to the SBC using a Micro-USB to USB-A cable. [TO-DO: this won't be needed later when I figure out the UART connection]
Make sure that stratum.kano.is is replaced with your pool's URL and that username.worker is your username on that pool concatenated with a worker name.

[5] Make the file executable.
Code:
sudo chmod +x ./miner_start.sh

[6] To test everything's working, execute it and give it some time to start up the hashboard and perform some hashes.
Code:
sudo ./miner_start.sh

[7] Create the file for stopping all hashboards.
Code:
sudo vim ./miner_stop.sh

[8] Add this content. Full credit to jstefanop.
Code:
#!/bin/bash

reset_hashboards()
{
        while [ $1 ];
                do
                python -c 'import termios; termios.tcsendbreak(3, 0)' 3>$1
                sleep .5
                shift
        done
}

#quit all mining proccesses
for scr in $(screen -ls | awk '{print $1}'); do screen -S $scr -X quit; done

#reset internal hashboard
gpio write 0 0
sleep .5
gpio write 0 1

#find and reset external hashboards
ports=$(ls /dev/ttyACM*)
reset_hashboards $ports

echo "Stopped"

[9] Make it executable.
Code:
sudo chmod +x ./miner_stop.sh

[10] Stop the miner for now.
Code:
sudo ./miner_stop.sh
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
GPIO Setup
[1] Download WiringOP to get access to GPIO of the Orange Pi 4.
Code:
cd /home/admin
git clone https://github.com/orangepi-xunlong/WiringOP
cd WiringOP

[2] Build the software
Code:
./build clean
./build

[3] Verify you have GPIO access.
Code:
cd && gpio -v && gpio readall

[4] The above command should output something like this.
Code:
gpio version: 2.46
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

   * Device tree is enabled.
   *--> OrangePi 4

 +------+-----+----------+------+---+OrangePi 4+---+---+--+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | GPIO |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
 |      |     |     3.3V |      |   |  1 || 2  |   |      | 5V       |     |      |
 |   64 |   0 | I2C2_SDA |   IN | 1 |  3 || 4  |   |      | 5V       |     |      |
 |   65 |   1 | I2C2_SCL |   IN | 1 |  5 || 6  |   |      | GND      |     |      |
 |  150 |   2 |     PWM1 | ALT2 | 1 |  7 || 8  | 1 | ALT2 | I2C3_SCL | 3   | 145  |
 |      |     |      GND |      |   |  9 || 10 | 1 | ALT2 | I2C3_SDA | 4   | 144  |
 |   33 |   5 | GPIO1_A1 |   IN | 0 | 11 || 12 | 1 | IN   | GPIO1_C2 | 6   | 50   |
 |   35 |   7 | GPIO1_A3 |  OUT | 1 | 13 || 14 |   |      | GND      |     |      |
 |   92 |   8 | GPIO2_D4 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO1_C6 | 9   | 54   |
 |      |     |     3.3V |      |   | 17 || 18 | 0 | IN   | GPIO1_C7 | 10  | 55   |
 |   40 |  11 | SPI1_TXD | ALT3 | 0 | 19 || 20 |   |      | GND      |     |      |
 |   39 |  12 | SPI1_RXD | ALT3 | 1 | 21 || 22 | 0 | IN   | GPIO1_D0 | 13  | 56   |
 |   41 |  14 | SPI1_CLK | ALT3 | 1 | 23 || 24 | 1 | ALT3 | SPI1_CS  | 15  | 42   |
 |      |     |      GND |      |   | 25 || 26 | 0 | IN   | GPIO4_C5 | 16  | 149  |
 |   64 |  17 | I2C2_SDA |   IN | 1 | 27 || 28 | 1 | IN   | I2C2_SCL | 18  | 65   |
 |      |     |  I2S0_RX |      |   | 29 || 30 |   |      | GND      |     |      |
 |      |     |  I2S0_TX |      |   | 31 || 32 |   |      | I2S_CLK  |     |      |
 |      |     | I2S0_SCK |      |   | 33 || 34 |   |      | GND      |     |      |
 |      |     | I2S0_SI0 |      |   | 35 || 36 |   |      | I2S0_SO0 |     |      |
 |      |     | I2S0_SI1 |      |   | 37 || 38 |   |      | I2S0_SI2 |     |      |
 |      |     |      GND |      |   | 39 || 40 |   |      | I2S0_SI3 |     |      |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | GPIO |
 +------+-----+----------+------+---+OrangePi 4+---+---+--+----------+-----+------+

[5] Download the DTS file that comes with the 'Apollo OS'. Yes, this is a binary file I'm providing, but the apollo miner binary is, too, and I'm trying to figure out a better way for this as we speak.
Code:
wget https://github.com/iamthen0nce/apollo-dtb/raw/main/rk3399-orangepi-4.dtb

[6] Move it into the right directory.
Code:
sudo mv rk3399-orangepi-4.dtb /boot/dtb/rockchip/rk3399-orangepi-4.dtb

[7] Edit the /etc/rc.local file.
Code:
sudo vim /etc/rc.local

[8] Replace 'exit 0' line with the following.
Code:
#configure gpios
gpio mode 1 out
gpio write 1 0
gpio mode 0 out
gpio write 0 1

[9] Reboot the unit.
Code:
sudo reboot
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
Miner Install Guide

This is part of my Futurebit Apollo BTC Custom Linux install guide.
See here for the prerequisites.
Pages:
Jump to: