From a081eef02d71fc678a343896420343986e6dfe10 Mon Sep 17 00:00:00 2001 From: Mitchell Klijs Date: Wed, 30 Sep 2026 23:44:24 +0200 Subject: [PATCH 1/2] Recognise compute modules in assert_hw_rpi A CM4 or CM5 reports "Raspberry Pi Compute Module 4/5" in /proc/device-tree/model. The generic pattern looks for a digit directly after "Raspberry Pi", which such a string never contains, so every compute module fell through to the else branch and the script exited with "NOT RUNNING ON A RECOGNIZED RASPBERRY PI MODEL". Match compute modules before the generic pattern and map them to their generation, which is the question the function is actually asking: a CM5 is a Pi 5 on a different carrier. The original CM carries no number and maps to 1. Verified against the model strings of CM1 through CM5 and of the Pi 1, 4, 5 and 400; none of the previously recognised boards change. A Pi Zero 2 W is still unrecognised, as it was before, and is left alone here. Co-Authored-By: Claude Opus 5 --- common-functions.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common-functions.sh b/common-functions.sh index 5dc77a6..1f3014e 100755 --- a/common-functions.sh +++ b/common-functions.sh @@ -170,7 +170,14 @@ function assert_hw_rpi() { } local detected_model_number - if [[ $model =~ Raspberry\ Pi\ ([0-9]+) ]]; then + # A compute module has no digit directly after "Raspberry Pi", so the + # generic pattern below never matches one. + if [[ $model =~ Raspberry\ Pi\ Compute\ Module\ ([0-9]+) ]]; then + detected_model_number=${BASH_REMATCH[1]} + elif [[ $model == *"Raspberry Pi Compute Module"* ]]; then + # The original CM carries no number. + detected_model_number=1 + elif [[ $model =~ Raspberry\ Pi\ ([0-9]+) ]]; then detected_model_number=${BASH_REMATCH[1]} elif [[ $model == *"Raspberry Pi Model"* ]]; then detected_model_number=1 From 0d52588c506b843eb5636dc90d8698b553c8079e Mon Sep 17 00:00:00 2001 From: rmens Date: Wed, 30 Sep 2026 23:50:43 +0200 Subject: [PATCH 2/2] refactor: simplify Raspberry Pi model detection --- common-functions.sh | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/common-functions.sh b/common-functions.sh index 1f3014e..216f34f 100755 --- a/common-functions.sh +++ b/common-functions.sh @@ -170,16 +170,10 @@ function assert_hw_rpi() { } local detected_model_number - # A compute module has no digit directly after "Raspberry Pi", so the - # generic pattern below never matches one. - if [[ $model =~ Raspberry\ Pi\ Compute\ Module\ ([0-9]+) ]]; then - detected_model_number=${BASH_REMATCH[1]} - elif [[ $model == *"Raspberry Pi Compute Module"* ]]; then - # The original CM carries no number. - detected_model_number=1 - elif [[ $model =~ Raspberry\ Pi\ ([0-9]+) ]]; then - detected_model_number=${BASH_REMATCH[1]} - elif [[ $model == *"Raspberry Pi Model"* ]]; then + # A CMn counts as a Pi n; the original CM and Pi 1 carry no number. + if [[ $model =~ Raspberry\ Pi\ (Compute\ Module\ )?([0-9]+) ]]; then + detected_model_number=${BASH_REMATCH[2]} + elif [[ $model =~ Raspberry\ Pi\ (Compute\ Module|Model) ]]; then detected_model_number=1 else echo -e "${RED}** NOT RUNNING ON A RECOGNIZED RASPBERRY PI MODEL **${NC}"