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.

CC3220SF-LAUNCHXL: ota.cmd ERROR in _BundleCmdFile_Parse

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: CC3220SF, UNIFLASH

While using local ota in cc3220sf the following issue is found while parsing the ota.cmd file

Error: -16384, Couldn't parse the received Json file <CR><LF>
[OtaArchive_RunParseTar] ERROR in _BundleCmdFile_Parse, Status=-16384<CR><LF>

The sdk used is simplelink_cc32xx_sdk_1_60_00_04

The ota.cmd file created by uniflash 4.2.1 is

[
{
"digest":"ca07d9c0c8cf718e227cc62a5198025728005c056ab53b5c8242af364fa437ed",
"certificate":"",
"signature_base64":"",
"secured":1,
"bundle":1,
"filename":"/sys/mcubootinfo.bin"
},
{
"digest":"9c3c60e4668c8775a88c123d6a931e7cc2b0a1d5ffcb9b23cd8c0b957b5b7d52",
"certificate":"dummy-root-ca-cert",
"signature_base64":"QnynCxGm3jiv4HKns6NyMIu/dFq3hOcEqC/USqAyeSlDYYWHsp1x3b8J4wqbcE00zrglnf+0FhQeRxvIkis2GuOlced+vkYF8XXmx58U/NqyJsolSfsW/Nm7rfzwL0KU2cFyb3y6Ah2LQeaPt5L2NORyad+oa4W9/IjtmM4zant/bVUNo1aZtCqQV8PE3ZTZfvn16wLFrqDuWUQ7T5WLLRsbEdamsnl1yT+JuXRL+JpQItsMrNxIGcn1yK0GuShAqMGSWonPPg3ZQpw/h7ibQ+2L0cA/NhnM0p0sk1pUAa4bX3UPnjsURNITr2WI7j0e9YDeKI+afXzGuT5hlqYyuw==",
"secured":1,
"bundle":1,
"filename":"/sys/mcuflashimg.bin"
},
{
"digest":"feef1c942ef14001711ca61a59f495c6ac88f2c495f2513ceb63c5b7c33e7b22",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/callout.png"
},
{
"digest":"7698ab55269ac5ddc047cd17896ed70b732f039997c4950a8b3a6c8aaef65774",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/d.js"
},
{
"digest":"835c4095ba83871be0da1399233fda6fa0666f8f77d131f600c27d51b4cea74b",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/favicon.ico"
},
{
"digest":"263d362b7f6f6ded3c7d4f9839790ff55f162d888e0ebc8af578e375a057df06",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/index.htm"
},
{
"digest":"fef40a1e33420f00bdd431b98bc2c78f858a70792695df4dece3b9f5b3898281",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/item.png"
},
{
"digest":"64a3e7cc0ebdc06a1835b046d8d56f895404b7b780eac116ec765fb4a1871cd2",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/listdir.cgi"
},
{
"digest":"e8881d2e9ebf02222ae583327dbf089aaaf955e55d61ce1bdd09244bc6c461b9",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/login.htm"
},
{
"digest":"e8881d2e9ebf02222ae583327dbf089aaaf955e55d61ce1bdd09244bc6c461b9",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/main.html"
},
{
"digest":"49705c4fa4474f410f08dcc1b1ae6a49a3ead3261885edb492ddefedebbd99d9",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/monthbackward_normal.gif"
},
{
"digest":"5d97d14f870879185cc4c1da2d387f3c26b0a03eaec4100ea17580c732267d8a",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/monthforward_normal.gif"
},
{
"digest":"637ce1bf5478487417624334241d7fec1c36f627ea0af4fd1557e5a4e7c865c3",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/req.htm"
},
{
"digest":"370b51bfc70da3aa69bd8415822ec4259241a5dbf9793085e34000108eb7a556",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/site_test.css"
},
{
"digest":"637ce1bf5478487417624334241d7fec1c36f627ea0af4fd1557e5a4e7c865c3",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"/www/upgrade.htm"
},
{
"digest":"34941765501d16a4ab776c3a74d89945f1a2575c5893069f62ffbe803f344549",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"dummy-root-ca-cert"
},
{
"digest":"a160b855d7a00a6002922181377249a80ecd6a738d23e1dd8976c8bb7fad1bcb",
"certificate":"",
"signature_base64":"",
"secured":0,
"bundle":1,
"filename":"dummy_ota_vendor_cert.der"
},
{
"digest":"d4ed4c744b1d68a60bee9670f5d95b7dc705ee93b9cec1656a17a9519623baba",
"certificate":"",
"signature_base64":"oATmfueKeInbDmOVA/smKyBe1swJ5yWzgo4KLkVuBY84su6+/pWsfAHbiUMnQl8jGLQ0li067A4bIl1UC1yMsRE9VJhB3xy/547ZyPpB/MTvaNT4v33kuTPUdXO7dbo4QYQHyeXX+vNuLoIrx419ePkWiw3RRR15Z2zPYy+tWFYL7J2jQQ0ttOgjeMCoSgYriMyV4C2kWqrhungSKTV/u+o65hz1+DllBF2SFgqltmyfWjDXkIjsvuPfHE7+I2Ns7fJcyNBiiS2fT3CUsw3Ky5aWPLZkz3orilandeOvmAfsB9f5Wcdelic4KTvKZVIkLIb46y5rPnJy6BCNQe1snA==",
"secured":1,
"bundle":1,
"filename":"/sys/servicepack.ucf"
}
]

  • Hi Himanshu Batra,

    This looks like a parsing issue.
    Please provide the terminal log which should show the exact point of failure.
    Alternatively - go through the "_BundleCmdFile_Parse" step by step to find what triggers the error.
    This typically caused by JSON buffer size that is too small for the input string, but i couldn't find anything obvious in your file (the sizes are defined in the top of "ota_json.c" and you can try manipulating them).

    Br,
    Kobi
  • The terminal logs are :

    [_BundleCmdFile_Parse] bundle cmd file=/sys/mcubootinfo.bin, sig_len=0, SHA_256_Digets=ca07d9c0c8cf718e227cc62a5198025728005c056ab53b5c8242af364fa437ed, cert=, secured=1, bundle=1<CR><LF>
    [_BundleCmdFile_Parse] bundle cmd file=/sys/mcuflashimg.bin, sig_len=256, SHA_256_Digets=9c3c60e4668c8775a88c123d6a931e7cc2b0a1d5ffcb9b23cd8c0b957b5b7d52, cert=dummy-root-ca-cert, secured=1, bundle=1<CR><LF>
    [_BundleCmdFile_Parse] bundle cmd file=/www/callout.png, sig_len=0, SHA_256_Digets=feef1c942ef14001711ca61a59f495c6ac88f2c495f2513ceb63c5b7c33e7b22, cert=, secured=0, bundle=1<CR><LF>
    [_BundleCmdFile_Parse] bundle cmd file=/www/d.js, sig_len=0, SHA_256_Digets=7698ab55269ac5ddc047cd17896ed70b732f039997c4950a8b3a6c8aaef65774, cert=, secured=0, bundle=1<CR><LF>
    [_BundleCmdFile_Parse] bundle cmd file=/www/favicon.ico, sig_len=0, SHA_256_Digets=835c4095ba83871be0da1399233fda6fa0666f8f77d131f600c27d51b4cea74b, cert=, secured=0, bundle=1<CR><LF>
    [_BundleCmdFile_Parse] bundle cmd file=/www/index.htm, sig_len=0, SHA_256_Digets=263d362b7f6f6ded3c7d4f9839790ff55f162d888e0ebc8af578e375a057df06, cert=, secured=0, bundle=1<CR><LF>
    [_BundleCmdFile_Parse] bundle cmd file=/www/item.png, sig_len=0, SHA_256_Digets=fef40a1e33420f00bdd431b98bc2c78f858a70792695df4dece3b9f5b3898281, cert=, secured=0, bundle=1<CR><LF>
    Error: -16384 , Couldn't parse the received Json file <CR><LF>
    [OtaArchive_RunParseTar] ERROR in _BundleCmdFile_Parse, Status=-16384<CR><LF>

    And specifically about which buffer are you talking about. Is it the JSON_OBJ_SIZE or some other?
  • Hi Himanshu,

    This give more focus but not enough.
    As I'm not familiar with similar issue (and couldn't reproduce this - I actually passed the point that you got the error using similar ota.cmd as you provided), I'll need you help with the debug.
    Please put a break point at line 511 of ota_archive.c -> this is where the files name are being read from ota.cmd file and printed to the log. You stop couple of times until you get to "/www/item.png". Continue debugging step-by-step until you get to the point of failure.
    Alternatively, add some log prints in "_BundleCmdFile_Parse" to get to the exact point of failure.

    Have you done any change in the Local OTA example?

    Thanks,
    Kobi
  • local_ota_CC3220SF.txt
                    while(g_state.connections[uConnection].uContentLeft)
                    {
    //                    UART_PRINT("Content Length %d\r\n",g_state.connections[uConnection].uContentLeft);
                        if (unprocessedBytes > 0)
                        {
                            memcpy(&g_PayloadBuffer[0], &g_PayloadBuffer[processedBytes], unprocessedBytes);
                        }
    
                        chunkLen = SL_NETAPP_REQUEST_MAX_DATA_LEN - unprocessedBytes;
    
                        if(chunkLen)
                        {
                            recvlen = recv(g_state.connections[uConnection].dataSocket, (char*)&g_PayloadBuffer[unprocessedBytes], chunkLen, 0);
                            if(recvlen < 0)
                            {
                                UART_PRINT("!!!!!!!!!!recv = %d!!!!!!!!!\n\r", recvlen);
                                OtaArchive_Abort(&g_OtaArcive);
                                first_otapacket = 0;
                                return 1;
                            }
                            chunkLen = recvlen;
                        }
    //                    UART_PRINT("chunkLen= %d recv = %d unprocessedBytes= %d processedBytes= %d \n\r", chunkLen, recvlen, unprocessedBytes, processedBytes);
                        otaState = OtaArchive_GetStatus(&g_OtaArcive);
    //                    UART_PRINT("******** OTA state is %d \n\r", otaState);
                        otaChunkLen = chunkLen + unprocessedBytes;
                        ota_status = (int32_t)OtaArchive_Process(&g_OtaArcive, g_PayloadBuffer, otaChunkLen, &processedBytes);
    //                    UART_PRINT("*******Received OTA payload=%d. Processed=%d \n\r", otaChunkLen, processedBytes);
                        if(ota_status <0)
                        {
                            UART_PRINT("Error %d\r\n",ota_status);
                            mcuReboot();
                        }
                        else if (ota_status == ARCHIVE_STATUS_DOWNLOAD_DONE)
                        {
                            ota_update = 0;
                            UART_PRINT("download done");
                            ota_complete = 1;
                            osi_LockObjLock(updateVar_MutexHandle, 300);
                            OSI_DELAY(5000);
                            mcuReboot();
                        }
                        unprocessedBytes = otaChunkLen - processedBytes;
    
                        g_state.connections[uConnection].uContentLeft -= chunkLen;
                        g_state.connections[uConnection].request.requestContent.uLength += (UINT16)chunkLen;
                    }
                }
    
    Hi Kobi,

    The error is not always received. Sometimes the ota update runs successfully and sometimes fails with the shared error.

    We have seen the similar issue in

    I hope you have already seen this post.

    However, the buffer mentioned in this is used for cloud ota and we are using the local ota.

    We have already verified and tried to increase the buffer sizes mention at top of otajson.h as per your suggestion but the problem is still not resolved. After step debigging the point of error found lies in the function "OtaJson_init" in ota_archive.c.

    Also the code is attached. This is called through http

    Thanks,

    Himanshu

  • Hi Himanshu,

    The other issue is not relevant for your case.

    As said before, this is a new issue and I'll need your help debugging it.

    You mentioned that the problem occurs in OtaJson_init() (which is implemented in "OtaJson.c"), can you be more specific? 

    The attached code doesn't seems to be relevant.

    Please specify the OtaJson_init input parameters when it fails:

    - template_OtaCmd - should be constant value (as initiated in the ota_archive.c), make sure it is not overridden.

    - pStartFileBuf - should point to a memory buffer that contains a file description from the OTA,  for example:

    {
    "digest":"fef40a1e33420f00bdd431b98bc2c78f858a70792695df4dece3b9f5b3898281",
    "certificate":"",
    "signature_base64":"",
    "secured":0,
    "bundle":1,
    "filename":"/www/item.png"
    },

    Please send me the buffer that you see.

    - the 3rd parameter should be the length of the buffer

              Please send the value.

    Again, I've tried parsing the same file and it works for me - so really need your help debugging this.

    Br,

    Kobi

  • The issue is resolved. It was because of the heap size. Increasing the heap size did work in my case