Skip to content

Commit

Permalink
fix: add pi5 support (#225)
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Gehrsitz <[email protected]>
  • Loading branch information
mryel00 authored Jan 7, 2024
1 parent 0b4cf6f commit aa97f12
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down
23 changes: 22 additions & 1 deletion bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion libs/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions libs/hwhandler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion libs/init_stream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down
4 changes: 3 additions & 1 deletion libs/versioncontrol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 " ")"
Expand Down
17 changes: 17 additions & 0 deletions tools/libs/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit aa97f12

Please sign in to comment.