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.

CC3220: Host driven factory reset procedure

Part Number: CC3220


Hi,

I'm trying to figure out what the exact procedure is to execute a host driven factory reset on the CC3220.

The simplelink programmer's guide () is not very clear on this.

As far as I can tell, with SOP[2:0] fixed on 000, I should just run the following code:

_i32 slRetVal;
SlFsRetToFactoryCommand_t RetToFactoryCommand;
_i32 Status, ExtendedStatus;
RetToFactoryCommand.Operation = SL_FS_FACTORY_RET_TO_IMAGE;
Status = sl_FsCtl( (SlFsCtl_e)SL_FS_CTL_RESTORE, 0, NULL , (_u8 *)&RetToFactoryCommand ,
sizeof(SlFsRetToFactoryCommand_t), NULL, 0 , NULL );
if ((_i32)Status < 0)
{
/*error*/
//Status is composed from Signed error number & extended status
Status = (_i16)Status>> 16;
ExtendedStatus = (_u16)slRetVal& 0xFFFF;
break;
}
//Reset
sl_Stop(10);
//sl_Start(NULL, NULL, NULL);
//CC3220
 PRCMHibernateCycleTrigger();

But is this all? Is this supposed to fully execute the entire factory reset?

From what I can see, this seem to do -something-, but after a while seems to reset the device which then fully hangs. (nothing happens/boots. Nor the old or current image)
Even when unpowering/repowering and waiting a long time, nothing seems to happen.
Only when I toggle the RESET line, after 10+s the system seems to reboot into a valid image again.

Is this behavior to be expected? And/or what is the full procedure to execute a host-driven factory reset? Am I missing something, since the toggling of the reset was not outlined in the datasheet?

Thanks for any clarification.

Arnout

  • Hi Arnout,

    The code that you have there is basically all that is needed to execute a factory reset. After issuing the command, the NWP will indeed take several seconds to complete the factory reset operation. During this time, the NWP is not available for use and sl_FsCtl() will block until programming is complete. Once it returns, do a sl_stop()/sl_start() and then reset the MCU. Resetting the MCU through software should be good enough - you don't need to actually physically assert the reset signal.If you happen to reset or power-cycle the device while sl_FsCtl() is still running, the NWP will continue the factory reset automatically and will block program execution until it is complete, which is most likely what you observed.

    The code below here works for host-driven factory reset as well as hardware-driven factory reset:

    void mainThread(void *pvParameters)
    {
        int32_t             status = 0;
        pthread_attr_t      pAttrs_spawn;
        pthread_attr_t      pAttrs;
        struct sched_param  priParam;
        int32_t             mode;
        int16_t             ret;
    
        SPI_init();
        Display_init();
        display = Display_open(Display_Type_UART, NULL);
        if (display == NULL) {
            /* Failed to open display driver */
            while(1);
        }
        ret = sem_init(&ipEventSyncObj,0,0);
        if(ret != 0)
        {
            printError("Semaphore init failed, error code : %d \r\n", ret);
            return;
        }
        Display_printf(display,0,0,"At start of application\n\r");
        /* Start the SimpleLink Host */
        pthread_attr_init(&pAttrs_spawn);
        priParam.sched_priority = SPAWN_TASK_PRIORITY;
        status = pthread_attr_setschedparam(&pAttrs_spawn, &priParam);
        status |= pthread_attr_setstacksize(&pAttrs_spawn, SPAWN_STACK_SIZE);
    
        status = pthread_create(&spawn_thread, &pAttrs_spawn, sl_Task, NULL);
        if(status)
        {
            printError("Task create failed, error code : %d \r\n", status);
        }
    
        /* initialize the device */
    
        mode = sl_Start(0, 0, 0);
        Display_printf(display,0,0,"sl_Start return code %d\n\r",mode);
        if (mode == SL_ERROR_RESTORE_IMAGE_COMPLETE )
        {
            Display_printf(display,0,0,"Received factory reset status code. Resetting MCU...");
            PRCMMCUReset(1);
    
        }
        else if (mode < 0)
        {
            printError("Sl_start failed, error code : %d \r\n", status);
        }
    
        /* Perform factory reset */
        _i32 slRetVal;
        SlFsRetToFactoryCommand_t RetToFactoryCommand;
        _i32 Status, ExtendedStatus;
        RetToFactoryCommand.Operation = SL_FS_FACTORY_RET_TO_IMAGE;
        Status = sl_FsCtl( (SlFsCtl_e)SL_FS_CTL_RESTORE, 0, NULL , (_u8 *)&RetToFactoryCommand ,
        sizeof(SlFsRetToFactoryCommand_t), NULL, 0 , NULL );
        if ((_i32)Status < 0)
        {
        /*error*/
        //Status is composed from Signed error number & extended status
        Status = (_i16)Status>> 16;
        ExtendedStatus = (_u16)slRetVal& 0xFFFF;
        Display_printf(display,0,0,"factory reset failed, error status : %d, extended status: %d\r\n", Status, ExtendedStatus);
        }
        //Reset
        Display_printf(display,0,0,"stopping sl %d\n\r",mode);
        sl_Stop(10);
        Display_printf(display,0,0,"starting sl\n\r",mode);
        mode = sl_Start(NULL, NULL, NULL);
        if (mode == SL_ERROR_RESTORE_IMAGE_COMPLETE )
        {
            Display_printf(display,0,0,"Received factory reset status code. Resetting MCU...");
            PRCMMCUReset(1);
    
        }
        else if (mode < 0)
        {
            printError("Sl_start failed, error code : %d \r\n", status);
            while(1){
                ;
            }
        }
        //CC3220
        PRCMMCUReset(1);
    }

    Give that a try and see if that helps clear up some of the questions you might have. If you are still confused about how this process works, feel free to let me know.

  • Hi,

    Thanks for your reply, I'll try it and let you know.

    I do have another question though:

    I have the hardware watchdog running in my code, and have a seperate thread that kicks it.
    If the factory reset SW operation takes a long time, is it possible preemption is not active, causing the other thread not to execute, triggering the wdog to reset? This might explain the strange behavior?

    Kind regards,
    Arnout
  • Hi,

    I have two additional questions:

    - In your code snippet, you do "factory reset" + sl_stop + sl_start + reset. The datasheet seems to tell to not do the sl_start before the reset. Is this then wrong in the datasheet?

    - The datasheet also uses PRCMHibernateCycleTrigger, while you use PRCMMCUReset. Is this of any significance?

    Thanks for your reply!

    Arnout

  • Hi,

    I got it working now that I disabled the HW wdog.
    It clearly fired during the operation, causing everthing to get screwed up pretty bad.
    (Also, the PRCMHibernateCycleTrigger/ PRCMMCUReset does not seem to matter).

    Thanks for the help.

    Kind regards,
    Arnout