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
    May 25 '20 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
    May 26 '20 at 6:46
0

I have a PCF2127 working on Buster.

I placed the line

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 work without making changes to the hwclock-set file.

You are probably smarter than I am as I don't know what your first line above

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

To read the RTC I just do a sudo hwclock -r which returns the time and date.

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.