FS#18078 - [initscripts] does not create /dev/rtc node correctly, so hwclock fails

Attached to Project: Arch Linux
Opened by Glenn McCarthy (Rotech) - Saturday, 30 January 2010, 21:06 GMT
Last edited by Thomas Bächler (brain0) - Wednesday, 09 June 2010, 17:42 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Aaron Griffin (phrakture)
Thomas Bächler (brain0)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
rc.sysinit does not create the /dev/rtc device node correctly on my system. My /dev/rtc0 looks like this when created by UDEV

crw-rw-r-- 1 root audio 10, 135 Jan 31 09:45 /dev/rtc

rc.sysinit finds the major number like this

RTC_MAJOR=$(/bin/grep -w rtc /proc/devices 2>/dev/null)
RTC_MAJOR="${RTC_MAJOR%% *}"

Then creates the device as such
/bin/mknod /dev/rtc0 c $RTC_MAJOR 0

For my system it needs to be like this. I don't know what causes mine to be different from what is obviously "the norm"

RTC_MAJOR=$(/bin/grep -w misc /proc/devices 2>/dev/null)
RTC_MAJOR="${RTC_MAJOR% *}"

RTC_MINOR=$(/bin/grep -w rtc /proc/misc 2>/dev/null)
RTC_MINOR="${RTC_MINOR% *}"

/bin/mknod /dev/rtc0 c $RTC_MAJOR $RTC_MINOR
/bin/ln -s /dev/rtc0 /dev/rtc

Additional info:
* package version(s)
initscripts 2010.01-1
This task depends upon

Closed by  Thomas Bächler (brain0)
Wednesday, 09 June 2010, 17:42 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed in upcoming 2010.06-2
Comment by Thomas Bächler (brain0) - Saturday, 30 January 2010, 21:51 GMT
Can you give us a few details about your kernel? For me, rtc also has its own major number and is not a misc device.
Comment by Glenn McCarthy (Rotech) - Saturday, 30 January 2010, 22:10 GMT
Custom compiled kernel. I don't remember when this problem arose, but I have been through a few kernels since I noticed it. I had fixed it, and forgotten about it, but a new version of initscripts brought it back to my attention. Attached is my current kernel config.
   kconfig26 (56.4 KiB)
Comment by Gerardo Exequiel Pozzi (djgera) - Saturday, 30 January 2010, 22:25 GMT
You don't have selected any "plataform RTC driver", like rtc-cmos that is the most common case.
Comment by Glenn McCarthy (Rotech) - Saturday, 30 January 2010, 23:06 GMT
I'll have a deeper look, I didn't see anything like that, I have this selected:

Device Drivers->Character Devices

CONFIG_RTC:
If you say Y here and create a character special file /dev/rtc with
major number 10 and minor number 135 using mknod ("man mknod"), you
will get access to the real time clock (or hardware clock) built
into your computer.

Which is working perfectly for me if I change the mknod line in rc.sysinit
Comment by Gerardo Exequiel Pozzi (djgera) - Saturday, 30 January 2010, 23:49 GMT
OK, anyway go to: "Device drivers" -> "Real time clock" -> "*** Platform RTC drivers ***" -> "PC-style 'CMOS'" ;)
Comment by Glenn McCarthy (Rotech) - Sunday, 31 January 2010, 00:27 GMT
OK, that gets my /dev/rtc working as 254,0 instead of 10,135
I still don't really understand the differences between these two different RTC's and they both worked for hwclock, but doesn't matter, problem solved. Thanks for your help, I guess this can be closed now.
Comment by Thomas Bächler (brain0) - Saturday, 06 February 2010, 16:39 GMT
In both cases, can you look at /sys/class/rtc/, show us which folders are there and look at /sys/class/rtc/*/dev?
Comment by Glenn McCarthy (Rotech) - Sunday, 07 February 2010, 18:10 GMT
No unfortunately, in my case it shows as /sys/class/misc/rtc/dev
Comment by Thomas Bächler (brain0) - Tuesday, 23 February 2010, 08:53 GMT
Sorry for keeping you waiting so long. Is /sys/class/rtc missing entirely? What device nodes does udev create? Does it create /dev/rtc0 and /dev/rtc or only /dev/rtc?
Comment by Glenn McCarthy (Rotech) - Tuesday, 23 February 2010, 09:29 GMT
No Problem. Yes /sys/class/rtc is missing. Udev creates only /dev/rtc
Comment by Thomas Bächler (brain0) - Tuesday, 23 February 2010, 11:04 GMT
Okay, I think we can detect the style of the RTC device in rc.sysinit and create the device according to that. I hope to get to this soon, but if someone wants to provide a patch, it might speed up the process.
Comment by Glenn McCarthy (Rotech) - Tuesday, 23 February 2010, 18:16 GMT
Try this maybe. I'm not too experienced with bash scripting, and I don't quite get why I have to use % instead of %% to get it to work, because if I use the longest match removal, I end up with nothing at all.
Comment by Thomas Bächler (brain0) - Tuesday, 23 February 2010, 18:27 GMT
Yeah, something like that. Only a few changes I'll make:
1) Get the major/minor from sysfs
2) Check whether the "other rtc" can be built as a module and try to load that if you can.
Comment by Glenn McCarthy (Rotech) - Wednesday, 24 February 2010, 00:34 GMT
There are 2 possible modules to be loaded
/sbin/modprobe rtc >/dev/null 2>&1
/sbin/modprobe genrtc >/dev/null 2>&1
Comment by Glenn McCarthy (Rotech) - Wednesday, 24 February 2010, 04:58 GMT
OK, how about this one then?
Comment by Thomas Bächler (brain0) - Wednesday, 24 February 2010, 08:48 GMT
Better. I'll have a look at this tonight, but this patch is almost what I had in mind.

Loading...