From a35faa0eb8456e3001300ffdbe4f7a669605d710 Mon Sep 17 00:00:00 2001 From: Craig Schardt Date: Sat, 17 Aug 2024 15:50:47 -0500 Subject: [PATCH 1/5] move install.sh --- install.sh | 203 ++++++++++++++++++++++++++++++++++++++++++ install_limelight3.sh | 0 install_snakeyes.sh | 0 3 files changed, 203 insertions(+) create mode 100755 install.sh mode change 100644 => 100755 install_limelight3.sh mode change 100644 => 100755 install_snakeyes.sh diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..ba9cb69 --- /dev/null +++ b/install.sh @@ -0,0 +1,203 @@ +#!/bin/bash + +package_is_installed(){ + dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -q "ok installed" +} + +help() { + echo "This script installs Photonvision." + echo "It must be run as root." + echo + echo "Syntax: sudo ./install.sh [-h|m|n|q]" + echo " options:" + echo " -h Display this help message." + echo " -m Install and configure NetworkManager (Ubuntu only)." + echo " -n Disable networking. This will also prevent installation of NetworkManager." + echo " -q Silent install, automatically accepts all defaults. For non-interactive use." + echo +} + +INSTALL_NETWORK_MANAGER="false" + +while getopts ":hmnq" name; do + case "$name" in + h) + help + exit 0 + ;; + m) INSTALL_NETWORK_MANAGER="true" + ;; + n) DISABLE_NETWORKING="true" + ;; + q) QUIET="true" + ;; + \?) + echo "Error: Invalid option -- '$OPTARG'" + echo "Try './install.sh -h' for more information." + exit 1 + esac +done + +shift $(($OPTIND -1)) + +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +ARCH=$(uname -m) +ARCH_NAME="" +if [ "$ARCH" = "aarch64" ]; then + ARCH_NAME="linuxarm64" +elif [ "$ARCH" = "armv7l" ]; then + echo "ARM32 is not supported by PhotonVision. Exiting." + exit 1 +elif [ "$ARCH" = "x86_64" ]; then + ARCH_NAME="linuxx64" +else + if [ "$#" -ne 1 ]; then + echo "Can't determine current arch; please provide it (one of):" + echo "" + echo "- linuxarm64 (64-bit Linux ARM)" + echo "- linuxx64 (64-bit Linux)" + exit 1 + else + echo "Can't detect arch (got $ARCH) -- using user-provided $1" + ARCH_NAME=$1 + fi +fi + +echo "This is the installation script for PhotonVision." +echo "Installing for platform $ARCH_NAME" + +DISTRO=$(lsb_release -is) +if [[ "$DISTRO" = "Ubuntu" && "$INSTALL_NETWORK_MANAGER" != "true" && -z "$QUIET" && -z "$DISABLE_NETWORKING" ]]; then + echo "" + echo "Photonvision uses NetworkManager to control networking on your device." + read -p "Do you want this script to install and configure NetworkManager? [y/N]: " response + if [[ $response == [yY] || $response == [yY][eE][sS] ]]; then + INSTALL_NETWORK_MANAGER="true" + fi +fi + +echo "Update package list" +apt-get update + +echo "Installing curl..." +apt-get install --yes curl +echo "curl installation complete." + +echo "Installing avahi-daemon..." +apt-get install --yes avahi-daemon +echo "avahi-daemon installation complete." + +echo "Installing cpufrequtils..." +apt-get install --yes cpufrequtils +echo "cpufrequtils installation complete." + +echo "Setting cpufrequtils to performance mode" +if [ -f /etc/default/cpufrequtils ]; then + sed -i -e 's/^#\?GOVERNOR=.*$/GOVERNOR=performance/' /etc/default/cpufrequtils +else + echo 'GOVERNOR=performance' > /etc/default/cpufrequtils +fi + +echo "Installing libatomic" +apt-get install --yes libatomic1 +echo "libatomic installation complete." + +if [[ "$INSTALL_NETWORK_MANAGER" == "true" ]]; then + echo "Installing network-manager..." + apt-get install --yes network-manager net-tools + systemctl disable systemd-networkd-wait-online.service + cat > /etc/netplan/00-default-nm-renderer.yaml < /lib/systemd/system/photonvision.service < Date: Sat, 17 Aug 2024 15:57:49 -0500 Subject: [PATCH 2/5] use install.sh in new location --- install_limelight.sh | 8 +------- install_opi5.sh | 6 ------ install_pi.sh | 5 ----- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/install_limelight.sh b/install_limelight.sh index c3532a6..c058661 100755 --- a/install_limelight.sh +++ b/install_limelight.sh @@ -1,11 +1,5 @@ # Run normal photon installer - -wget https://git.io/JJrEP -O install.sh -chmod +x install.sh -./install.sh -rm install.sh - - +./install.sh -q # edit boot partition install -m 644 limelight/config.txt /boot/ diff --git a/install_opi5.sh b/install_opi5.sh index 4f313d9..79a9dfc 100755 --- a/install_opi5.sh +++ b/install_opi5.sh @@ -33,13 +33,7 @@ freed=$(( before - after )) echo "Freed up $freed KiB" # run Photonvision install script -wget https://git.io/JJrEP -O install.sh -chmod +x install.sh - -sed -i 's/# AllowedCPUs=4-7/AllowedCPUs=0-7/g' install.sh - ./install.sh -m -q -rm install.sh echo "Installing additional things" diff --git a/install_pi.sh b/install_pi.sh index c5821d8..b572db3 100755 --- a/install_pi.sh +++ b/install_pi.sh @@ -1,10 +1,5 @@ # Run normal photon installer - -wget https://git.io/JJrEP -O install.sh -chmod +x install.sh ./install.sh -rm install.sh - # and edit boot partition install -m 644 config.txt /boot/ From bfc6c172c84fca8440f38116e660072f9f8cca88 Mon Sep 17 00:00:00 2001 From: Craig Schardt Date: Sat, 17 Aug 2024 16:21:59 -0500 Subject: [PATCH 3/5] remove redundant installs --- install.sh | 2 +- install_limelight.sh | 8 +++----- install_opi5.sh | 28 ++++------------------------ install_pi.sh | 12 ++++-------- 4 files changed, 12 insertions(+), 38 deletions(-) diff --git a/install.sh b/install.sh index ba9cb69..3f064af 100755 --- a/install.sh +++ b/install.sh @@ -120,7 +120,6 @@ fi echo "Installing the JRE..." if ! package_is_installed openjdk-17-jre-headless then - apt-get update apt-get install --yes openjdk-17-jre-headless fi echo "JRE installation complete." @@ -129,6 +128,7 @@ echo "Installing additional math packages" if [[ "$DISTRO" = "Ubuntu" && -z $(apt-cache search libcholmod3) ]]; then echo "Adding jammy to list of apt sources" add-apt-repository -y -S 'deb http://ports.ubuntu.com/ubuntu-ports jammy main universe' + apt-get --quiet update fi apt-get install --yes libcholmod3 liblapack3 libsuitesparseconfig5 diff --git a/install_limelight.sh b/install_limelight.sh index c058661..ed24544 100755 --- a/install_limelight.sh +++ b/install_limelight.sh @@ -28,12 +28,10 @@ apt-get autoremove -y echo "Installing additional things" sudo apt-get update apt-get install -y pigpiod pigpio device-tree-compiler libraspberrypi-bin -apt-get install -y network-manager -apt-get install -y net-tools +apt-get install -y network-manager net-tools # libcamera-driver stuff -apt-get install -y libegl1 libopengl0 libopencv-core406 libgl1-mesa-dri libcamera0.1 libgbm1 libatomic1 -# mrcal stuff -apt-get install -y libcholmod3 liblapack3 libsuitesparseconfig5 +apt-get install -y libegl1 libopengl0 libopencv-core406 libgl1-mesa-dri libcamera0.1 libgbm1 + rm -rf /var/lib/apt/lists/* apt-get clean diff --git a/install_opi5.sh b/install_opi5.sh index 79a9dfc..cd72d96 100755 --- a/install_opi5.sh +++ b/install_opi5.sh @@ -36,8 +36,7 @@ echo "Freed up $freed KiB" ./install.sh -m -q echo "Installing additional things" - -apt-get install --yes --quiet network-manager net-tools libatomic1 +apt-get install --yes --quiet libc6 libstdc++6 # let netplan create the config during cloud-init rm -f /etc/netplan/00-default-nm-renderer.yaml @@ -48,17 +47,12 @@ cp -f ./OPi5_CIDATA/network-config /boot/network-config # add customized user-data file for cloud-init cp -f ./OPi5_CIDATA/user-data /boot/user-data -# tell NetworkManager not to wait for the carrier on ethernet, which can delay boot -# when the coprocessor isn't connected to the ethernet -# cat > /etc/NetworkManager/conf.d/50-ignore-carrier.conf < Date: Sat, 17 Aug 2024 16:47:39 -0500 Subject: [PATCH 4/5] make sure insall scripts are executable --- install_limelight.sh | 1 + install_limelight3.sh | 1 + install_opi5.sh | 1 + install_pi.sh | 1 + install_snakeyes.sh | 1 + 5 files changed, 5 insertions(+) diff --git a/install_limelight.sh b/install_limelight.sh index ed24544..3ca4779 100755 --- a/install_limelight.sh +++ b/install_limelight.sh @@ -1,4 +1,5 @@ # Run normal photon installer +chmod +x ./install.sh ./install.sh -q # edit boot partition diff --git a/install_limelight3.sh b/install_limelight3.sh index b685a14..15913c0 100755 --- a/install_limelight3.sh +++ b/install_limelight3.sh @@ -1,4 +1,5 @@ # Run the pi install script +chmod +x ./install_pi.sh ./install_pi.sh # Add the one extra file for the LL3 diff --git a/install_opi5.sh b/install_opi5.sh index cd72d96..a26b563 100755 --- a/install_opi5.sh +++ b/install_opi5.sh @@ -33,6 +33,7 @@ freed=$(( before - after )) echo "Freed up $freed KiB" # run Photonvision install script +chmod +x ./install.sh ./install.sh -m -q echo "Installing additional things" diff --git a/install_pi.sh b/install_pi.sh index b7284b9..af63120 100755 --- a/install_pi.sh +++ b/install_pi.sh @@ -1,4 +1,5 @@ # Run normal photon installer +chmod +x ./install.sh ./install.sh -q # and edit boot partition diff --git a/install_snakeyes.sh b/install_snakeyes.sh index add210c..583b6b3 100755 --- a/install_snakeyes.sh +++ b/install_snakeyes.sh @@ -1,4 +1,5 @@ # Run the pi install script +chmod +x ./install_pi.sh ./install_pi.sh # Add the one extra file for the snakeyes hardware config From b51b817a8ea14ae4822b7e563140af7515aa13a7 Mon Sep 17 00:00:00 2001 From: Craig Schardt Date: Sat, 17 Aug 2024 21:19:29 -0500 Subject: [PATCH 5/5] Stick to the high performance cores --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 3f064af..43b9eee 100755 --- a/install.sh +++ b/install.sh @@ -189,8 +189,8 @@ if [ "$DISABLE_NETWORKING" = "true" ]; then fi if [[ -n $(cat /proc/cpuinfo | grep "RK3588") ]]; then - echo "This has a Rockchip RK3588, enabling all cores" - sed -i 's/# AllowedCPUs=4-7/AllowedCPUs=0-7/g' /lib/systemd/system/photonvision.service + echo "This has a Rockchip RK3588, enabling high A76 cores" + sed -i 's/# AllowedCPUs=4-7/AllowedCPUs=4-7/g' /lib/systemd/system/photonvision.service fi cp /lib/systemd/system/photonvision.service /etc/systemd/system/photonvision.service