|
@@ -204,7 +204,10 @@ static void Main_Task(void* arg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
+ if(Fota_Struct.Fota_update)
|
|
|
|
+ {
|
|
|
|
+ sleep_count = 0;
|
|
|
|
+ }
|
|
if (sleep_count >=sleep_time_value)
|
|
if (sleep_count >=sleep_time_value)
|
|
{
|
|
{
|
|
PROC_MAIN_STATE_SWITCH(PROCESS_STATE_SLEEP);
|
|
PROC_MAIN_STATE_SWITCH(PROCESS_STATE_SLEEP);
|
|
@@ -468,7 +471,7 @@ static void Uart_Task(void* arg)
|
|
slpManApplyPlatVoteHandle("UARTSLP",&UartSlpHandler);
|
|
slpManApplyPlatVoteHandle("UARTSLP",&UartSlpHandler);
|
|
slpManPlatVoteDisableSleep(UartSlpHandler, SLP_SLP2_STATE);
|
|
slpManPlatVoteDisableSleep(UartSlpHandler, SLP_SLP2_STATE);
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
|
|
-
|
|
|
|
|
|
+ uint16_t temp;
|
|
while (true)
|
|
while (true)
|
|
{
|
|
{
|
|
switch (gProcess_Uart_Task)
|
|
switch (gProcess_Uart_Task)
|
|
@@ -480,8 +483,9 @@ static void Uart_Task(void* arg)
|
|
}
|
|
}
|
|
case PROCESS_UART_STATE_WORK:
|
|
case PROCESS_UART_STATE_WORK:
|
|
{
|
|
{
|
|
|
|
+ BSP_QSPI_Read_Safe(&temp,0x318000,2);
|
|
#ifdef USING_PRINTF
|
|
#ifdef USING_PRINTF
|
|
- printf("UART_STATE_WORK!\n");
|
|
|
|
|
|
+ printf("V0003!,Fota_flag:%c%c\n",temp,temp>>8);
|
|
#endif
|
|
#endif
|
|
//Uart_func();//读取函数运行
|
|
//Uart_func();//读取函数运行
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
|
|
PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
|
|
@@ -514,20 +518,23 @@ uint8_t Fota_crc_chk(uint8_t* data,uint8_t length)
|
|
}
|
|
}
|
|
//Fota线程
|
|
//Fota线程
|
|
static void Fota_Task(void* arg)
|
|
static void Fota_Task(void* arg)
|
|
-{
|
|
|
|
|
|
+{
|
|
Fota_Struct.Fota_Current_Addres = 0x00000000;
|
|
Fota_Struct.Fota_Current_Addres = 0x00000000;
|
|
Fota_Struct.Fota_Recv_Data_Len=100;
|
|
Fota_Struct.Fota_Recv_Data_Len=100;
|
|
uint8_t Uart_Rece_buffer[110];
|
|
uint8_t Uart_Rece_buffer[110];
|
|
- uint8_t temp[100];
|
|
|
|
|
|
+ uint8_t temp[1];
|
|
uint8_t Uart_Send_buffer[6] = {0x00,0x00,0x00,0x00,0x64,0x01};
|
|
uint8_t Uart_Send_buffer[6] = {0x00,0x00,0x00,0x00,0x64,0x01};
|
|
uint8_t timeout = 0x00;
|
|
uint8_t timeout = 0x00;
|
|
uint8_t Fota_Crc;
|
|
uint8_t Fota_Crc;
|
|
- osDelay(5000);
|
|
|
|
|
|
+ uint32_t Recv_Address;
|
|
|
|
+ Fota_Struct.Fota_Flash_Addres = 0x2A0000;
|
|
|
|
+ osDelay(1000);
|
|
USARTdrv->Send(Uart_Send_buffer,6);
|
|
USARTdrv->Send(Uart_Send_buffer,6);
|
|
while (true)
|
|
while (true)
|
|
{
|
|
{
|
|
osDelay(500);
|
|
osDelay(500);
|
|
USARTdrv->Receive(Uart_Rece_buffer,110);
|
|
USARTdrv->Receive(Uart_Rece_buffer,110);
|
|
|
|
+ Fota_Struct.Fota_update = FALSE;
|
|
while((isRecvTimeout == false) && (isRecvComplete == false))
|
|
while((isRecvTimeout == false) && (isRecvComplete == false))
|
|
{
|
|
{
|
|
timeout++;
|
|
timeout++;
|
|
@@ -544,25 +551,25 @@ static void Fota_Task(void* arg)
|
|
isRecvComplete == false;
|
|
isRecvComplete == false;
|
|
Fota_Struct.Fota_All_Data_Len = Uart_Rece_buffer[0]<<24|Uart_Rece_buffer[1]<<16|Uart_Rece_buffer[2]<<8|Uart_Rece_buffer[3];
|
|
Fota_Struct.Fota_All_Data_Len = Uart_Rece_buffer[0]<<24|Uart_Rece_buffer[1]<<16|Uart_Rece_buffer[2]<<8|Uart_Rece_buffer[3];
|
|
Fota_Crc = Fota_crc_chk(&Uart_Rece_buffer[9],Fota_Struct.Fota_Recv_Data_Len);
|
|
Fota_Crc = Fota_crc_chk(&Uart_Rece_buffer[9],Fota_Struct.Fota_Recv_Data_Len);
|
|
- if (Fota_Crc==Uart_Rece_buffer[109])
|
|
|
|
|
|
+ Recv_Address = Uart_Rece_buffer[4]<<24|Uart_Rece_buffer[5]<<16|Uart_Rece_buffer[6]<<8|Uart_Rece_buffer[7];
|
|
|
|
+ #ifdef USING_PRINTF
|
|
|
|
+ printf("Recv_Address:%x!\t",Recv_Address);
|
|
|
|
+ printf("Fota_Current_Addres:%x!\n",Fota_Struct.Fota_Current_Addres);
|
|
|
|
+ #endif
|
|
|
|
+ if ((Fota_Crc==Uart_Rece_buffer[Fota_Struct.Fota_Recv_Data_Len+9])&&(Fota_Struct.Fota_Current_Addres==Recv_Address))
|
|
{
|
|
{
|
|
#ifdef USING_PRINTF
|
|
#ifdef USING_PRINTF
|
|
printf("Fota_Crc:%x!\n",Fota_Crc);
|
|
printf("Fota_Crc:%x!\n",Fota_Crc);
|
|
printf("Fota_Current_Addres:%x!\n",Fota_Struct.Fota_Current_Addres);
|
|
printf("Fota_Current_Addres:%x!\n",Fota_Struct.Fota_Current_Addres);
|
|
#endif
|
|
#endif
|
|
- BSP_QSPI_Erase_Safe(0x2A0000,100);
|
|
|
|
- BSP_QSPI_Write_Safe(&Uart_Rece_buffer[9],0x2A0000,100);
|
|
|
|
- BSP_QSPI_Read_Safe(&temp,0x2A0000,100);
|
|
|
|
- #ifdef USING_PRINTF
|
|
|
|
- printf("temp:");
|
|
|
|
- for(int i=0;i<100;i++)
|
|
|
|
- printf("%x ",temp[i]);
|
|
|
|
- printf("\n");
|
|
|
|
- #endif
|
|
|
|
|
|
+ Fota_Struct.Fota_update = TRUE;
|
|
|
|
+ BSP_QSPI_Erase_Safe(Fota_Struct.Fota_Flash_Addres+Fota_Struct.Fota_Current_Addres,Fota_Struct.Fota_Recv_Data_Len);
|
|
|
|
+ BSP_QSPI_Write_Safe(Uart_Rece_buffer+9,Fota_Struct.Fota_Flash_Addres+Fota_Struct.Fota_Current_Addres,Fota_Struct.Fota_Recv_Data_Len);
|
|
}
|
|
}
|
|
|
|
+ Fota_Struct.Fota_Current_Addres = Recv_Address + Fota_Struct.Fota_Recv_Data_Len;
|
|
if (Fota_Struct.Fota_Current_Addres + Fota_Struct.Fota_Recv_Data_Len >Fota_Struct.Fota_All_Data_Len)
|
|
if (Fota_Struct.Fota_Current_Addres + Fota_Struct.Fota_Recv_Data_Len >Fota_Struct.Fota_All_Data_Len)
|
|
{
|
|
{
|
|
- Fota_Struct.Fota_Recv_Data_Len = Fota_Struct.Fota_All_Data_Len-Fota_Struct.Fota_Current_Addres;
|
|
|
|
|
|
+ Fota_Struct.Fota_Recv_Data_Len = Fota_Struct.Fota_All_Data_Len - Fota_Struct.Fota_Current_Addres;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -573,6 +580,17 @@ static void Fota_Task(void* arg)
|
|
#ifdef USING_PRINTF
|
|
#ifdef USING_PRINTF
|
|
printf("Done!\n");
|
|
printf("Done!\n");
|
|
#endif
|
|
#endif
|
|
|
|
+ appSetCFUN(0);
|
|
|
|
+ #ifdef USING_PRINTF
|
|
|
|
+ for(int i=0;i<Fota_Struct.Fota_All_Data_Len;i++)
|
|
|
|
+ {
|
|
|
|
+ BSP_QSPI_Read_Safe(temp,Fota_Struct.Fota_Flash_Addres+i,1);
|
|
|
|
+ printf("%X ",temp[0]);
|
|
|
|
+ }
|
|
|
|
+ #endif
|
|
|
|
+ osDelay(5000);
|
|
|
|
+ EC_SystemReset();
|
|
|
|
+
|
|
}
|
|
}
|
|
#ifdef USING_PRINTF1
|
|
#ifdef USING_PRINTF1
|
|
printf("Uart_Rece_buffer:");
|
|
printf("Uart_Rece_buffer:");
|
|
@@ -586,10 +604,6 @@ static void Fota_Task(void* arg)
|
|
Uart_Send_buffer[3] = Fota_Struct.Fota_Current_Addres;
|
|
Uart_Send_buffer[3] = Fota_Struct.Fota_Current_Addres;
|
|
Uart_Send_buffer[4] = Fota_Struct.Fota_Recv_Data_Len;
|
|
Uart_Send_buffer[4] = Fota_Struct.Fota_Recv_Data_Len;
|
|
USARTdrv->Send(Uart_Send_buffer,6);
|
|
USARTdrv->Send(Uart_Send_buffer,6);
|
|
- Fota_Struct.Fota_Current_Addres = Fota_Struct.Fota_Current_Addres + Fota_Struct.Fota_Recv_Data_Len;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|