I have a really strange behavior of the Yun after cold boot. I would like to write a log entry to a logfile on the sd card in the method "setup" of my sketch. The strange thing is that no log entry is written to the sd card when I power on the Yun (cold boot). If the Yun is already running and I reset the ATmega32u4 by pressing the reset button, the setup method is logged correctly. On cold boot, I am absolutely sure that the setup method is also called because otherwise my application wouldn't work.
Can someone explain this behavior?
it tooks some time for the SD card to be auto-mounted, maybe the sketch starts too early?
Would you like to test by adding a delay(20000) between Bridge.begin() and writeToLog("Setup")?
The Leonardo side starts up much faster than the Linino side, I think mine takes a little over 60 seconds to complete all the startup work. The last thing I see when rebooting (the button by the leds) with the YunSerialTerminal sketch running is wlan0: associated which means Linino has a DHCP lease from my router.
While for a different purpose some people are doing this which waits for the chatter to pause for 1 second to know Uboot has completed: http://forum.arduino.cc//index.php?topic=191820.msg1436262#msg1436262
There are other processes at work that pause for more than 1 second, you may need to modify this to detect when Linino is ready to write your info to the SD card.
Thanks for your replies!
You are right, the file system was not yet ready!
I am simply waiting as long as my logging directory gets available. After that the log entry is written.
But, I had another problem. In my log file I saw the log entry with a timestamp of "08/08/13 22:42:19". It seems that the clock of the Yun falls back to it's factory settings on every reboot.
Therfore I am checking the time in a loop till the date is synchronized with a time server.
I have modified my sketch like the following:
Yun does not have real time clock on board so its clock gets reset at every reboot. I don't have a yun at hand right now, but you can try forcing a quick clock sync right before your sketch starts: check this out NTP client / NTP server [Old OpenWrt Wiki]
Good catch: the yun already synchronizes its clock as soon as it can reach an NTP server. You can try to speed it up by calling the ntp client after your while(!FileSystem.exists...)