Search code examples
cmemory-managementubuntu-14.04fwrite

C flash file system using fwrite life limit?


I am currently writing a C program on an Industrial PC. The operating system is Ubuntu. The PC is using flash file system. I did some researches on flash file system. It turns out that flash file system has limited times of rewriting data on the same spot. However, my program may need to fwrite files over and over to keep the config data. My program needs to keep running on this PC over years, and it needs to record data every minutes. I am wondering if I fwrite a file many times, is the system gonna rewrite data on the same memory spot? Is that going to cause the flash file system to be broken?


Solution

  • First thing to see is whether you are using a NOR flash file system or NAND flash file system. Because both of them differs in the number of erase cycles that can be done reliably . Please see the link for differences between the two https://focus.ti.com/pdfs/omap/diskonchipvsnor.pdf

    The problem also depends upon the amount of data you want to write. If its small you can write a custom filewrite function using putc instead of using the fwrite.

    You can see one method here https://bytes.com/topic/c/answers/876395-fwrite-efficiency-alternative

    Hope it helps.