This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3235SF: Inquiry Regarding CC3235SF File Write Operation

Part Number: CC3235SF

Tool/software:

Dear TI support team,

I hope this message finds you well. I am reaching out with a query regarding the file write operation on the CC3235SF. Specifically, I would like to know the maximum number of times a file can be rewritten.

For context, I am referring to the following code:

/** 
 * \return         File handle on success. Negative error code on failure
 * 
 * \sa             sl_FsRead, sl_FsWrite, sl_FsClose
 * \note           Belongs to \ref basic_api
 * \warning        None
 * 
 * \par Example
 * 
 * - Creating a file and writing data to it
 */
char*           DeviceFileName = "MyFile.txt";
unsigned long   MaxSize = 63 * 1024; // 62.5KB is the max file size
long            DeviceFileHandle = -1;
_i32            RetVal;        // Negative return value indicates error
unsigned long   Offset = 0;
unsigned char   InputBuffer[100];
_u32            MasterToken = 0;

// Create a secure file if it doesn't exist and open it for writing
DeviceFileHandle = sl_FsOpen((unsigned char *)DeviceFileName,
                             SL_FS_CREATE | SL_FS_OVERWRITE | SL_FS_CREATE_SECURE | SL_FS_CREATE_NOSIGNATURE | SL_FS_CREATE_MAX_SIZE(MaxSize),
                             &MasterToken);

Offset = 0;
// It is preferred that the Offset and length be aligned to 16 bytes in secure files
RetVal = sl_FsWrite(DeviceFileHandle, Offset, (unsigned char *)"HelloWorld", strlen("HelloWorld"));

RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);

// Open the same file for reading, using the Token obtained during creation
DeviceFileHandle = sl_FsOpen((unsigned char *)DeviceFileName, SL_FS_READ, &MasterToken);

Offset = 0;
RetVal = sl_FsRead(DeviceFileHandle, Offset, (unsigned char *)InputBuffer, strlen("HelloWorld"));

RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);

Could you kindly clarify the limitations on the number of rewrites for a file created in this manner?

Thank you for your assistance, and I look forward to your response.

  • Hi,

    Generally filesystem is not designed for data logging purpose. Limited number of write cycles comes from livetime of SPI flash. Filesystem does not support wear leveling. For mode details about serial flash (sFlash) see serial flash guide.

    Jan



  • Hi Jan D,

    Does the file system overwrite the same sector when the data being rewritten is of the same size? If so, I can calculate the number of times a file can be rewritten per day based on its desired lifespan.

  • Hi,

    When you rewrite file, all sectors for file content are erased and written again with new content into same sectors.You need to rewrite file not a delete file. That means you theoretically crate your own wear levelling algorithm above filesystem. This is up to you.

    But personally I did not recommand to use filesystem for often writing. Because you will need to deal with power lost situation. Because if you not properly handle this state you may to end with corrupted filesystem.

    Jan