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.

CC3100: sl_FsOpen with FS_MODE_OPEN_CREATE is allocating an extra block

Part Number: CC3100
Other Parts Discussed in Thread: UNIFLASH, CC3200,

If I create a new file on the CC3100 serial flash using the following:
retVal = sl_FsOpen((_u8 *)"NewFile",FS_MODE_OPEN_CREATE(4096,_FS_FILE_PUBLIC_WRITE),&Token, &fileHandle);

Then check the allocation using:
SlFsFileInfo_t myFileInfo;
retVal = sl_FsGetInfo((_u8 *)"NewFile", Token, &myFileInfo);

I get myFileInfo.AllocatedLen as 7752.
I believe that this is correctly 440 bytes below the actual value to account for the header, but I was expecting 3656.

If I change the allocation size to 4096-400 I still get 7752 back as the allocated size.

I am actually always getting one extra block allocated, such that a request for 8192 bytes (2 blocks) results in 11848 bytes (3 blocks minus the 400 byte header).

I have ensured, via CCS UNIFLASH that fail safe is not enabled for the file.

I am using CCS v8.3.1, CC3100SDK_1.3.0 and CC3100_CC3200_ServicePack_1.0.1.15-2.14.0.0.

Thanks,

Kevin.

  • Hi Kevin,

    Size of header is 440B.

    • when you want to create file with data size 4096 it does not fit into one 4kB flash block (4096B data + 440B header). And from this reason two blocks need to be allocated (sl_FsGetInfo returns 2*4096-440)
    • for 8192B data file it is similar (8192 + 440 > 2*4096)

    Jan

  • Thanks Jan,

    However, my file is actually much smaller than a single block.

    I was attempting to make a file that would use 'up to' 1 block, as suggested in SWRA657.

    As stated above I did attempt the following but still got a 7752 byte allocated file:
    retVal = sl_FsOpen((_u8 *)"NewFile",FS_MODE_OPEN_CREATE(3656,_FS_FILE_PUBLIC_WRITE),&Token, &fileHandle);

    Kevin

  • Hi Kvin,

    Try to create file with size let say 3000B.

    Jan

  • Jan,

    It appears that if I create a file with a size of over 3584 (4096-512) then it will also allocate the next block too.

    Does this mean that we need to allow for header etc. of 512 bytes total, not 440 as shown in section 4 of SWRA657?

    Thanks,

    Kevin

  • Hi Kevin,

    In the CC3100/CC3200 User's Guide (SWRU368) section 13.1.1 and the host driver API guide in the SDK, the total file metadata size is 512 bytes. I'll have to check why there is a discrepancy with the serial flash guide.

    Best regards,

    Sarah