Ver Fonte

版本号1.2.1.24,4830软件,Fota更新测试,更改了Fota回复逻辑,需要等到写入数据正常才回复正常,BMS升级文件写入也需要同步更改

CHENJIE-PC\QiXiang_CHENJIE há 3 anos atrás
pai
commit
654871080b
3 ficheiros alterados com 21 adições e 18 exclusões
  1. 1 1
      inc/app.h
  2. 18 16
      src/Fota.c
  3. 2 1
      src/TcpTask.c

+ 1 - 1
inc/app.h

@@ -34,7 +34,7 @@ extern "C" {
 #define HWVERSION		    0x0102    //硬件主版本,现为V1.2板
 #define	BLSWVERSION		0x01020000    //BootLoader版本号V1.2.0.0
 #define	DRVSWVERSION		0x01040000     //驱动层版本号V1.4.0.0
-#define	APPSWVERSION		0x01020117     
+#define	APPSWVERSION		0x01020118     
 
 //--------------------------------------------------------------------------------
 

+ 18 - 16
src/Fota.c

@@ -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
                 {

+ 2 - 1
src/TcpTask.c

@@ -725,9 +725,10 @@ static void socketAppConnectionCallBack(UINT8 connectionEventType, void *bodyEve
                 #ifdef USING_PRINTF
                     uint8_t* Ptr;
                     Ptr=rcvInd->data;
-                    printf("socketAppConnectionCallBack socket connection %u receive length %u data:", rcvInd->connectionId, rcvInd->length);
+                    printf("socket connection %u receive length %u data:", rcvInd->connectionId, rcvInd->length);
                     for(int i = 0;i<rcvInd->length;i++)
                         printf("%x  ",*(Ptr+i));
+                    printf("\n");
                 #endif
                 ECOMM_TRACE(UNILOG_PLA_APP, socketAppConnectionCallBack_5, P_INFO, 2, "socketAppConnectionCallBack socket connection %u receive length %u data", rcvInd->connectionId, rcvInd->length);
             }