Skip to content

Commit

Permalink
[mark2] Better I2C requirement handling
Browse files Browse the repository at this point in the history
  • Loading branch information
goldyfruit committed Mar 26, 2024
1 parent 9dc0368 commit 290a40e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions utils/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,16 @@ function i2c_get() {
function i2c_scan() {
if [ "$RASPBERRYPI_MODEL" != "N/A" ]; then
echo -ne "➤ Scan I2C bus for hardware auto-detection..."
dtparam -v i2c_arm=on &>>"$LOG_FILE"
modprobe -v i2c-dev &>>"$LOG_FILE"

# Load I2C requirements if not ready, nothing persistent here as
# it will be handled later by the Ansible playbook.
if ! dtparam -l | grep -q i2c_arm=on; then
dtparam -v i2c_arm=on &>>"$LOG_FILE"
fi
if ! lsmod | grep -q i2c-dev; then
modprobe -v i2c-dev &>>"$LOG_FILE"
fi

for device in "${!SUPPORTED_DEVICES[@]}"; do
address="${SUPPORTED_DEVICES[$device]}"
if i2c_get "$address"; then
Expand Down

0 comments on commit 290a40e

Please sign in to comment.