# RTC Problem

## bobtongue

I am having a small problem. I recently upgraded to kernel version 3 and for some reason the RTC will not set system time at boot. The error is that the kernel is trying to read the hwclock as /dev/rtc0. 

hwclock: select() to /dev/rtc0 to wait for clock tick timed out: No such file or directory.  If I give the command as hwclock --rtc /dev/rtc the clock reads fine. I am not really clear on how the whole RTC thing works. I have been working with gentoo for about 5 years now and this is the first time I have had a problem reading the RTC. I am sure I have a setting in the kernel wrong since upgrading was what brought the problem on, but I have been googling my fingers off for the last week to try to find the solution and I just can't seem to get it. Any help you can give me as to what I have to do to get the RTC to read /dev/rtc instead of /dev/rtc0 would be greatly appreciated.

----------

## eyoung100

Reconfigure the section that reads:

```
[*] Device Drivers

    [*]Character Devices

        [*] One of these settings near the top has to do with Realtime Clock
```

or use the / and search for CONFIG_RTC

----------

## PaulBredbury

What does this show:

```
grep rtc /etc/udev/rules.d/* /lib/udev/rules.d/*
```

I expect you've got a bad udev rule somewhere. The kernel will by default name the first rtc as rtc0.

Also check:

```
$ zgrep HCTOSYS /proc/config.gz 

CONFIG_RTC_HCTOSYS=y

CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
```

----------

## bobtongue

 *PaulBredbury wrote:*   

> What does this show:
> 
> ```
> grep rtc /etc/udev/rules.d/* /lib/udev/rules.d/*
> ```
> ...

 

I don't have /proc/config.gz

but zgrep HCTOSYS /usr/src/linux/.config shows:

CONFIG_RTC_HCTOSYS=y

CONFIG_RTC_HCTOSYS_DEVICE="rtc0"

grep rtc /etc/udev/rules.d/* /lib/udev/rules.d/* shows:

/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="rtc", ATTR{hctosys}=="1", MODE="0644", SYMLINK+="rtc"

if I issue the hwclock command I get:

hwclock: select() to /dev/rtc to wait for clock tick timed out: No such file or directory

now when I issue hwclock --rtc /dev/rtc I get the same output as above.

If I issue hwclock --rtc /dev/rtc1 I now get:

hwclock --rtc /dev/rtc1

Wed Mar 13 08:41:12 2013  -0.000000 seconds

It seems that udev is randomly assigning the name. It almost looks like what happened to my nics when I upgraded udev. Could this be the issue?

----------

## PaulBredbury

Ah, you have more than one real-time clock? Why didn't you say? Show:

```
ls -l /dev/rtc*
```

If you have more than one, then handle it in the same way as for network devices that the Internet is full of confusion for - remove the ambiguity.

Edit: I think you want /dev/rtc symlinking to rtc0 or rtc1 as appropriate. Udev's default rule looks wrong for such a situation, but can be overridden. Use e.g.:

/etc/udev/rules.d/10-local.rules

```
SUBSYSTEM=="rtc", <identify properly>, SYMLINK+="rtc", OPTIONS+="last_rule"
```

You need to fill in <identify properly> by looking:

```
udevadm info -a --name /dev/rtc0

udevadm info -a --name /dev/rtc1
```

Then change your kernel to have:

```
CONFIG_RTC_HCTOSYS_DEVICE="rtc"
```

----------

## bobtongue

 *PaulBredbury wrote:*   

> Ah, you have more than one real-time clock? Why didn't you say? Show:
> 
> ```
> ls -l /dev/rtc*
> ```
> ...

 

Actually I don't think I have more than one. ls -l /dev/rtc only shows 

lrwxrwxrwx 1 root root      4 Mar 13 10:02 /dev/rtc -> rtc0

crw------- 1 root root 254, 0 Mar 13 10:02 /dev/rtc0

udevadm info -a --name /dev/rtc0 gives this output

looking at device '/devices/pnp0/00:04/rtc/rtc0':

    KERNEL=="rtc0"

    SUBSYSTEM=="rtc"

    DRIVER==""

    ATTR{date}=="2013-03-13"

    ATTR{name}=="rtc_cmos"

    ATTR{time}=="15:13:05"

    ATTR{since_epoch}=="1363187585"

    ATTR{hctosys}=="0"

    ATTR{max_user_freq}=="64"

    ATTR{wakealarm}==""

  looking at parent device '/devices/pnp0/00:04':

    KERNELS=="00:04"

    SUBSYSTEMS=="pnp"

    DRIVERS=="rtc_cmos"

    ATTRS{id}=="PNP0b00"

    ATTRS{nvram}==""

    ATTRS{options}==""

  looking at parent device '/devices/pnp0':

    KERNELS=="pnp0"

    SUBSYSTEMS==""

    DRIVERS==""

I set up a rule as you suggested, 10-local.rules with this line:

SUBSYSTEM=="rtc", ATTR{name}=="rtc_cmos", SYMLINK+="rtc", OPTIONS+="last_rule"

I changed the kernel CONFIG_RTC_HCTOSYS_DEVICE="rtc" and recompiled. 

when I rebooted, I still got the error on startup

hwclock: select() to /dev/rtc to wait for clock tick timed out: No such file or directory

when I checked ls -l /dev/rtc* /dev/rtc was symlinked to rtc0 as expected. the strange thing is, I can use the command hwclock --rtc /dev/rtc1 and get the clock to return the time. that rtc1 can be rtc2 rtc3 rtc4 rtc5 anything BUT rtc0 or rtc and the command will work. there is no /dev/rtc1, 2, 3, 4, or 5 in the /dev directory. What am I missing? What gives? This is certainly puzzling.

EDIT: so i was thinking maybe /dev/rtc0 was the culprit. I renamed /dev/rtc0 to /dev/rtc8 just to get it out of the way. I deleted the rtc symlink and ran the hwclock command. It worked fine. 

www dev # hwclock

Wed Mar 13 11:30:20 2013  -0.000909 seconds

So does that mean that I may be trying to use a bad driver or maybe something is loading that really isn't there?

Of course, it would be great if that fixed it, but naturally, the /dev/rtc0 file is recreated at startup

----------

