Skip to content

Commit

Permalink
[utils/common] Check for I2C/I2S when Raspberry Pi is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
goldyfruit committed Dec 14, 2023
1 parent 36aa844 commit c2a09a0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions utils/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,27 @@ function detect_display() {
echo -e "[$done_format]"
}

# Parse /sys/firmware/devicetree/base/model file if exist and check
# for "raspberrypi" string. This will be used by the installer to
# apply the Ansible tuning tasks.
# Parse /sys/firmware/devicetree/base/model file if it exists and check
# for "raspberrypi" string. I2C and I2S will be checked as well as they
# could be required when using a HAT. This will be used by the installer
# to apply the Ansible tuning tasks.
function is_raspeberrypi_soc() {
echo -ne "➤ Checking for Raspberry Pi board... "
RASPBERRYPI_MODEL="N/A"
if [ -f "$DT_FILE" ]; then
if grep -q -i raspberry "$DT_FILE"; then
RASPBERRYPI_MODEL="$(tr -d '\0' <"$DT_FILE")"
echo -ne "➤ Checking for I2C support... "
if [ ! -f /dev/i2c-1 ]; then
echo -e "[$fail_format]"
echo "I2C and I2S must be enabled... " | tee -a "$LOG_FILE"
echo -e "\necho 'dtparam=i2c_arm=on' | sudo tee -a /boot/config.txt"
echo -e "\necho 'dtparam=i2s=on' | sudo tee -a /boot/config.txt"
echo -e "\necho 'i2c-dev' | sudo tee /etc/modules-load.d/i2c.conf"
echo -e "\nsudo reboot"
exit 1
fi
echo -e "[$done_format]"
fi
fi
export RASPBERRYPI_MODEL
Expand Down

0 comments on commit c2a09a0

Please sign in to comment.