Tidy hardware type detection functions

This commit is contained in:
Simon Long 2022-04-25 17:41:12 +01:00
parent 224369d93b
commit 2ef9a3a194
2 changed files with 22 additions and 1 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
raspi-config (20220425) bullseye; urgency=medium
* Tidy hardware detection functions
-- Simon Long <simon@raspberrypi.com> Mon, 25 Apr 2022 17:38:35 +0100
raspi-config (20220419) bullseye; urgency=medium raspi-config (20220419) bullseye; urgency=medium
* Reinstate -R parameter for xcompmgr * Reinstate -R parameter for xcompmgr

View File

@ -25,6 +25,8 @@ else
CMDLINE=/proc/cmdline CMDLINE=/proc/cmdline
fi fi
# tests for Pi 1, 2 and 0 all test for specific boards...
is_pione() { is_pione() {
if grep -q "^Revision\s*:\s*00[0-9a-fA-F][0-9a-fA-F]$" /proc/cpuinfo; then if grep -q "^Revision\s*:\s*00[0-9a-fA-F][0-9a-fA-F]$" /proc/cpuinfo; then
return 0 return 0
@ -45,6 +47,13 @@ is_pizero() {
return $? return $?
} }
# ...while tests for Pi 3 and 4 just test processor type, so will also find CM3, CM4, Zero 2 etc.
is_pithree() {
grep -q "^Revision\s*:\s*[ 123][0-9a-fA-F][0-9a-fA-F]2[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$" /proc/cpuinfo
return $?
}
is_pifour() { is_pifour() {
grep -q "^Revision\s*:\s*[ 123][0-9a-fA-F][0-9a-fA-F]3[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$" /proc/cpuinfo grep -q "^Revision\s*:\s*[ 123][0-9a-fA-F][0-9a-fA-F]3[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$" /proc/cpuinfo
return $? return $?
@ -55,8 +64,14 @@ get_pi_type() {
echo 1 echo 1
elif is_pitwo; then elif is_pitwo; then
echo 2 echo 2
else elif is_pithree; then
echo 3
elif is_pifour; then
echo 4
elif is_pizero; then
echo 0 echo 0
else
echo -1
fi fi
} }