Add Rock Pi 4 support

This commit is contained in:
Taylor Helsper 2022-01-24 21:50:13 -06:00
parent d243b27ce8
commit ffb7b58e21
14 changed files with 208 additions and 67 deletions

View File

@ -66,6 +66,11 @@ setup_new_rockpro64: start_file_server out/base_images/rockpro64_base.img.gz roo
@cp -f setup/setup_device.sh out/setup_device.sh
@/bin/bash scripts/setup_new_rockpro64.sh
.PHONY: setup_new_rockpi4
setup_new_rockpi4: start_file_server out/base_images/rockpi4_base.img.gz rootfs
@cp -f setup/setup_device.sh out/setup_device.sh
@/bin/bash scripts/setup_new_rockpi4.sh
.PHONY: setup_new_raspi3
setup_new_raspi3: start_file_server out/base_images/raspi3_base.img.gz rootfs
@cp -f setup/setup_device.sh out/setup_device.sh

View File

@ -0,0 +1,45 @@
# Setup Base Image (Rock Pi 4)
1. After Armbian Flash
- Open Terminal (no login)
- Change set root password to something like rootbolt
- Create admin user with password adminbolt
2. Login as admin
3. Delete root password and set admin pass to bolt
```sh
sudo passwd -d root
sudo passwd admin
```
4. Set hostname
```sh
echo "myNode" | sudo tee /etc/hostname
sudo sed -i 's/rockpi4-b/myNode/g' /etc/hosts
# OR armbian-config -> Personal -> Hostname
```
5. Update packages
```sh
sudo apt-get update
sudo apt-get -y upgrade
```
6. Install some necessary tools
```sh
sudo apt-get -y install network-manager tmux
```
7. Sync
```sh
sync
```
8. Make image now (if imaging)

View File

@ -3,7 +3,7 @@
# DEPRECATED DEVICES: raspi3
# Make each device
for i in 'raspi4' 'rock64' 'rockpro64' 'debian'; do
for i in 'raspi4' 'rock64' 'rockpro64' 'rockpi4' 'debian'; do
echo Creating root file system for $i
mkdir -p out/rootfs_$i/
rsync -r -u rootfs/standard/* out/rootfs_$i/

View File

@ -0,0 +1,4 @@
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# No reason to truncate, we use log rotate
# */15 * * * * root /usr/lib/armbian/armbian-truncate-logs

View File

@ -0,0 +1,12 @@
# configuration values for the armbian-ram-logging service
#
# enable the armbian-ram-logging service?
ENABLED=true
#
# size of the tmpfs mount -- please keep in mind to adjust /etc/default/armbian-zram-config too when increasing
SIZE=150M
#
# use rsync instead of cp -r
# requires rsync installed, may provide better performance
# due to copying only new and changed files
USE_RSYNC=false

View File

@ -0,0 +1,34 @@
# configuration values for the armbian-zram-config service
#
# enable the armbian-zram-config service?
ENABLED=false
# percentage of zram used as swap compared to physically available DRAM.
# Huge overcommitment (300) is possible and sometimes desirable. See
# https://forum.armbian.com/topic/5565-zram-vs-swap/?do=findComment&comment=61082
# and don't forget to adjust $MEM_LIMIT_PERCENTAGE below too.
# ZRAM_PERCENTAGE=50
# percentage of DRAM available to zram. If this amount is exceeded the zram
# devices used for swap simply behave as if the device is full. You need to
# adjust/increase this value only if you want to work with massive memory
# overcommitment (ZRAM_PERCENTAGE exceeding 150 for example)
# MEM_LIMIT_PERCENTAGE=50
# create how many zram devices max for swap
# ZRAM_MAX_DEVICES=4
# Which algorithm for zram based swapping. Seems lzo is best choice on ARM:
# https://forum.armbian.com/topic/8161-swap-on-sbc/?do=findComment&comment=61668
# SWAP_ALGORITHM=lzo
# Which algorithm to choose for zram based ramlog partition
# RAMLOG_ALGORITHM=zstd
# Which algorithm to choose for zram based /tmp
# TMP_ALGORITHM=zstd
# If defined a separate partition will be used as zram backing device. Be CAREFUL
# which partition you assign and read starting from CONFIG_ZRAM_WRITEBACK in
# https://www.kernel.org/doc/Documentation/blockdev/zram.txt
# ZRAM_BACKING_DEV=/dev/nvme0n2

