2022-10-22 11:41:10 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
echo "Setting up the real time clock module, part 1"
|
|
|
|
|
2022-11-06 19:44:28 +00:00
|
|
|
# Enable i2c
|
|
|
|
sudo raspi-config nonint do_i2c 0
|
|
|
|
|
|
|
|
# Enable i2c rtc on the default i2c pins
|
2022-10-22 11:41:10 +00:00
|
|
|
sudo cat << EOF | sudo tee -a /boot/config.txt
|
|
|
|
dtoverlay=i2c-rtc,ds3231
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Disable fake-hwclock
|
2022-10-23 14:04:10 +00:00
|
|
|
sudo apt-get remove -y fake-hwclock
|
2022-10-22 11:41:10 +00:00
|
|
|
sudo update-rc.d -f fake-hwclock remove
|
|
|
|
sudo systemctl disable fake-hwclock
|
|
|
|
|
2022-11-06 19:44:28 +00:00
|
|
|
# Load needed modules at boot
|
2022-10-22 11:41:10 +00:00
|
|
|
sudo cat << EOF | sudo tee -a /etc/modules
|
|
|
|
i2c-bcm2708
|
|
|
|
i2c-dev
|
|
|
|
rtc-ds1307
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Remove some lines from /lib/udev/hwclock-set
|
|
|
|
sudo sed -i '/^if \[ \-e \/run\/systemd\/system \] ; then$/,/^fi$/d' /lib/udev/hwclock-set
|
|
|
|
|
2022-11-06 19:44:28 +00:00
|
|
|
echo "Setup RTC part 1 done, reboot and run setup-rtc-2.sh"
|