Other Parts Discussed in Thread: CC3200, UNIFLASH
Hi All,
I am working on a project where i have to perform OTA on pressing switch, when i press the switch the switch device goes in the OTA loop but OTA does not work properly it stuck in after giving (iRet = sl_extLib_OtaRun(pvOtaApp);) iRet = 0.
Any kind of Help would be appreciated
Here is my ota snippet
//***********************************************************************************************************************
//***********************************************************************************************************************
// OTA Thread Check For Firmware Update If Available Perform Update
//***********************************************************************************************************************
void Button1_Thread(void *pvParameters)
{
int OtaTry, OtaTry2;
event_msgQueue rx_msgQueue;
while(1)
{
//osi_SyncObjWait(&button_syncObj,OSI_WAIT_FOREVER);
osi_MsgQRead( &ButtonMSGQ, &rx_msgQueue, OSI_WAIT_FOREVER);
if(rx_msgQueue.msg_event == short_press)
{
UART_PRINT("--------------Short Press--------------\n");
GPIOPinWrite(GPIOA1_BASE,GPIO_PIN_3,GPIO_PIN_3);
//osi_SyncObjClear(&button_syncObj);
// Disconnect and stop networking service
//Stop_nwp();
//sl_Start(0,0,0);
int iRet;
int SetCommitInt = 1;
unsigned char ucVendorStr[50];
while(!IS_CONNECTED(g_ulStatus))
{
UART_PRINT("--------------!IS_CONNECTED(g_ulStatus)--------------\n");
}
strcpy((char *)ucVendorStr,OTA_VENDOR_STRING);
OtaTry=0;
OtaTry2=0;
while(1)
{
// Initialize OTA service
OTAServerInfoSet(&pvOtaApp,(char *)ucVendorStr);
// Set the OTA status and system state to RUN
UART_PRINT("OTA IN PROGRESS\n");
g_ulSysState = SYS_STATE_RUN;
// OTA update loop
while( SYS_STATE_RUN == g_ulSysState )
{
// while(!iRet)
// {
// iRet = sl_extLib_OtaRun(pvOtaApp);
// }
iRet = sl_extLib_OtaRun(pvOtaApp);
UART_PRINT("OTA LOOP\n");
UART_PRINT("%i\n",iRet);
if ( iRet < 0 )
{
if( RUN_STAT_ERROR_CONTINUOUS_ACCESS_FAILURES == iRet )
{
// Schedule a restart.
UART_PRINT("OTA_ERROR_RETRYING.....\n");
OtaTry++;
if(OtaTry>=2)
{
g_ulSysState = SYS_STATE_ERROR_REBOOT;
}
}
else
{
UART_PRINT("OTA_ERROR_RETRYING.....\n");
OtaTry++;
if(OtaTry>=3)
{
g_ulSysState = SYS_STATE_ERROR_REBOOT;
}
}
}
else if( iRet == RUN_STAT_NO_UPDATES )
{
UART_PRINT("OTA_NO_UPDATES\n");
g_ulSysState = SYS_STATE_NO_UPDATES;
}
else if ((iRet & RUN_STAT_DOWNLOAD_DONE))
{
// Set OTA File for testing
iRet = sl_extLib_OtaSet(pvOtaApp, EXTLIB_OTA_SET_OPT_IMAGE_TEST,
sizeof(int), (_u8 *)&SetCommitInt);
UART_PRINT("Download Completed.\n");
if (iRet & (OTA_ACTION_RESET_MCU| OTA_ACTION_RESET_NWP) )
{
g_ulSysState = SYS_STATE_REBOOT;
}
else
{
OtaTry2++;
if(OtaTry2>=2)
{
g_ulSysState = SYS_STATE_ERROR_REBOOT;
}
}
}
}
if(g_ulSysState == SYS_STATE_REBOOT)
{
UART_PRINT("Rebooting\n");
// Disconnect and stop networking service
Stop_nwp();
// Reboot system
RebootMCU();
}
else if(g_ulSysState == SYS_STATE_ERROR_REBOOT)
{
UART_PRINT("Error.Rebooting..\n");
// Disconnect and stop networking service
Stop_nwp();
// Reboot system
RebootMCU();
}
else if(g_ulSysState == SYS_STATE_NO_UPDATES)
{
osi_Sleep(1000);
Button1_EnableInterrupt();
Button2_EnableInterrupt();
break;
}
}
//osi_SyncObjClear(&button_syncObj);
}
/************************** Long Press to Reset Firmware *****************************/
else if(rx_msgQueue.msg_event == long_press)
{
UART_PRINT("--------------Long Press--------------\n");
Stop_nwp();
sl_Start(0,0,0);
while(1)
{
sBootInfo_t sBootInfo;
long lFileHandle;
unsigned long ulToken;
// Wait for button press
// osi_SyncObjWait(&g_FactResetSyncObj, OSI_WAIT_FOREVER);
// Read the boot Info
if( 0 == sl_FsOpen((unsigned char *)IMG_BOOT_INFO, FS_MODE_OPEN_READ, &ulToken, &lFileHandle))
{
if( 0 > sl_FsRead(lFileHandle, 0, (unsigned char *)&sBootInfo, sizeof(sBootInfo_t)) )
{
UART_PRINT("Unable to Read /sys/mcubootinfo.bin \n");
// Indicate Error
sl_FsClose(lFileHandle, 0, 0, 0);
sl_Stop(200);
sl_Start(0,0,0);
break;
while(1)
{
}
}
sl_FsClose(lFileHandle, 0, 0, 0);
}
// Set the factory default
sBootInfo.ucActiveImg = IMG_ACT_FACTORY;
sBootInfo.ulImgStatus = IMG_STATUS_NOTEST;
// Save the new configuration
if( 0 == sl_FsOpen((unsigned char *)IMG_BOOT_INFO, FS_MODE_OPEN_WRITE, &ulToken, &lFileHandle))
{
sl_FsWrite(lFileHandle, 0, (unsigned char *)&sBootInfo, sizeof(sBootInfo_t));
sl_FsClose(lFileHandle, 0, 0, 0);
}
// Disconnect and stop networking service
Stop_nwp();
// Reboot system
RebootMCU();
}
osi_Sleep(1000);
Button1_EnableInterrupt();
Button2_EnableInterrupt();
}
else if(rx_msgQueue.msg_event == device_reset)
{
UART_PRINT("--------------Device Reset--------------\nRebooting MCU..\n");
GPIOPinWrite(GPIOA1_BASE,GPIO_PIN_2,GPIO_PIN_2);
Stop_nwp();
// Delete_Files();
RebootMCU();
}
}
}
///--------------- MY OTA_CONFIG.h Configurations are-------------------
#define OTA_SERVER_NAME "api.dropbox.com"
#define OTA_SERVER_IP_ADDRESS 0x00000000
#define OTA_SERVER_SECURED 1
#define OTA_SERVER_APP_TOKEN "sl.BAXc8-D1xPrMyAQdV19mJ-8QP0vSen7Jg-YC785I2raVXiRzcORS_Jpb_ycEl47iHTjW_zhLxNF9VJCIXEatUdHKXIykHentDFmtXN-W6Fj8kkoIPw7CITq8VrGW200XkdNPiA0"
#define OTA_VENDOR_STRING "Vid01_Pid00_Ver00"