BIN
rootfs/rockpi4/usr/bin/electrs Executable file

Binary file not shown.

View File

@ -269,7 +269,7 @@ if [ $IS_RASPI = 1 ]; then
if [ $IS_RASPI4_ARM64 = 1 ]; then
ARCH="aarch64-linux-gnu"
fi
elif [ $IS_ROCK64 = 1 ] || [ $IS_ROCKPRO64 = 1 ]; then
elif [ $IS_ROCK64 = 1 ] || [ $IS_ROCKPRO64 = 1 ] || [ $IS_ROCKPI4 = 1 ]; then
ARCH="aarch64-linux-gnu"
elif [ $IS_X86 = 1 ]; then
ARCH="x86_64-linux-gnu"
@ -324,7 +324,7 @@ LND_ARCH="lnd-linux-armv7"
if [ $IS_X86 = 1 ]; then
LND_ARCH="lnd-linux-amd64"
fi
if [ $IS_RASPI4_ARM64 = 1 ]; then
if [ $IS_RASPI4_ARM64 = 1 ] || [ $IS_ROCK64 = 1 ] || [ $IS_ROCKPRO64 = 1 ] || [ $IS_ROCKPI4 = 1 ]; then
LND_ARCH="lnd-linux-arm64"
fi
LND_UPGRADE_URL=https://github.com/lightningnetwork/lnd/releases/download/$LND_VERSION/$LND_ARCH-$LND_VERSION.tar.gz

View File

@ -59,7 +59,8 @@ if [ ! -f /var/lib/mynode/.expanded_rootfs ]; then
raspi-config --expand-rootfs
touch /var/lib/mynode/.expanded_rootfs
fi
if [ $IS_ROCK64 = 1 ] || [ $IS_ROCKPRO64 = 1 ]; then
#if [ $IS_ROCK64 = 1 ] || [ $IS_ROCKPRO64 = 1 ] || [ $IS_ROCKPI4 = 1 ]; then
if [ $IS_ARMBIAN = 1 ]; then
/usr/lib/armbian/armbian-resize-filesystem start
touch /var/lib/mynode/.expanded_rootfs
fi
@ -487,18 +488,7 @@ fi
chown -R joinmarket:joinmarket /mnt/hdd/mynode/joinmarket
# Setup Mempool
cp -f /usr/share/mynode/mempool-docker-compose.yml /mnt/hdd/mynode/mempool/docker-compose.yml
if [ ! -f /mnt/hdd/mynode/mempool/.env ]; then
cp -f /usr/share/mynode/mempool.env /mnt/hdd/mynode/mempool/.env
fi
if [ -f /mnt/hdd/mynode/mempool/.env ]; then
sed -i "s/VERSION=.*/VERSION=$MEMPOOL_VERSION/g" /mnt/hdd/mynode/mempool/.env
fi
if [ $IS_RASPI -eq 1 ] && [ $IS_RASPI4_ARM64 -eq 0 ]; then
sed -i "s|MARIA_DB_IMAGE=.*|MARIA_DB_IMAGE=hypriot/rpi-mysql:latest|g" /mnt/hdd/mynode/mempool/.env
else
sed -i "s|MARIA_DB_IMAGE=.*|MARIA_DB_IMAGE=mariadb:10.5.8|g" /mnt/hdd/mynode/mempool/.env
fi
# Moved to mynode_pre_mempool.sh
# Setup Netdata
mkdir -p /opt/mynode/netdata
@ -541,9 +531,6 @@ fi
if [ -f /mnt/hdd/mynode/lit/lit.conf ]; then
sed -i "s/faraday.bitcoin.password=.*/faraday.bitcoin.password=$BTCRPCPW/g" /mnt/hdd/mynode/lit/lit.conf
fi
if [ -f /mnt/hdd/mynode/mempool/.env ]; then
sed -i "s/BITCOIN_RPC_PASS=.*/BITCOIN_RPC_PASS=$BTCRPCPW/g" /mnt/hdd/mynode/mempool/.env
fi
echo "BTC_RPC_PASSWORD=$BTCRPCPW" > /mnt/hdd/mynode/settings/.btcrpc_environment
chown bitcoin:bitcoin /mnt/hdd/mynode/settings/.btcrpc_environment
if [ -f /mnt/hdd/mynode/bitcoin/bitcoin.conf ]; then

