nwlee
April 10, 2018, 10:10am
1
Hi All,
I want to know how to print current time with “date” command no external network.
“date” command is working well with ntp time when it is connected with external network.
But, my development environment is no external network.
So, I’ve test to save the RTC because I’ve found “dmesg | grep rtc”.
I think that if system clock is saved to hwclock, it is no problem.
But, when it is rebooted, time is initialized. that is, no changed.
Could you let me know your idea for this way or not, is other way solution?
Thanks & BR,
Assuming your clock is set, then you’d just print date with “date”. This can be customized, e.g., I have a version I script as “timestamp” which has no spaces in it and is good for file searches:
date '+%a-%d-%b-%Y_%H-%M-%S'
If you are trying to set the date, then that’s a different question. If this is the case I found this URL which is useful:
https://askubuntu.com/questions/349763/how-can-i-change-the-date-and-time-on-ubuntu?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
snarky
April 11, 2018, 12:42am
3
It sounds like the real problem is that the RTC that’s on the jetson doesn’t save the date across reboots.
I know that some carrier boards have a supercap, or a CR lithium battery, to back up the RTC across reboots.
I don’t know what the carrier board uses.
Try
hwclock -r
to read the clock from the RTC directly. (Note: NTP may or may not update the RTC when it updates system clock.)
Easiest way to check is to unplug networking, then turn off the board, then unplug power and wait for a bit. Plug it in to power again, boot it, and see what hwclock -r now says.
nwlee
April 12, 2018, 1:07am
4
Hi snarky,
Thank you for your support kindly.
My carrier board is Jetson TX2 reference board.
The Log of the RTC is as below.
=================================================================================================
nvidia@tegra-ubuntu:~$ dmesg | grep RTC
[ 2.796083] tegra186-cam-rtcpu b000000.rtcpu: using cam RTCPU IRQ (52)
nvidia@tegra-ubuntu:~$ dmesg | grep rtc
[ 0.225978] iommu: Adding device b000000.rtcpu to group 19
[ 0.341827] vdd-rtc: at 800 mV
[ 2.648078] max77686-rtc max77620-rtc: rtc core: registered max77620-rtc as rtc0
[ 2.650247] tegra_rtc c2a0000.rtc: rtc core: registered c2a0000.rtc as rtc1
[ 2.650261] tegra_rtc c2a0000.rtc: Tegra internal Real Time Clock
[ 2.793171] tegra186-cam-rtcpu b000000.rtcpu: Trace buffer configured at IOVA=0xa0000000
[ 2.794816] tegra186-cam-rtcpu b000000.rtcpu: already unhalted
[ 2.795060] tegra-ivc ivc-b000000.rtcpu: region 0: iova=0xa0110000-0xa011957f size=38272
[ 2.795471] tegra-ivc ivc-b000000.rtcpu:echo@0: echo: ver=0 grp=1 RX[16x64]=0x1000-0x1480 TX[16x64]=0x1480-0x1900
[ 2.795575] tegra-ivc ivc-b000000.rtcpu:vinotify@12c0: vinotify: ver=0 grp=1 RX[64x128]=0x1900-0x3980 TX[64x128]=0x3980-0x5a00
[ 2.795627] tegra-ivc ivc-b000000.rtcpu:mods@32c0: mods: ver=0 grp=1 RX[1x64]=0x5a00-0x5ac0 TX[1x64]=0x5ac0-0x5b80
[ 2.795695] tegra-ivc ivc-b000000.rtcpu:ivccontrol@52c0: ivccontrol: ver=0 grp=1 RX[16x320]=0x5b80-0x7000 TX[16x320]=0x7000-0x8480
[ 2.795736] tegra-ivc ivc-b000000.rtcpu:ivccapture@72c0: ivccapture: ver=0 grp=1 RX[16x64]=0x8480-0x8900 TX[16x64]=0x8900-0x8d80
[ 2.795774] tegra-ivc ivc-b000000.rtcpu:dbg@7c00: dbg: ver=0 grp=1 RX[1x384]=0x8d80-0x8f80 TX[1x384]=0x8f80-0x9180
[ 2.795818] tegra-ivc ivc-b000000.rtcpu:dbg@7e00: dbg: ver=0 grp=1 RX[1x384]=0x9180-0x9380 TX[1x384]=0x9380-0x9580
[ 2.796083] tegra186-cam-rtcpu b000000.rtcpu: using cam RTCPU IRQ (52)
[ 2.796086] tegra186-cam-rtcpu b000000.rtcpu: tegra_camrtc_mon_create is successful
[ 2.796805] tegra-ivc ivc-b000000.rtcpu:echo@0: ivc channel driver missing
[ 2.796808] tegra-ivc ivc-b000000.rtcpu:vinotify@12c0: ivc channel driver missing
[ 2.796811] tegra-ivc ivc-b000000.rtcpu:mods@32c0: ivc channel driver missing
[ 2.796814] tegra-ivc ivc-b000000.rtcpu:ivccontrol@52c0: ivc channel driver missing
[ 2.796817] tegra-ivc ivc-b000000.rtcpu:ivccapture@72c0: ivc channel driver missing
[ 2.796820] tegra-ivc ivc-b000000.rtcpu:dbg@7c00: ivc channel driver missing
[ 2.796823] tegra-ivc ivc-b000000.rtcpu:dbg@7e00: ivc channel driver missing
[ 2.796852] tegra186-cam-rtcpu b000000.rtcpu: firmware version cpu=sce cmd=4 sha1=a8b1ecdd9615cd817a56df035be363fce3b0b88f
[ 2.803876] tegra-ivc-cdev ivc-b000000.rtcpu:echo@0: probing /dev/camchar-echo
[ 2.804659] tegra-ivc-cdev ivc-b000000.rtcpu:dbg@7c00: probing /dev/camchar-dbg
[ 2.804770] camchar: rtcpu character device driver loaded
[ 4.992997] tegra_rtc c2a0000.rtc: setting system clock to 2000-01-01 01:00:15 UTC (946688415)
=================================================================================================
I had test as you said.
As a result, It was remain hwclock info after reboot.
I think that TX2 reference board is having a supercap.
but, it is initialized after long time. So, I don’t know how long time saved.
What can I do in order to solve this problem?
That’s a point, print out current time with hwclock constantly.
Could you let me know your idea?
Thanks & BR,
The TX2 dev board does have a supercap. If you do not have correctly set time at boot and ntp cannot be used, then you’d have to set it manually.
What is it you wish to accomplish? Do you want a way to ensure date does not fail after power down? Are you looking for a way to add a backup power source to the RTC?
nwlee
April 13, 2018, 9:05am
6
Yes, I have check that existing on the carrier board.
So, I want to save time info current RTC back-up battery.
But, it is not saved. I have test as below.
connecting the external network cable
check the system current time with “date” command
save the RTC current time with “hwclock -w” command
check the RTC current time with “hwclock -r” command
unplug the network cable
power down
unplug the power cable
wait for a second
plug the power cable
power up
check the RTC current time with “hwclock -r”
As a result, current time info is not saved in the RTC back-up battery.
Is a defect for a RTC chip or back-up battery?
Thanks & BR,
snarky
April 13, 2018, 6:58pm
7
Perhaps it is damaged on his board, because power off for just a minute should not lead to clock data loss.
I haven’t really timed it, but as I recall, I have had time preserved for hours (it might be days…or maybe intended to just be minutes…but seconds will definitely imply either the clock didn’t have the time or the supercap didn’t work).
One question I wonder about though is whether there might be a way to read the RTC from U-Boot…this would rule out time setting software in Linux itself. Would someone happen to know if current clock time can be read from the U-Boot command line via some sort of memory read? If so, then it may be listed as so many seconds since epoch…which could be compared across partial boots to U-Boot command line and would rule out other software resetting time.
Sorry for late reply. I’ll help check this issue.
nwlee
April 20, 2018, 12:32am
10
Hi Wane,
RTC is damaged on our board as snarky’s reply.
RTC of the other board is working well.
Thank you for yours aggressive support.
Thanks & BR,
Got it. I am glad that you’ve found the root cause.