How to Test RTC Drivers
Table of Contents
- Table of contents
- HOWTO Test RTC Drivers
Using hwclock
Most people use the RTC to keep track of the system time in hardware. Therefore, it is probably adequate to use the userspace utility hwclock provided by either util-linux (for bash-based RFSs) or busybox. Note that the util-linux version will test more of the driver than the busybox version, so we recommend using that. It is possible for the busybox version to succeed and the util-linux to fail, but probably not vice-versa.
The simplest way to test it is to set the rtc, cut all power to the board, and make sure that the time persists. To use hwclock, you must have a symlink called /dev/rtc that points to /dev/rtc0. This is typically done by udev, but many of our distributions fail to implement it. Therefore, you can create the link manually using the ln command:
bash# ln -s /dev/rtc0 /dev/rtc
Once the link exists, you must set the system clock using the date command and sync the hardware clock with the system clock using hwclock:
bash# date 032009552008 Thu Mar 20 09:55:00 UTC 2008 bash# hwclock --systohc bash# hwclock Thu Mar 20 09:55:54 2008 -0.262207 seconds
Shut down the board (it's best to completely cut power and wait a few moments) and reboot the kernel. You can see in the boot logs whether or not the board actually gets the correct time, or you can use hwclock or date again.
Using rtctest
The kernel includes an rtc test program in the file Documentation/rtc.txt . This tests the various ioctls and interrupts of the RTC. Be sure to read the document in order to fully understand the results of the test. For instance, some ioctls are optional, and will cause failures to happen even if the RTC driver is sound.
- rtctest.c - Real Time Clock test program