|
@@ -24,6 +24,8 @@ void Fota_Func(UINT8 *DataPtr,INT32 connectId)
|
|
|
UINT8 Fota_Answer[43];
|
|
|
UINT8 Fota_Cmd;
|
|
|
INT8 ret;
|
|
|
+ UINT8* Data_Read_Buffer;
|
|
|
+ UINT8 Data_Read_Crc;
|
|
|
if(*(DataPtr+30)==0x01)
|
|
|
{
|
|
|
Fota_S.Fota_Flash_Addres = FLASH_FOTA_REGION_START;
|
|
@@ -44,6 +46,7 @@ void Fota_Func(UINT8 *DataPtr,INT32 connectId)
|
|
|
else
|
|
|
{
|
|
|
Fota_Answer[3] = 0x01;
|
|
|
+ BSP_QSPI_Erase_Safe(Fota_S.Fota_Flash_Addres,Fota_S.Fota_All_Data_Len + 4 - (Fota_S.Fota_All_Data_Len%4)); //512k-32k = 480k -> 0x75300 0x78000
|
|
|
}
|
|
|
memcpy(&Fota_Answer[4],(DataPtr+4),BATT_SN_LEN);
|
|
|
Fota_Answer[21] = TCP_ENCPT_DISABLE;
|
|
@@ -52,10 +55,6 @@ void Fota_Func(UINT8 *DataPtr,INT32 connectId)
|
|
|
memcpy(&Fota_Answer[24],(DataPtr+24),18);
|
|
|
Fota_Answer[42] = bcc_chk_fota(Fota_Answer,42);
|
|
|
tcpipConnectionSend(connectId,Fota_Answer,43,0,0,0);
|
|
|
- if(Fota_Answer[3] == 0x01)
|
|
|
- {
|
|
|
- BSP_QSPI_Erase_Safe(Fota_S.Fota_Flash_Addres,Fota_S.Fota_All_Data_Len + 4 - (Fota_S.Fota_All_Data_Len%4)); //512k-32k = 480k -> 0x75300 0x78000
|
|
|
- }
|
|
|
break;
|
|
|
}
|
|
|
case 0x02:
|
|
@@ -72,8 +71,21 @@ void Fota_Func(UINT8 *DataPtr,INT32 connectId)
|
|
|
{
|
|
|
Fota_S.Fota_Recv_Data_Len = Fota_S.Fota_Recv_Data_Len + 4-(Fota_S.Fota_Recv_Data_Len%4);
|
|
|
}
|
|
|
- ret = BSP_QSPI_Write_Safe(Fota_S.Fota_Recv_Data,Fota_S.Fota_Flash_Addres+Fota_S.Fota_Current_Addres,Fota_S.Fota_Recv_Data_Len);
|
|
|
- if(ret==QSPI_OK)
|
|
|
+ BSP_QSPI_Write_Safe(Fota_S.Fota_Recv_Data,Fota_S.Fota_Flash_Addres+Fota_S.Fota_Current_Addres,Fota_S.Fota_Recv_Data_Len);
|
|
|
+ Data_Read_Buffer = malloc(Fota_S.Fota_Recv_Data_Len);
|
|
|
+ BSP_QSPI_Read_Safe(Data_Read_Buffer,Fota_S.Fota_Flash_Addres+Fota_S.Fota_Current_Addres,Fota_S.Fota_Recv_Data_Len);
|
|
|
+ Data_Read_Crc = Fota_crc_chk(Data_Read_Buffer,Fota_S.Fota_Recv_Data_Len);
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("\n\n\n");
|
|
|
+ UINT8 temp[1];
|
|
|
+ for(int i=0;i<Fota_S.Fota_Recv_Data_Len;i++)
|
|
|
+ {
|
|
|
+ printf("%x ",*(Data_Read_Buffer+i));
|
|
|
+ }
|
|
|
+ printf("\n\n\n");
|
|
|
+ #endif
|
|
|
+ free(Data_Read_Buffer);
|
|
|
+ if(Data_Read_Crc==Fota_S.Fota_CRC )
|
|
|
{
|
|
|
Fota_Answer[3] = 0x01;
|
|
|
}
|
|
@@ -110,16 +122,6 @@ void Fota_Func(UINT8 *DataPtr,INT32 connectId)
|
|
|
if(Fota_S.Fota_All_Data_Len==Fota_S.Fota_Current_Addres)
|
|
|
{
|
|
|
NB_Fota_update_flag = TRUE;
|
|
|
- #ifdef USING_PRINTF
|
|
|
- printf("\n\n\n");
|
|
|
- UINT8 temp[1];
|
|
|
- for(int i=0;i<Fota_S.Fota_All_Data_Len;i++)
|
|
|
- {
|
|
|
- BSP_QSPI_Read_Safe(temp,FLASH_FOTA_REGION_START+i,1);
|
|
|
- printf("%x ",temp[0]);
|
|
|
- }
|
|
|
- printf("\nend data \n\n\n");
|
|
|
- #endif
|
|
|
}
|
|
|
else
|
|
|
{
|