From b5a83a54a2f62baa324b25ed4129b6a76e06f7b8 Mon Sep 17 00:00:00 2001 From: arfrie22 <43021241+arfrie22@users.noreply.github.com> Date: Mon, 5 Aug 2024 14:54:46 -0400 Subject: [PATCH] update build script to set clock speed --- build.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index a451f895..9ffb2d04 100755 --- a/build.sh +++ b/build.sh @@ -4,9 +4,12 @@ set -e function enable_i2c { if command -v raspi-config &> /dev/null; then echo "Enabling i2c" - sudo dtparam i2c_baudrate=400000 sudo modprobe i2c-dev sudo raspi-config nonint do_i2c 0 + if ! grep -q 'dtparam=i2c_arm=on$ /boot/config.txt'; then + echo "Setting the i2c clock speed to 400 kHz, you will have to reboot for this to take effect." + sudo sed -i -e 's/dtparam=i2c_arm=on$/dtparam=i2c_arm=on,i2c_arm_baudrate=400000/g' /boot/config.txt + fi else echo "Can not automatically enable i2c you might have to do this manually" fi