-
-
Save davidebettio/b1321ac38ad163f0bcb2887e4401f6f4 to your computer and use it in GitHub Desktop.
Initialize an external I2C RTC module on raspberry using udev and systemd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/udev/rules.d/rtc-i2c.rules | |
# | |
# | |
#I2C hardware device driver | |
ACTION=="add", KERNEL=="i2c_bcm2708", SUBSYSTEM=="module", TAG+="systemd" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/udev/rules.d/rtc-i2c.rules | |
# | |
# | |
ACTION=="add", SUBSYSTEM=="rtc", ATTRS{hctosys}=="0", RUN+="/usr/bin/hwclock -s --utc" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/i2c_rtc.service | |
[Unit] | |
Description=Initialize i2c hardware RTC device driver | |
DefaultDependencies=no | |
Requires=sys-module-i2c_bcm2708.device | |
After=sys-module-i2c_bcm2708.device | |
Conflicts=shutdown.target | |
[Service] | |
Type=oneshot | |
RemainAfterExit=yes | |
EnvironmentFile=/etc/conf.d/rtc-i2c | |
ExecStart=/bin/sh -c "echo ${CHIP} ${ADDRESS} > /sys/class/i2c-adapter/i2c-${BUS}/new_device" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment