From aa97f12a5d84f6808695cad00f749bef5773a9a4 Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz Date: Sun, 7 Jan 2024 17:57:56 +0100 Subject: [PATCH] fix: add pi5 support (#225) Signed-off-by: Patrick Gehrsitz --- README.md | 1 + bin/build.sh | 23 ++++++++++++++++++++++- libs/core.sh | 4 +++- libs/hwhandler.sh | 9 +++++++++ libs/init_stream.sh | 4 +++- libs/versioncontrol.sh | 4 +++- tools/libs/core.sh | 17 +++++++++++++++++ 7 files changed, 58 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 18d3af21..a280f44f 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ See the [README.md](https://github.com/mainsail-crew/crowsnest/tree/legacy/v3) o #### Hint Bookworm Raspberry Pi OS images that are based on Debian 12 (codename 'bookworm') currently use a different branch of [camera-streamer](https://github.com/ayufan/camera-streamer)! +The Raspberry Pi 5 has only [ustreamer](https://github.com/pikvm/ustreamer) support! This is due to the missing JPEG and H264 Hardware encoders. --- diff --git a/bin/build.sh b/bin/build.sh index 4093d454..6c03f292 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -79,6 +79,24 @@ is_bookworm() { fi } +is_pi5() { + if [[ -f /proc/device-tree/model ]] && + grep -q "Raspberry Pi 5" /proc/device-tree/model; then + echo "1" + else + echo "0" + fi +} + +is_ubuntu_arm() { + if [[ "$(is_raspberry_pi)" = "1" ]] && + grep -q "ubuntu" /etc/os-release; then + echo "1" + else + echo "0" + fi +} + ### Get avail mem get_avail_mem() { grep "MemTotal" /proc/meminfo | awk '{print $2}' @@ -114,7 +132,10 @@ clone_ustreamer() { clone_cstreamer() { ## Special handling because only supported on Raspberry Pi [[ -n "${CROWSNEST_UNATTENDED}" ]] || CROWSNEST_UNATTENDED="0" - if [[ "$(is_raspberry_pi)" = "0" ]] && [[ "${CROWSNEST_UNATTENDED}" = "0" ]]; then + if { [[ "$(is_raspberry_pi)" = "0" ]] || + [[ "$(is_pi5)" = "1" ]] || + [[ "$(is_ubuntu_arm)" = "1" ]]; } && + [[ "${CROWSNEST_UNATTENDED}" = "0" ]]; then printf "WARN: Cloning camera-streamer skipped! Device is not supported!" return fi diff --git a/libs/core.sh b/libs/core.sh index 0f1a904c..aab784df 100755 --- a/libs/core.sh +++ b/libs/core.sh @@ -93,7 +93,9 @@ function check_apps { fi ## Avoid dependency check if non rpi sbc - if [[ "$(is_raspberry_pi)" = "1" ]] && [[ "$(is_ubuntu_arm)" = "0" ]]; then + if [[ "$(is_raspberry_pi)" = "1" ]] && + [[ "$(is_ubuntu_arm)" = "0" ]] && + [[ "$(is_pi5)" = "0" ]]; then if [[ -x "${BASE_CN_PATH}/${cstreamer}" ]]; then log_msg "Dependency: '${cstreamer##*/}' found in ${cstreamer}." else diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 7ee45d1a..2e1fd075 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -131,6 +131,15 @@ is_raspberry_pi() { fi } +is_pi5() { + if [[ -f /proc/device-tree/model ]] && + grep -q "Raspberry Pi 5" /proc/device-tree/model; then + echo "1" + else + echo "0" + fi +} + is_ubuntu_arm() { if [[ "$(is_raspberry_pi)" = "1" ]] && grep -q "ubuntu" /etc/os-release; then diff --git a/libs/init_stream.sh b/libs/init_stream.sh index 4b6dce64..2884c698 100755 --- a/libs/init_stream.sh +++ b/libs/init_stream.sh @@ -27,7 +27,9 @@ function construct_streamer { check_section "${cams}" case ${mode} in [mM]ulti | camera-streamer) - if [[ "$(is_raspberry_pi)" = "1" ]] && [[ "$(is_ubuntu_arm)" = "0" ]]; then + if [[ "$(is_raspberry_pi)" = "1" ]] && + [[ "$(is_ubuntu_arm)" = "0" ]] && + [[ "$(is_pi5)" = "0" ]]; then MULTI_INSTANCES+=( "${cams}" ) else log_msg "WARN: Mode 'camera-streamer' is not supported on your device!" diff --git a/libs/versioncontrol.sh b/libs/versioncontrol.sh index 806bf120..2c7b1850 100644 --- a/libs/versioncontrol.sh +++ b/libs/versioncontrol.sh @@ -42,7 +42,9 @@ versioncontrol() { # Camera Streamer has no version Output yet get_ayucamstream_version() { local cur_ver avail_ver - if [[ "$(is_raspberry_pi)" = "1" ]] && [[ "$(is_ubuntu_arm)" = "0" ]]; then + if [[ "$(is_raspberry_pi)" = "1" ]] && + [[ "$(is_ubuntu_arm)" = "0" ]] && + [[ "$(is_pi5)" = "0" ]]; then pushd "${BASE_CN_PATH}"/bin/camera-streamer &> /dev/null || exit 1 avail_ver="($(git describe --tags --always))" cur_ver="$("${PWD}"/camera-streamer --version | tr -d " ")" diff --git a/tools/libs/core.sh b/tools/libs/core.sh index a72bb4a4..3fe80165 100755 --- a/tools/libs/core.sh +++ b/tools/libs/core.sh @@ -67,6 +67,15 @@ is_raspberry_pi() { fi } +is_pi5() { + if [[ -f /proc/device-tree/model ]] && + grep -q "Raspberry Pi 5" /proc/device-tree/model; then + echo "1" + else + echo "0" + fi +} + is_ubuntu_arm() { if [[ "$(is_raspberry_pi)" = "1" ]] && grep -q "ubuntu" /etc/os-release; then @@ -104,6 +113,14 @@ shallow_cs_dependencies_check() { fi status_msg "Checking if device is a Raspberry Pi ..." "0" + msg "Checking if device is not a Raspberry Pi 5 ...\n" + if [[ "$(is_pi5)" = "1" ]]; then + status_msg "Checking if device is not a Raspberry Pi 5 ..." "3" + msg "This device is a Raspberry Pi 5 therefore camera-streeamer cannot be installed ..." + return 1 + fi + status_msg "Checking if device is not a Raspberry Pi 5 ..." "0" + msg "Checking if device is not running Ubuntu ...\n" if [[ "$(is_ubuntu_arm)" = "1" ]]; then status_msg "Checking if device is not running Ubuntu ..." "3"