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.

SIMPLELINK-SDK-WIFI-PLUGIN: CC3120MOD File System Read Issues

Part Number: SIMPLELINK-SDK-WIFI-PLUGIN
Other Parts Discussed in Thread: CC3120MOD, CC3120, UNIFLASH

Hello,

I am working on a project using an MSP432 and CC3120MOD.

I was looking at using the nonvolatile memory on the CC3120 to create a testing program that will count every time the MSP432 wakes up from LPM before going back to sleep.

I am able to create and write onto files just fine. When I download a created file via uniflash, I can see the text put into the CC3120 file by using notepad.

However, when I read a file from the CC3120, the text seems to be distorted from what is actually on the file. For example, if I write "Testing CC3120" to a file using either notepad + Uniflash or the MSP432, the MSP432 input buffer will read "eesiigg C31120�". I made sure to check the file again by re-downloading from the CC3120 via uniflash, and the text looks to still be perfectly in-tact in the file it is reading from.

In the case of my counter, when I read "00001" off of the CC3120 file from the MSP432, the input buffer is showing up as "00011", which completely breaks my program. I did double check that the counter system works by downloading this file again, and the text contained was "00001".

I think it is an issue in the way I am using sl_FsRead() or sl_FsOpen(), but I am not sure. I will include the code for reading/writing I am using below.

Thanks,

Greg

    char*           DeviceFileName = "lpm_count_hex";
    unsigned long   MaxSize = 63 * 1024; // Bytes
    long            DeviceFileHandle = -1;
    char    InputBuffer[50];
    char    OutputBuffer[50];
    long count;

    DeviceFileHandle =  sl_FsOpen((unsigned char *)DeviceFileName,
                                  SL_FS_READ,
                                  NULL);
    sleep(1);
    ret = sl_FsRead( DeviceFileHandle, 0, (unsigned char *)InputBuffer, 50);
    UART_PRINT("%s", InputBuffer);

    count = strtol(InputBuffer, NULL, 10);
    count++;
    sprintf(OutputBuffer, "%05lu", count);

    sleep(1);
    ret = sl_FsClose(DeviceFileHandle, 0, 0, 0);

    sleep(1);
    DeviceFileHandle =  sl_FsOpen((unsigned char *)DeviceFileName,
                                  SL_FS_WRITE,
                                  NULL);
    sleep(1);
    ret = sl_FsWrite(DeviceFileHandle, 0, OutputBuffer, 5);
    sleep(1);
    ret = sl_FsClose(DeviceFileHandle, 0, 0, 0);

  • Very strange.

    Are you using the "wifi plugin" as is? (are you using UART or SPI for the NWP interface?)

    Please verify return code of the sl_Fs function.

    I see that your sequence starts with a read. Who writes the original value? (can you share code).

    If I understand correctly - the log from line 13 shows "00011" (instead of "00001"), right?

    Since this is not a new file - can you try using "SL_FS_OVERWRITE" instead of the "SL_FS_WRITE"?

  • Hello Kobi,

    Thank you for the response.

    1.) I am using SPI for the interface between the MSP432 and CC3120.

    2.) For the sl_Fs functions, I am receiving the expected values, as far as I know, as a return. sl_FsOpen() always returns positive, sl_FsWrite() and sl_FsRead() are returning the number of characters that I tell the functions to read/write. sl_FsClose() always returns 0. This is all with the current code I posted before.

    3.) I have tried multiple methods to write the original file including: with the MSP432 via the sl_FsOpen() + sl_FsWrite(), with a notepad document, and with a hex editor (HxD64). I will attach the code here that I have been using to create the file via the MSP432. Through all of these methods, I am able to use Uniflash to access the online files and confirm that the data is not corrupted. The only problem seems to be when the MSP432 reads the file via sl_FsRead().

    4.) Yes, if the file contains "00001", line 13 will print instead "00011". Based on the test with characters I mentioned above, I think some of the characters are being coppied into random places in the InputBuffer, but I have no idea why.

    5.) I can give SL_FS_OVERWRITE a shot, but the problem doesn't seem to be the writing portion. I downloaded the file through Uniflash after the program ran, and I saw the file contained "00012". This would be the next expected count above "00011", which was the distorted version of "00001". This appears to be working as intended.

    Greg

        char*           DeviceFileName = "lpm_count.txt";
        unsigned long   MaxSize = 63 * 1024; // Bytes
        long            DeviceFileHandle = -1;
        char    InputBuffer[50];
        char    OutputBuffer[50];
        long count;
    
        //create a secure file if not exists and open it for write.
        DeviceFileHandle =  sl_FsOpen((unsigned char *)DeviceFileName,
                                      SL_FS_CREATE | SL_FS_OVERWRITE | SL_FS_CREATE_NOSIGNATURE | SL_FS_CREATE_MAX_SIZE( MaxSize ),
                                      NULL);
    
        sleep(1);
        ret = sl_FsWrite( DeviceFileHandle, Offset, (unsigned char *)"00001",
                            strlen("00001"));
                            
        sleep(1);
        ret = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);

  • are you using TI reference board (launchpad + boosterpack) or is it a custom board?

    have you gone through the hw review process (https://www.ti.com/tool/SIMPLELINK-WIFI-DESIGN-REVIEWS)?