0

the rasclock is detected by the raspberry Pi but if I want to read or set the time on it I got the error

hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Remote I/O error

dmesg output is:

[  165.915983] rtc-pcf2127-i2c 1-0051: pcf2127_rtc_set_time: err=-121
[  165.916127] rtc-pcf2127-i2c 1-0051: pcf2127_rtc_read_time: read error

Raspbian Version is:

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"

and i2c puts out this:

         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- 09 -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- 35 -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

My config.txt contains following: (Everything above is commented)

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
#dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
#dtoverlay=vc4-fkms-v3d
#max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d

dtoverlay=i2c-rtc,pcf2127
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
dtoverlay=i2c-bcm2835-overlay
dtoverlay=spi1-3cs

#start-up blinking
dtparam=act_led_gpio=7,act_led_trigger=timer

The File /lib/udev/hwclock-set is configured like this:

#!/bin/sh
# Reset the System Clock to UTC if the hardware clock from which it
# was copied by the kernel was in localtime.

dev=$1

#if [ -e /run/systemd/system ] ; then
#    exit 0
#fi

if [ -e /run/udev/hwclock-set ]; then
    exit 0
fi

if [ -f /etc/default/rcS ] ; then
    . /etc/default/rcS
fi

# These defaults are user-overridable in /etc/default/hwclock
BADYEAR=no
HWCLOCKACCESS=yes
HWCLOCKPARS=
HCTOSYS_DEVICE=rtc0
if [ -f /etc/default/hwclock ] ; then
    . /etc/default/hwclock
fi

if [ yes = "$BADYEAR" ] ; then
    #/sbin/hwclock --rtc=$dev --systz --badyear
    /sbin/hwclock --rtc=$dev --hctosys --badyear
else
    #/sbin/hwclock --rtc=$dev --systz
    /sbin/hwclock --rtc=$dev --hctosys
fi

# Note 'touch' may not be available in initramfs
> /run/udev/hwclock-set

The Clock is at least registered:

lcg@lcg-0123917fbb6e29ba01:~ $ dmesg  | grep rtc
[    5.854858] rtc-pcf2127-i2c 1-0051: pcf2127_rtc_read_time: read error
[    5.855118] rtc-pcf2127-i2c 1-0051: rtc core: registered rtc-pcf2127-i2c as rtc0
2
  • 1
    Do you mean this device? afterthoughtsoftware.com/products/rasclock It may help if you show the config.txt and the file /lib/udev/hwclock-set Did you run the commands as sudo? I also note that page does not mention Buster - what install instructions did you follow?
    – user115418
    Commented May 25, 2020 at 16:33
  • Yes I mean this device! Buster is the latest Version and I think it's also the only available Version on raspberrypi.org/downloads/raspbian ? I've added the config.txt and the /lib/udev/hwclock-set file
    – Bierly
    Commented May 26, 2020 at 6:46

1 Answer 1

1

I have a PCF2127 working on Buster.

I placed the following line in /boot/config.txt:

dtoverlay=i2c-rtc,pcf212

right after the Enable Audio lines and above the [pi4].

I did not make any changes to the /lib/udev/hwclock-set file.

Pre Buster you had to make the changes that you have in your /lib/udev/hwclock-set file above plus comment out the 2 lines that have --systz in them. It appears that with Buster some changes were made that allows the PCF2127 to work without making changes to the hwclock-set file.

As stated in the Setup Guide, the first time you use the clock you will need to set the time. To copy the system time into the clock module:

sudo hwclock -w

After that you should be able to read (and copy) the time from the RTC using the parameters -r and -s.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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