Correct way to set persistent date and time when flashing directly from an image

We have a system.img and custom device tree. We have replaced the files in the appropriate locations under Linux_for_Tegra. When we set up a new board, we run the following, skipping the sdkmanager completely:

sudo ./flash.sh -r jetson-xavier mmcblk0p1

One issue I have noticed is that the date and time don’t get set up. What is the correct way to set these up from the command line such that they persist across power cycles?

I have tried the following sequence, but one of my colleagues tells me that it didn’t ‘stick’ and fell back to the default January 2018 date.

sudo date +%Y%m%D -s "20200603"
sudo date +%T -s "11:52:00"
sudo hwclock --systohc -f /dev/rtc1

Am I missing an important step?

Try setting it through, timedatectl(1) utility.

sudo timedatectl set-timezone America/New_York    # get list of timezones through "list-timezones" option
sudo timedatectl set-ntp 1

Hope this works.

timedatectl seems to do the trick.
Since our device doesn’t always have access to the internet, we used:
sudo timedatectl set-time set-time "2020-06-03 18:00:00" and it worked like a charm. Thanks!

Also worth noting: the system appears to lose the time if the Tegra SOM is disconnected from the carrier card, and needs to be set again. Maybe the RTC loses power in those cases. We ran into this when we installed an NVMe module on our Xavier board.

Hmm. It would appear that if I leave the Jetson disconnected for several days, the time reverts back. Does the Xavier have battery backup for its date/time or do we have to rely on NTP to update it at startup?

For the time lost if unplug the power, You may need to add coin battery for RTC timer backup.

Thanks for the response, Shane.
Do you have any images indicating where on the Xavier AGX dev kit board I would need to put this battery?
Thanks!

agx devkit seems to have rtc battery near U501 by default
reference RTC battery replacement

what if you use use the last command as listed below instead of sudo hwclock --systohc -f /dev/rtc1 ?

root #timedatectl set-local-rtc 1

and/or

root #hwclock --systohc

then try with



hwclock --show --rtc /dev/rtc1
hwclock --show --rtc /dev/rtc0

source https://wiki.gentoo.org/wiki/System_time