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.

CC3200: sl_FsWrite Return access error for file written by Uniflash

Other Parts Discussed in Thread: UNIFLASH, CC3200

Hi,

I have flashed a configuration file in sFlash using Uniflash utility. Now I need to update its content programatically so I am using sl_fsWrite() api. However it returns error (-23) SL_FS_ERR_FILE_ACCESS_IS_DIFFERENT. Can someone please let me know the possible cause.

Please note that When flashing from Uniflsh, I have tried 2 things.

a) Did not check anything in Mode options

b) Checked Public Write and Public Read options in Mode options

None of them helped. In both cases error is same (-23).

  • Hi,

    What do you refer as configuration file?

    Also, all the options under mode in Uniflash (except rollback) are for secured files. Please don't use them unless you have a secured file system.

    For your error code, there are two options:

    1. you have not opened the file using sl_FsOpen() API. In this case, it is not clear how you used the sl_FsWrite() as you need a handle
    2. you have opened it for read and trying to write

    Please use Uniflash to write a file with all mode options unchecked (as non secured file) and make sure you do not get any error (in case you do please share it in this post). Then try to open and write.

    Shlomi

  • Hi Shlomi,


    Thanks for your inputs. This is a text file that contains some configuration parameter for our application. Thanks for pointing to error.

    1. Of course file was opened.

    2. Yes, You are right, I have opened file for reading and tried to write. Actually I had to read a variable value from file increment it and then write it back. I should have closed it and opened it again for writing.

    3. I am wondering if I can open file for read  and write? It seems bad closing and opening file again and again for reading and writing in different parts of application.

    API only have following three options as below and I dont' think that I can bitwise OR (FS_MODE_OPEN_READ | FS_MODE_OPEN_WRITE) them as they expand in to something else (#define FS_MODE_OPEN_READ                                     _FS_MODE(_FS_MODE_OPEN_READ,0,0,0)).

    FS_MODE_OPEN_READ - Read a file
    FS_MODE_OPEN_WRITE - Open for write for an existing file
    FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) - Open for creating a new file. Max file size is defined in bytes.

  • Hi,

    So the root casue is understood.

    The file system requires you to open for READ and then for WRITE.

    However, please note that the implementation of the file system erases before write. It means that if you have an existing file and then you want to write something into it (even if just appending something at the end), the content of the file would get erased.

    The correct approach to overcome this is to read-modify-write from application layer.

    Shlomi

  • Hi,

    I am writing a file using UniFlash with nothing checked. Except Erase, Update and Verify. Also MaxSize is 255.

    Name field is /compdir/632f4162-6169-44f8-ab85-c549bdc73679.

    Url is a local binary file.

    When I try opening it, it crashes.

    long lFileHandle = NULL;
    unsigned long ulToken;

    iRetVal = sl_FsOpen((unsigned char *)"/compdir/632f4162-6169-44f8-ab85-c549bdc73679",
                   FS_MODE_OPEN_CREATE(255, \
                   _FS_FILE_PUBLIC_READ),
                   &ulToken,
                   &lFileHandle);

    When the above line is executed, control goes to FaultISR().

    I have also tried passing the _FS_FILE_PUBLIC_READ flag only. But same result.

    Actual size of binary file is 70 bytes.

    What may be wrong? Thanks in advance.

    Regards,

    Shashi.

     

  • Ok. So when at the boot, if I do the following call, then my FsOpen succeeds.

    //
    // Initializing the CC3200 networking layers
    //
    sl_Start(NULL, NULL, NULL);

    //
    // reset all network policies
    //
    sl_WlanPolicySet(SL_POLICY_CONNECTION,
    SL_CONNECTION_POLICY(0,0,0,0,0),
    &policyVal,
    1 /*PolicyValLen*/);

    But when the policy changes by my later programs, FsOpen no longer works.

    sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0);

    Documentation also does not say anything about it. Has anyone faced this problem?

    Please help. Thanks.

    -Shashi

  • Solved. 

    sl_Stop() was called in the middle. Thats why fsOpen API used to fail.