Hi,
I have more of a general question. Currently I have a code which opens a file for writing and at the end of the code it closes the file for onboard microSD card. The data is obviously not saved in the event of a power loss. For my application I want something more robust such that it will have the last recorded data even in case of power loss. I guess one way of doing this would be to open the file for appending at the beginning of each write cycle and closing the file after each write cycle. However its my notion that it too much overhead, is there any simpler way of doing this? Thank you.
Regards,
Tanmay
MOD54415: How To Prevent Data Loss In case of Power loss
-
- Posts: 513
- Joined: Sat Apr 26, 2008 7:14 am
Re: MOD54415: How To Prevent Data Loss In case of Power loss
You can also f_flush the file, which writes the data, although that still takes a while. I've found that the access time required for the file open and close functions is related to the number of items in the directory: access depends on the file name (whether to create, open, whether there is a name conflict, etc), and it simply takes longer to search a bigger directory. Therefore, smaller directories are faster, and probably the default 8.3 name standard is faster than long filenames, although nowhere as understandable. Keep in mind that large block writes tend to be MUCH more efficient than small individual byte writes.
Another way that this kind of logged, but not-yet-written data can be lost is during an update. There's an autoupdate hook that makes it easy to write and close any open files before an update.
Finally, if the data really matters, and depending on the cycle count, you can write it to user flash.
If you really care, it's probably advisable to add power multiplexer hardware (eg TI TPS211x) that switches the NB to battery backup and provides a "save-state" status signal in the event of a power loss.
Another way that this kind of logged, but not-yet-written data can be lost is during an update. There's an autoupdate hook that makes it easy to write and close any open files before an update.
Finally, if the data really matters, and depending on the cycle count, you can write it to user flash.
If you really care, it's probably advisable to add power multiplexer hardware (eg TI TPS211x) that switches the NB to battery backup and provides a "save-state" status signal in the event of a power loss.
Re: MOD54415: How To Prevent Data Loss In case of Power loss
I've used an SD car dto log data, where I used no file system at all...
I erase the whole card then on start up I read sectors till I find a blank one then start recording there....
when I want the log or data I have the netburner dumps it back out sector by sector...
when I've downloaded the data I have a separate erase card command that puts it back to blank.
I've used this in an autonomous helicopter where I failure may lead to physical destruction I I really want the log to know what happened...
Some PC's will allow you raw access to the SD card, but most won't so you can't really move the SD card from the netburner to a PC to read....
It's pretty much stuck in the netburner for readback....
I erase the whole card then on start up I read sectors till I find a blank one then start recording there....
when I want the log or data I have the netburner dumps it back out sector by sector...
when I've downloaded the data I have a separate erase card command that puts it back to blank.
I've used this in an autonomous helicopter where I failure may lead to physical destruction I I really want the log to know what happened...
Some PC's will allow you raw access to the SD card, but most won't so you can't really move the SD card from the netburner to a PC to read....
It's pretty much stuck in the netburner for readback....
Re: MOD54415: How To Prevent Data Loss In case of Power loss
Hi,
Thanks rideglider and pbreed for the useful information. Like pbreed even I am using NB for crash testing and want to know what exactly happened during the process of crash. I guess for the time being the more practical solution seems to be to keep the directory size small and use f_flush.
Thanks again,
Regards,
TM
Thanks rideglider and pbreed for the useful information. Like pbreed even I am using NB for crash testing and want to know what exactly happened during the process of crash. I guess for the time being the more practical solution seems to be to keep the directory size small and use f_flush.
Thanks again,
Regards,
TM