Skip to content

Instantly share code, notes, and snippets.

@avanvucht
Last active January 4, 2021 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avanvucht/e4d5a555e90736b9573e7805a8859034 to your computer and use it in GitHub Desktop.
Save avanvucht/e4d5a555e90736b9573e7805a8859034 to your computer and use it in GitHub Desktop.
Armbian for RK3288 TV boxes scripts

About

Some scripts that I use for my RK3288-based Openhour Chameleon TV box

These scripts assume:

  • You have compiled an appropriate desktop image from https://armbian.org/build
    • I use miqi:dev:groovy
  • You have stepped through the first run
  • You are root in a terminal in the Armbian desktop
# Moonlight is the open source client of Nvidia's Limelight gamestreaming feature.
# https://moonlight-stream.org/
# Moonlight needs hardware decoding to work on the RK3288
# Not yet working (3/Jan/2021):
# - RK3288 uses Hantro H1 VPU
# - Linux 5.10 has a staging 'hantro' V4L2 driver
# - This driver does stateless decoding
# - Moonlight uses libva AKA VA-API
# - libva doesn't support V4L2 or stateless decoding
# I have seen a Moonlight-gstreamer branch but that has vanished. I am not sure if it was ever usable.
# Build from source actions
mkdir /src
cd /src
# 2. Build moonlight with QT gui.
# https://github.com/moonlight-stream/moonlight-qt
# Installed above: libva-dev libssl-dev
PACKAGES="
libegl1-mesa-dev
libgl1-mesa-dev
libopus-dev
libqt5svg5-dev
libsdl2-dev
libsdl2-ttf-dev
libavcodec-dev
libvdpau-dev
libxkbcommon-dev
qt5-default
qt5-qmake
qtbase5-dev
qtdeclarative5-dev
qtquickcontrols2-5-dev
wayland-protocols
qml-module-qtquick-controls2
qml-module-qtquick-layouts
qml-module-qtquick-window2
qml-module-qtquick2
"
echo $PACKAGES | xargs apt install -y $PACKAGES
cd /src
git clone https://github.com/moonlight-stream/moonlight-qt.git
cd moonlight-qt
git submodule update --init --recursive
qmake moonlight-qt.pro
make release
make install
exit
# Alternatives:
# 2. Moonlight embedded - moonlight without GUI
git clone https://github.com/irtimmer/moonlight-embedded.git
cd moonlight-embedded
git submodule update --init --recursive
# Probably a couple of packages missing here
PACKAGES="
cmake
libevdev-dev
libudev-dev
libcurl4-openssl-dev
libexpat-dev
libcec-dev
libavahi-client-dev
libp8-platform-dev
libenet-dev
"
echo $PACKAGES | xargs apt install -y $PACKAGES
cmake .
make
make install
echo "/usr/local/lib" >> /etc/ld.so.conf.d/local.conf
ldconfig
# NOT WORKING for armhf 5.10.y
# 1. Build VA-API driver for V4L2
# The driver compiles and loads but it doesn't make any hardware decoding entrypoints available for applications.
PACKAGES="
meson
pkg-config
libva-dev
libdrm-dev
vainfo
vdpauinfo
"
echo $PACKAGES | xargs apt install -y $PACKAGES
git clone https://github.com/bootlin/libva-v4l2-request.git
mkdir libva-v4l2-request/build
cd libva-v4l2-request/build
meson . ..
ninja
ninja install
cp /usr/lib/dri/v4l2_request_drv_video.so /usr/lib/arm-linux-gnueabihf/dri/v4l2_request_drv_video.so
echo "LIBVA_DRIVER_NAME=v4l2_request" >>/etc/environment
echo "Reboot to load V4L2 driver for VAAPI"
#reboot
#!/bin/bash
# curl -sL https://gist.github.com/avanvucht/e4d5a555e90736b9573e7805a8859034/first_run.sh/raw | sudo bash
# Armbian prompts you to
# Note that on recent builds, the SSHd keys fail to generate. Generate the keys with:
# ssh-keygen -A
# The MAC address also isn't fixed on these boards and is random on each boot. This means likely the IP address will change.
# You can fix this by setting a static IP address. TODO: do that here
echo "First run on boot"
USER=$( w -h | cut -d ' ' -f1 | grep -v root | head -1 )
DEVMODE=1
# Passwordless sudo
if [ -n "$USER" ]; then
groupadd admin
usermod -a -G admin $USER
echo "%admin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
SSHDIR="/home/$USER/.ssh"
else
SSHDIR="/root/.ssh"
fi
# Passwordless ssh
# Generate your own key with ssh-keygen and put the contents of the id_rsa.pub file here
# Then access your TV box with: ssh -i ~/.ssh/id_rsa <IP address>
PUBKEY="AAAAB3NzaC1yc2EAAAADAQABAAABgQCmm0kLBzf+rBcbIJyQD3L3MpBliBtqLeXGg/5GHdKOzKqYs/1vNOuhDIkwsBLXThHgJhlYRrcWYd6QnIc4ppfWlaOV3SkjJajANB5OalT7BlSYS5WvXHmsia/uJZCaV7PTrs0WFwcg9BLEGoO4WUXjzYvr8OPGYuKnuMsuPuKI9pwkFEX/7rSzb8xWZSw9EfoiL2f3LsA0TPrHpfa5bWKrUfyX/+/C2WmihbTU+YEljTkOfedkpp3Ee+XgkozddRrdD+8uTthR0K1wITJL9F8p7SiOokR3MH+qEE0Xfi5gUBSHT+ZHfTwBvYZ2YZCPuawm7imy0DORAZzBibJjx1xgbNuHw2jLe12uOG+CkqLuhD/Refklgn6HXsGrWEpj8HuvxAwdxrsl+MKo4pIHdlQLRMRXlEjIw/fK0y+Kl5T4Nw5MpU4qzds/eFftd7cUtVTxdJgxmag1gxDgE/M/vAoXOnnmqdyLN2C0nPSuLMTHJG81xlsNNm0cd3tBprgHyWU="
mkdir $SSHDIR
echo "ssh-rsa ${PUBKEY} ${USER}@master" >>${SSHDIR}/authorized_keys
chmod 0600 ${SSHDIR}/authorized_keys
chmod 0700 ${SSHDIR}
chown -R ${USER}.admin ${SSHDIR}
# Confirm that HDMI sound device is configured:
aplay -l
# Update, upgrade, install packages
apt update
apt full-upgrade -y
PACKAGES="
inxi
mesa-utils
ubuntu-restricted-extras
chromium-codecs-ffmpeg-extra
gstreamer1.0-libav
gstreamer1.0-plugins-ugly
libavcodec-extra
gstreamer1.0-tools
unrar
"
#ttf-mscorefonts-installer
if [ $DEVMODE ]; then
PACKAGES="${PACKAGES}
apt-file
mlocate
"
fi
echo $PACKAGES | xargs apt install -y $PACKAGES
# If Panfrost is working, this will work (it uses glxinfo from mesa-utils)
inxi -FGxzi --display
if [ $DEVMODE ]; then
# Local file index for locate
updatedb
# Repository file index
apt-file update
fi
# Vivaldi with Widevine DRM
# Install Vivaldi
curl -sL https://downloads.vivaldi.com/snapshot/install-vivaldi.sh | bash
# I have to run vivaldi with: vivaldi-snapshot --disable-seccomp-filter-sandbox until Vivaldi updates its Chromium version
# Get ChromeOS Widevine Library
CHROMEOS_URL=$(curl -s https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf | grep -A11 CB5-312T | sed -n 's/^url=//p')
CHROMEOS_IMG="$(basename "$CHROMEOS_URL" .zip)"
# Obtain latest image
# We can't just run the Rurario script because the /tmp folder is not big enough to hold the 2GB ChromeOS image.
cd /opt
wget $CHROMEOS_URL
unzip ${CHROMEOS_IMG}.zip
rm ${CHROMEOS_IMG}.zip
curl -sL https://gist.github.com/ruario/19a28d98d29d34ec9b184c42e5f8bf29/raw/widevine-flash_armhf.sh | bash
tar Cvfx / `ls widevine-flash*.tgz | tail -1`
for HOMEDIR in /home/*; do
mkdir -p ${HOMEDIR}/.config/vivaldi-snapshot/WidevineCdm
echo '{"Path":"/opt/WidevineCdm"}' > ${HOMEDIR}/.config/vivaldi-snapshot/WidevineCdm/latest-component-updated-widevine-cdm
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment