I have wondered since ages, where does the initial date & time after a firmware flash come from. For me that date has been 09 Sep 2011 for a while. I thought that it might be something related to u-boot or Linux kernel or something in the core Openwrt system and have searched for documentation. But I couldn't figure it out :-(
Then after the Attitude Adjustment branch was created two days ago and I built the first firmware with that, I noticed that the router's initial system date was now 05 Oct 2012. But there was supposedly no difference in the source code between trunk and AA branch, or between Luci trunk and Luci 0.11. What the hell? Where is the new date coming from?
I figured out that is must be somehow related to the timestamp of some file in my build host, as the date (and time) matched the time when I had set up the new AA and Luci 0.11 sources. I reverted to brute force and recursively listed all files in my buildhost and looked for a date/time match between the initial system date and files there. Finally I found a file called "luci_fixtime" in Luci sources (/luci/trunk/modules/admin-core/root/etc/init.d/luci_fixtime). That file's timestamp matched the "inital system date" respectively in my trunk and in AA. So that must be it.
http://luci.subsignal.org/trac/browser/ … ci_fixtime
It gets copied to /etc/init.d/luci_fixtime in the final firmware.
That file is used to store the current date & time to in a warm reboot. But initially it uses its own date, coming directly from the build host. That part is not documented anywhere to my knowledge, but after finding the file and reading it, it can be figured out. Changing the date/time (e.g. with "touch") enables me to set the initial date & time for a firmware.
The file had last time been modified in SVN on 8 Sep 2011 and I had svn updated it on 9 Sep 2011, so 9 Sep 2011 was the initial date for my trunk.
That file is only in the full Luci sources, not in the contrib/package/luci set included in a normal build. But as I have the full Luci source in my local repository, I can touch the file there (/luci/branches/luci-0.11/modules/admin-core/root/etc/init.d/luci_fixtime).
I have now added a line to my build script that touches the file just before "make world" and sets the initial system date to the build hour. As I use the same script for trunk and AA, I wanted to make the script branch independent, so I use "/feeds/luci.tmp/location" as the pointer to the respective Luci source. That complicates the line a bit:
touch -t `date "+%Y%m%d%H00"` `cat feeds/luci.tmp/location`/../../modules/admin-core/root/etc/init.d/luci_fixtime
From now on, my firmware will have the build date and hour as the initial system date after a flash.