On my Beaglebone Black I added a I2C real-time-clock to not being reliant on ntpd to maintain accurate timing. The outcome is that there are two special device files in /dev. These are /dev/rtc0 and /dev/rtc1 but there is also /dev/rtc which is a symlink to /dev/rtc0.

enter image description here

/dev/rtc0 is the real-time-clock within the ARM SOC on the board, /dev/rtc1 is the I2C device. At the moment I'm using scripts that read and write the time manually to the I2C clock but I'd rather like the symlink /dev/rtc to point to /dev/rtc1.

Hence the question, how can this be done? The Linux distro on my beaglebone black is Arch Linux which uses systemd for all the house keeping.

When I delete the symlink and create a new one pointing to /dev/rtc1 not surprisingly it is reset after the next reboot and I didn't find any config files or systemd-units so far.

Help is much appreciated.


That udev rule hint pointed me in the right direction. After a quick review of writing udev rules I did the following.

udevadm info -a -p /sys/class/rtc/rtc1

The output (shortened) revealed some useful properties to define a udev rule.

looking at device '/devices/platform/ocp/4802a000.i2c/i2c-1/1-0068/rtc/rtc1':

So the rules file needs to reside in /etc/udev/rules.d/ with a naming scheme like 99-rtc1.rules.

The files content is

KERNEL=="rtc1", SUBSYSTEM=="rtc", DRIVER=="", ATTR{name}=="ds1307", SYMLINK="rtc", MODE="0666"

To test the rule you can run

udevadm test /sys/class/rtc/rtc1

and the important lines in the output are

creating link '/dev/rtc' to '/dev/rtc1'
atomically replace '/dev/rtc'

The result in /dev is the desired configuration.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.