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.

CC3200MOD: FLC_TEST_RESET_MCU FLAG / testing a new FOTA image

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

Hi Folks,

So close on getting FOTA to work.  I'm using a cell module instead of WiFi, so I FTP the FOTA.bin file to the cell module User File Space (UFS) and then I read the file and create the mcuimg* file.  All seems to work fine, except a reboot isn't being triggered with the new image flagged for test.  

I can use Uniflash and confirm the file was create and about the right size.

Here is the code I use to create the flash file:

_i32 move_UFS_to_mcuimgA(void)
{
    _u32 lMAX_FILE_SIZE = 65535l; //64 * 1024-1;

    ...    

    status = sl_extlib_FlcOpenFile("/sys/mcuimgA.bin", lMAX_FILE_SIZE, NULL, &lFileHandle_img, (_FS_FILE_PUBLIC_WRITE |_FS_FILE_OPEN_FLAG_COMMIT));

    ..
    

    while (not_done)  
    {

        connect_ptr = strstr(cCellRxData, "CONNECT "); 
        if (connect_ptr != NULL)
        {
            ... // set i variable to first byte of FOTA image...  temp_number is 1000 bytes or less if the last read
            
            status = sl_extlib_FlcWriteFile(lFileHandle_img, file_offset, (unsigned char *) &connect_ptr[i], temp_number);

            file_offset += temp_number;
            if (temp_number < 1000)
            {
                not_done = 0;
            }
        } // connect_ptr != NULL
        else
        {
            not_done = 0;
        }
    } // while not_done
    
    ...

    status = sl_extlib_FlcCloseFile(lFileHandle_img, NULL, NULL , 0);
    if (status < 0)
    {
        // something bad happened.
        ret_val = status;
        sl_Stop(SL_STOP_TIMEOUT);

        return ret_val;
    }


    status = sl_extlib_FlcTest(FLC_TEST_RESET_MCU_WITH_APP);
    if (status & FLC_TEST_RESET_MCU)  /// THIS STATEMENT RETURNS FALSE
    {
//       Report("proc_ota_run_step: Rebooting...");
//       Platform_Reset();    I can't find this function for CC3200, it might be a cc3220 specific function
        sl_Stop(SL_STOP_TIMEOUT);


 //       ProcessRestartMcu(); // another cc3220 function for resetting?
        PRCMMCUReset(true);
    }

    // IT GETS HERE BUT SHOULDN'T.
    return ret_val;
}

Also, here is what I run when the software starts up:  (I haven't had a chance to test with a successful FOTA file, but it seems to work if I load the image using uniflash, ie it doesn't break anything).

void check_FOTA_reboot(void)
{
    status = sl_extlib_FlcCommit(FLC_COMMITED);

    if (status == FLC_TEST_RESET_MCU)
    {
        reset_board();
    }
}

Again thanks for any pointers.  I have 30 hardware prototypes that I want to get into the field for beta testing, but need this working before I can do that.

thanks again,

Bob

  • Hi Bob,

    If you want to reset the CC3200 in software, the following code should be used instead of PRCMMCUReset():

    MAP_PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR);
            MAP_UtilsDelay((40000000 / 120) * 24);
    
            // Set wake up time and enter HIB
            MAP_PRCMHibernateIntervalSet(330);
            MAP_PRCMHibernateEnter();

    Restarting the device through a hibernate cycle results in less potential issues, and so it's recommended to use that method instead of simply using PRCMMCUReset().

    As for why the newly programmed mcuimg doesn't result it being in the test mode, could you please collect the NWP logs during the FOTA process? Curious as to what is actually written to the filesystem, and which image the CC3200 actually ends up booting. Instructions on collecting the NWP logs can be found here:https://processors.wiki.ti.com/index.php/CC3100_%26_CC3200_Capture_NWP_Logs

    Regards,

    Michael

  • Hi Michael,

    Thanks so much for the response!  I have a few tasks to take care of today but will try this out soon and will report back (might be Monday.)

    thanks again,
    Bob

  • Hi Michael,

    I've been digging into this some.  Looks like the file is being corrupted before being written to /sys/mcuimgA.....

    Thanks for the reboot suggestion I was able to incorporate that.

    Bob

  • Just to finish the thread.  I did get it all working.  The problem was in the cell module FTP file transfer corrupting the new bin file.  Once that was corrected all worked well.

    One thing that helped much was writing a small routine that would track the status of sl_start() and sl_stop().   The routine had a static flag to check if the system is already running then don't call sl_start().    And if the system isn't running don't call sl_stop().

    thanks again for all the help!

    Bob