This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How long to keep FDS file open and fds_record_desc_t

In our code we use NV storage for system settings and calibration data.

I'm trying to understand when to open/close files and which structs to keep bwtween reads/writes. I've looked at the GIT example code, but it only briefly reads or write files.

For our system settings, which change regularly, should we open the file on start-up and keep it open? Or just open, read/write, and then immediately close the file? If we should keep it open, which structs (fds_record_desc_t, p_flash_record, etc.) need to be kept between accesses?

Second, the calibration data file is rarely written but read often. The total required calibration data is a known size, and will be kept in multiple records. Why would we want to use fds_reserve()? Again, should the file be kept open or opened and closed only as required?

Parents
  • FormerMember
    0 FormerMember

    In FDS, when reading data, the data is never copied from flash, but it is read directly from flash. The purpose of fds_record_open() is to make sure that you will be able to read the data, without the reading operation being disturbed by the garbage collection operation. The garbage collection operation will erase pages and move records around. Therefore, read operation and garbage collection cannot happen at the same time. And purpose of fds_record_open() and fds_record_close() is to tell FDS is garbage collection can be performed/is an allowed operation or not.

    I would therefore recommend you to only have a record "open" when needed.

    I cannot see any specific reason to use fds_reserve().

Reply
  • FormerMember
    0 FormerMember

    In FDS, when reading data, the data is never copied from flash, but it is read directly from flash. The purpose of fds_record_open() is to make sure that you will be able to read the data, without the reading operation being disturbed by the garbage collection operation. The garbage collection operation will erase pages and move records around. Therefore, read operation and garbage collection cannot happen at the same time. And purpose of fds_record_open() and fds_record_close() is to tell FDS is garbage collection can be performed/is an allowed operation or not.

    I would therefore recommend you to only have a record "open" when needed.

    I cannot see any specific reason to use fds_reserve().

Children
Related