Skip to content

Instantly share code, notes, and snippets.

@u1735067
u1735067 / 1. i2c-rtc.sh
Last active March 11, 2021 15:28
Properly set-up i2c RTC ds1307 on ArchLinux
echo "dtoverlay=i2c-rtc,ds3231" >> /boot/config.txt
cat <<EOF > /etc/udev/rules.d/55-rtc-i2c.rules
#/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="rtc", ATTR{hctosys}=="1", SYMLINK+="rtc"
#/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="rtc", KERNEL=="rtc0", SYMLINK+="rtc", OPTIONS+="link_priority=-100"
# I2C RTC, when added and not the source of the sys clock (kernel), is used
ACTION=="add", SUBSYSTEMS=="i2c", SUBSYSTEM=="rtc", KERNEL=="rtc0", ATTR{hctosys}=="0", \\
RUN+="/sbin/hwclock '--rtc=\$root/\$name' --hctosys", \\
RUN+="/sbin/logger --tag systemd-udevd 'System clock set from i2c hardware clock \$name (\$attr{name})'"