Skip to content

Commit

Permalink
Add support for pi0w2 (#1627)
Browse files Browse the repository at this point in the history
* Add support for `pi0w2`
* Add is_pi_bt, is_pi_wlan

Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye committed Dec 1, 2021
1 parent 81feb7a commit 227470b
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build-image/openhabian.conf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ framebuffer=enable

# fake hardware
# force treating your box as if it was a ...
# pi4, pi4_8gb, cm4, pi400, pi3, cm3, pi3+, cm3+, pi2, pi1, cm1, pi0, pi0w, x86
# pi4, pi4_8gb, cm4, pi400, pi3, cm3, pi3+, cm3+, pi2, pi1, cm1, pi0, pi0w, pi0w2, x86
# hw=

# Hardware architecture
Expand Down
2 changes: 1 addition & 1 deletion build-image/openhabian.pi-raspios32.conf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ framebuffer=enable

# fake hardware
# force treating your box as if it was a ...
# pi4, pi4_8gb, cm4, pi400, pi3, cm3, pi3+, cm3+, pi2, pi1, cm1, pi0, pi0w, x86
# pi4, pi4_8gb, cm4, pi400, pi3, cm3, pi3+, cm3+, pi2, pi1, cm1, pi0, pi0w, pi0w2, x86
# hw=

# Hardware architecture
Expand Down
2 changes: 1 addition & 1 deletion build-image/openhabian.pi-raspios64beta.conf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ framebuffer=enable

# fake hardware
# force treating your box as if it was a ...
# pi4, pi4_8gb, cm4, pi400, pi3, cm3, pi3+, cm3+, pi2, pi1, cm1, pi0, pi0w, x86
# pi4, pi4_8gb, cm4, pi400, pi3, cm3, pi3+, cm3+, pi2, pi1, cm1, pi0, pi0w, pi0w2, x86
# hw=pi4

# Hardware architecture
Expand Down
2 changes: 1 addition & 1 deletion functions/find.bash
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ go_setup() {
## setup_monitor_mode()
##
setup_monitor_mode() {
if ! is_pizerow && ! is_pithree && ! is_pithreeplus && ! is_pifour; then
if ! is_pi_wlan; then
echo "$(timestamp) [openHABian] Incompatible hardware detected! Canceling Monitor Mode setup!"
return 0
fi
Expand Down
15 changes: 14 additions & 1 deletion functions/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ is_pizerow() {
grep -q "^Revision\\s*:\\s*[ 123][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]0[cC][0-9a-fA-F]$" /proc/cpuinfo
return $?
}
is_pizerow2() {
if [[ "$hw" == "pi0w2" ]]; then return 0; fi
grep -q "^Revision\\s*:\\s*[ 123][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]12[0-9a-fA-F]$" /proc/cpuinfo
return $?
}
is_pione() {
if [[ "$hw" == "pi1" ]]; then return 0; fi
if grep -q "^Revision\\s*:\\s*00[0-9a-fA-F][0-9a-fA-F]$" /proc/cpuinfo; then
Expand Down Expand Up @@ -206,7 +211,15 @@ is_pi400() {
return $?
}
is_pi() {
if is_pifour || is_cmfour || is_pi400 || is_cmthreeplus || is_cmthree || is_pithree || is_pitwo || is_pione || is_cmone || is_pizerow || is_pizero; then return 0; fi
if is_pifour || is_cmfour || is_pi400 || is_cmthreeplus || is_cmthree || is_pithreeplus || is_pithree || is_pitwo || is_pione || is_cmone || is_pizerow || is_pizerow2 || is_pizero; then return 0; fi
return 1
}
is_pi_wlan() {
if is_pifour || is_pi400 || is_pithreeplus || is_pithree || is_pizerow || is_pizerow2; then return 0; fi
return 1
}
is_pi_bt() {
if is_pifour || is_pi400 || is_pithreeplus || is_pithree || is_pizerow || is_pizerow2; then return 0; fi
return 1
}
is_cm() {
Expand Down
2 changes: 1 addition & 1 deletion functions/packages.bash
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ knxd_setup() {
## miflora_setup()
##
miflora_setup() {
if ! is_pizerow && ! is_pithree && ! is_pithreeplus && ! is_pifour; then
if ! is_pi_bt; then
echo "$(timestamp) [openHABian] Beginning setup of miflora-mqtt-daemon... SKIPPED (no Bluetooth support)"
return 0
fi
Expand Down
2 changes: 1 addition & 1 deletion functions/system.bash
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ needed_packages() {
avahi-autoipd fontconfig; \
then echo "OK"; else echo "FAILED"; return 1; fi

if is_pizerow || is_pithree || is_pithreeplus || is_pifour && [[ -z $PREOFFLINE ]]; then
if is_pi_wlan && [[ -z $PREOFFLINE ]]; then
echo -n "$(timestamp) [openHABian] Installing python3 serial package... "
if cond_redirect apt-get install --yes python3-smbus python3-serial; then echo "OK"; else echo "FAILED"; return 1; fi
echo -n "$(timestamp) [openHABian] Installing pigpio package... "
Expand Down
4 changes: 2 additions & 2 deletions functions/wifi.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ configure_wifi() {

echo -n "$(timestamp) [openHABian] Beginning WiFi configuration... "

if ! is_pizerow && ! is_pithree && ! is_pithreeplus && ! is_pifour; then
if ! is_pi_wlan; then
if (whiptail --title "No WiFi hardware detected" --yesno "$questionText" 10 80); then echo "OK"; else echo "CANCELED"; return 0; fi
else
echo "OK"
Expand All @@ -42,7 +42,7 @@ configure_wifi() {
fi
fi

if is_pifour || is_pithree || is_pithreeplus || is_pizerow; then
if is_pi_wlan; then
if ! dpkg -s 'firmware-brcm80211' &> /dev/null; then
echo -n "$(timestamp) [openHABian] Installing WiFi firmware... "
if cond_redirect apt-get install --yes firmware-brcm80211; then echo "OK"; else echo "FAILED"; return 1; fi
Expand Down
2 changes: 1 addition & 1 deletion functions/zram.bash
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ zram_setup() {
return 1
fi
if is_arm; then
if ! has_lowmem && ! is_pione && ! is_cmone && ! is_pizero && ! is_pizerow; then
if ! has_lowmem && ! is_pione && ! is_cmone && ! is_pizero && ! is_pizerow && ! is_pizerow2; then
echo -n "$(timestamp) [openHABian] Installing zram... "
if cond_redirect init_zram_mounts "install"; then echo "OK"; else echo "FAILED"; return 1; fi
else
Expand Down

0 comments on commit 227470b

Please sign in to comment.