View File

@ -53,9 +53,9 @@ rm -f /usr/share/mynode/beta_version
# Extract to temp location
tar -xf /opt/mynode_release_latest.tar.gz -C /opt/upgrade/
# Install files
# Install files (migrate all to rsync?)
VERSION=$(cat /opt/upgrade/out/rootfs_*/usr/share/mynode/version)
if [ $IS_X86 = 1 ] || [ $IS_RASPI4_ARM64 = 1 ]; then
if [ $IS_X86 = 1 ] || [ $IS_RASPI4_ARM64 = 1 ] || [ $IS_ROCKPI4 = 1 ]; then
rsync -r -K /opt/upgrade/out/rootfs_${DEVICE_TYPE}/* / 2>&1
else
cp -rf /opt/upgrade/out/rootfs_${DEVICE_TYPE}/* / 2>&1

View File

@ -2,16 +2,31 @@ version: "3.7"
services:
web:
environment:
FRONTEND_HTTP_PORT: "8080"
BACKEND_MAINNET_HTTP_HOST: "api"
image: mempool/frontend:${VERSION}
restart: on-failure
stop_grace_period: 1m
command: "./wait-for db:3306 --timeout=720 -- nginx -g 'daemon off;'"
ports:
- 4080:8080
environment:
FRONTEND_HTTP_PORT: "8080"
BACKEND_MAINNET_HTTP_HOST: "api"
api:
environment:
MEMPOOL_BACKEND: "electrum"
CORE_RPC_HOST: "172.26.0.1"
CORE_RPC_PORT: "8332"
CORE_RPC_USERNAME: "mynode"
CORE_RPC_PASSWORD: "${BITCOIN_RPC_PASS}"
ELECTRUM_HOST: "172.26.0.1"
ELECTRUM_PORT: "50001"
ELECTRUM_TLS: "false"
DATABASE_ENABLED: "true"
DATABASE_HOST: "db"
DATABASE_DATABASE: "mempool"
DATABASE_USERNAME: "mempool"
DATABASE_PASSWORD: "mempool"
STATISTICS_ENABLED: "true"
image: mempool/backend:${VERSION}
user: 0:0
restart: on-failure
@ -19,31 +34,22 @@ services:
command: "./wait-for-it.sh db:3306 --timeout=720 --strict -- ./start.sh"
volumes:
- /mnt/hdd/mynode/mempool/data:/backend/cache
environment:
RPC_HOST: "172.17.0.1"
RPC_PORT: "8332"
RPC_USER: "mynode"
RPC_PASS: "${BITCOIN_RPC_PASS}"
ELECTRUM_HOST: "172.17.0.1"
ELECTRUM_PORT: "50001"
ELECTRUM_TLS: "false"
MYSQL_HOST: "db"
MYSQL_PORT: "3306"
MYSQL_DATABASE: "mempool"
MYSQL_USER: "mempool"
MYSQL_PASS: "mempool"
BACKEND_MAINNET_HTTP_PORT: "8999"
MEMPOOL_CLEAR_PROTECTION_MINUTES: "20"
CACHE_DIR: "/backend/cache/"
db:
environment:
MYSQL_DATABASE: "mempool"
MYSQL_USER: "mempool"
MYSQL_PASSWORD: "mempool"
MYSQL_ROOT_PASSWORD: "admin"
image: ${MARIA_DB_IMAGE}
restart: on-failure
stop_grace_period: 1m
volumes:
- /mnt/hdd/mynode/mempool/mysql/data:/var/lib/mysql
- /mnt/hdd/mynode/mempool/mysql/db-scripts:/docker-entrypoint-initdb.d
environment:
MYSQL_DATABASE: "mempool"
MYSQL_USER: "mempool"
MYSQL_PASSWORD: "mempool"
MYSQL_ROOT_PASSWORD: "admin"
networks:
default:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.26.0.1/24

View File

@ -8,6 +8,7 @@ IS_RASPI=0
IS_RASPI3=0
IS_RASPI4=0
IS_RASPI4_ARM64=0
IS_ROCKPI4=0
IS_X86=0
IS_32_BIT=0
IS_64_BIT=0
@ -36,12 +37,18 @@ elif [[ $MODEL == *"Raspberry Pi 4"* ]]; then
IS_32_BIT=0
IS_64_BIT=1
fi
elif [[ $MODEL == *"ROCK Pi 4"* ]]; then
IS_ARMBIAN=1
IS_ROCKPI4=1
IS_64_BIT=1
fi
if [ $IS_RASPI3 -eq 1 ]; then
DEVICE_TYPE="raspi3"
elif [ $IS_RASPI4 -eq 1 ]; then
DEVICE_TYPE="raspi4"
elif [ $IS_ROCKPI4 -eq 1 ]; then
DEVICE_TYPE="rockpi4"
elif [ $IS_ROCK64 -eq 1 ]; then
DEVICE_TYPE="rock64"
elif [ $IS_ROCKPRO64 -eq 1 ]; then

49
scripts/setup_new_rockpi4.sh Executable file
View File

@ -0,0 +1,49 @@
#!/bin/bash
LOCAL_IP=$(python ./scripts/get_local_ip.py)
echo ""
echo "Finished updating rootfs and other files!"
echo ""
clear
echo "Step 1: "
echo " Flash SD Card with Rock Pi 4 Image: out/base_images/rockpi4_base.img.gz"
echo " OR"
echo " If you would rather create your own base image, follow the"
echo " manual instructions in doc/setup_base_image_rockpi4.md"
echo ""
echo "Press a key when complete..."
read -n 1
clear
echo "Step 2: "
echo " Insert SD Card into your Rock Pi 4 and boot the device"
echo ""
echo "Press a key when complete..."
read -n 1
clear
echo "Step 3: "
echo " Login to device with username 'admin' and password 'bolt'"
echo " Run the following commands. Use bolt at password prompts."
echo " wget http://${LOCAL_IP}:8000/setup_device.sh -O setup_device.sh"
echo " chmod +x setup_device.sh"
echo " tmux new-session -s mynode sudo ./setup_device.sh ${LOCAL_IP}"
echo ""
echo "Press a key when complete..."
read -n 1
clear
echo "Step 4:"
echo " Reboot your device."
echo ""
echo "Press a key when complete..."
read -n 1
clear
echo "Congratulations! Your device is now ready!"
echo " Access it via a web browser at http://mynode.local/ or http://<device ip>/"
echo " Access it via SSH using the default credentials: admin / bolt"
echo " You should change your password on the settings page in the web GUI"
echo ""

View File

@ -22,6 +22,7 @@ IS_RASPI=0
IS_RASPI3=0
IS_RASPI4=0
IS_RASPI4_ARM64=0
IS_ROCKPI4=0
IS_X86=0
IS_32_BIT=0
IS_64_BIT=0
@ -51,8 +52,13 @@ elif [[ $MODEL == *"Raspberry Pi 4"* ]]; then
IS_32_BIT=0
IS_64_BIT=1
fi
elif [[ $MODEL == *"ROCK Pi 4"* ]]; then
IS_ARMBIAN=1
IS_ROCKPI4=1
IS_64_BIT=1
fi
if [ $IS_UNKNOWN = 1 ]; then
echo "UNKNOWN DEVICE TYPE"
exit 1
@ -102,6 +108,8 @@ elif [ $IS_RASPI3 = 1 ]; then
TARBALL="mynode_rootfs_raspi3.tar.gz"
elif [ $IS_RASPI4 = 1 ]; then
TARBALL="mynode_rootfs_raspi4.tar.gz"
elif [ $IS_ROCKPI4 = 1 ]; then
TARBALL="mynode_rootfs_rockpi4.tar.gz"
elif [ $IS_X86 = 1 ]; then
TARBALL="mynode_rootfs_debian.tar.gz"
fi
@ -328,7 +336,7 @@ if [ $IS_RASPI = 1 ]; then
if [ $IS_RASPI4_ARM64 = 1 ]; then
ARCH="aarch64-linux-gnu"
fi
elif [ $IS_ROCK64 = 1 ] || [ $IS_ROCKPRO64 = 1 ]; then
elif [ $IS_ROCK64 = 1 ] || [ $IS_ROCKPRO64 = 1 ] || [ $IS_ROCKPI4 = 1 ]; then
ARCH="aarch64-linux-gnu"
elif [ $IS_X86 = 1 ]; then
ARCH="x86_64-linux-gnu"
@ -382,7 +390,7 @@ LND_ARCH="lnd-linux-armv7"
if [ $IS_X86 = 1 ]; then
LND_ARCH="lnd-linux-amd64"
fi
if [ $IS_RASPI4_ARM64 = 1 ]; then
if [ $IS_RASPI4_ARM64 = 1 ] || [ $IS_ROCK64 = 1 ] || [ $IS_ROCKPRO64 = 1 ] || [ $IS_ROCKPI4 = 1 ]; then
LND_ARCH="lnd-linux-arm64"
fi
LND_UPGRADE_URL=https://github.com/lightningnetwork/lnd/releases/download/$LND_VERSION/$LND_ARCH-$LND_VERSION.tar.gz
@ -902,12 +910,7 @@ update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy || true
# Install files (downloaded and extracted earlier)
if [ $IS_X86 = 1 ] || [ $IS_RASPI4_ARM64 = 1 ]; then
rsync -r -K /tmp/upgrade/out/rootfs_*/* /
else
cp -rf /tmp/upgrade/out/rootfs_*/* /
fi
sleep 1
rsync -r -K /tmp/upgrade/out/rootfs_*/* /
sync
sleep 1
@ -965,17 +968,6 @@ systemctl enable corsproxy_btcrpc
systemctl enable usb_extras
# Regenerate MAC Address for Armbian devices
if [ $IS_ARMBIAN = 1 ]; then
. /usr/lib/armbian/armbian-common
CONNECTION="$(nmcli -f UUID,ACTIVE,DEVICE,TYPE connection show --active | grep ethernet | tail -n1)"
UUID=$(awk -F" " '/ethernet/ {print $1}' <<< "${CONNECTION}")
get_random_mac
nmcli connection modify $UUID ethernet.cloned-mac-address $MACADDR
nmcli connection modify $UUID -ethernet.mac-address ""
fi
# Disable services
systemctl disable hitch || true
systemctl disable mongodb || true
@ -993,8 +985,8 @@ rm -rf /tmp/*
rm -rf ~/setup_device.sh
rm -rf /etc/motd # Remove simple motd for update-motd.d
# Reset MAC address for Armbian devices
if [ $IS_ARMBIAN = 1 ] ; then
# Regenerate MAC address for some Armbian devices
if [ $IS_ROCK64 = 1 ] || [ $IS_ROCKPRO64 = 1 ] ; then
. /usr/lib/armbian/armbian-common
CONNECTION="$(nmcli -f UUID,ACTIVE,DEVICE,TYPE connection show --active | tail -n1)"
UUID=$(awk -F" " '/ethernet/ {print $1}' <<< "${CONNECTION}")