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.

LAUNCHXL-CC3235SF: mqtt_client can't read file ota.dat from the filesystem.

Part Number: LAUNCHXL-CC3235SF
Other Parts Discussed in Thread: CC3235SF

Hi,

I am working on the OTA update and was looking into mqtt_client demo from the 6.10 SimpleLink SDK. I have imported the project, enabled:

#define INTERNAL_UPDATE_SUPPORT             (1)


... built the project and loaded SLI image onto the development board. After a bit of debugging by adding LOG_INFO() calls in different places around the code I was able to establish that code gets stuck in reading the version from the ota.dat file in here:
int OTA_IF_getCurrentVersion(uint8_t *pVersion)
{
    int16_t rc = SL_ERROR_BSD_EINVAL;

    if(pVersion)
    {
        rc = FILE_read((int8_t*)"ota.dat", OTA_VERSION_LEN, pVersion, 0);
        if(rc < 0)
        {
            memset(pVersion, '0', OTA_VERSION_LEN);
            rc = FILE_write("ota.dat", OTA_VERSION_LEN, (uint8_t*)pVersion, NULL, SL_FS_CREATE_FAILSAFE);
            if (rc < 0)
                while(1)    // HERE THE CODE GETS STUCK
                    ;
        }
    }
    LOG_ERROR_IF_NEG(rc, "FILE_read failed");
    return rc;
}


When I check image.syscfg file under CCS the ota.dat file is listed over there. What might be causing this problem? What is the solution?

Kind regard,
Mike

  • Check the "rc" error value (this will tell you the reason for the failure).

    Make sure you don't have the "ota.dat" in file system (especially one that was not created with the FAILSAFE flag).

    You can remove it from "image.syscfg".

    which project exactly have you imported? (i.e. what OS and compiler?) - typically the "image.syscfg" should be ok - but seems that something is wrong in your case. 

  • Hi Kobi,

    Project got imported from:
    C:\ti\simplelink_cc32xx_sdk_6_10_00_05\examples\rtos\CC3235SF_LAUNCHXL\demos\mqtt_client

    mqtt_client_CC3235SF_LAUNCHXL_freertos_ccs

  • ok. thanks - i'll check this. 

    meanwhile just remove the ota.dat from "image.syscfg" (and reprogram the device).

  • I do get rc = -2014

    #define SL_RET_CODE_PROVISIONING_IN_PROGRESS                            (-2014L)


    How is reading from filesystem related to provisioning?

  • During provisioning most other NWP API are blocked. 

    Please disable provisioning or wait until it is completed.

  • Removal of the ota.dat from image.syscfg results in exactly the same behavior. I do wonder if ota.dat gets included at all in the filesystem?

    I was trying reading from other file sys\mcubootinfo.bin with exactly he same result.

    I will try to wait for the end of provisioning...

  • yep, according to the error code - it is not related. OTA can't be started during provisioning.

  • Got it working. It was a provisioning process that was blocking access to the filesystem. This change fixes the problem:

    /* mqtt_client_app.c: mainThread() */
    
    /* ... */
    
        ret = SlNetConn_start(SLNETCONN_SERVICE_LVL_INTERNET, SlNetConnEventHandler, SLNETCONN_TIMEOUT, 0);
    
        /* If Failure to acquire AP Connection, verify no pending OTA commit by initializing OTA library then return to attempting to connect to the AP */
        if(ret != 0)
        {
            LOG_INFO("failed to Connect to AP: Error Code: %d. Verifying no pending OTA commits then re-attempting", ret);
            conn_Failure = 1;
    
        }
        
        
        LOG_INFO("mainThread: Waiting for provisioning...");
        
        // THIS LINE IS NEEDED!
        while (gIsProvsioning);
    
    
    #if OTA_SUPPORT
        HTTPSRV_IF_params_t *pHttpSrvParams = NULL;
    #if LOCAL_OTA_SUPPORT
        HTTPSRV_IF_params_t httpsSrvParams;
        httpsSrvParams.pClientRootCa = NULL;
        httpsSrvParams.pServerCert = "dummy-root-ca-cert";
        httpsSrvParams.pServerKey = "dummy-root-ca-cert-key";
        httpsSrvParams.primaryPort = 443;
        httpsSrvParams.secondaryPort = 80;
        pHttpSrvParams = &httpsSrvParams;
    #endif
        ret = OTA_IF_init(pHttpSrvParams, OtaCallback, 0, NULL);
        if(ret < 0){
            LOG_INFO("failed to init OTA_IF");
            while(1);
        }
    #endif
    
    /* .... */


    Thanks Kobi for help!

  • Or you could have extended the timeout for the SlNetConn_start.(0xffff - means it will wait till the connection is established).