Преглед изворни кода

2021-10-12 / Simon Xue

Action:
        1. Modify Update Function into Module Task.
Simon Xue пре 3 година
родитељ
комит
5ab9bed81e

+ 6 - 3
EVSE/Projects/DD360Audi/Apps/CSU/main.c

@@ -120,7 +120,7 @@ extern void SetIsCardScan(bool value);
 extern void SelfTestRun(void);
 
 //UpgradeFW.c
-extern void CheckFwUpdateFunction(void);
+/*extern void CheckFwUpdateFunction(void);*/
 
 //Ethernet.c
 extern void InitEthernet(void);
@@ -2672,6 +2672,7 @@ int SpawnTask(void)
     system("/root/Module_LcmControl &");
     system("/root/Module_InternalComm &");
     system("/root/Module_ProduceUtils &");
+    system("/root/Module_UpdateFW &");
 
 #if defined DD360 ||defined DD360Audi || defined DD360ComBox
     system("/root/Module_DoComm &");
@@ -2711,6 +2712,7 @@ void KillTask(void)
     system("killall Module_EvComm");
     system("killall Module_LcmControl");
     system("killall Module_InternalComm");
+    system("killall Module_UpdateFW");
     //system("killall Module_DoComm");
 #if defined DD360 || defined DD360Audi || defined DD360ComBox
     return ;
@@ -2747,6 +2749,7 @@ void KillAllTask(void)
     system("killall Module_EvComm");
     system("killall Module_LcmControl");
     system("killall Module_InternalComm");
+    system("killall Module_UpdateFW");
 
 #if defined DD360 || defined DD360Audi || defined DD360ComBox
     system("killall Module_DoComm");
@@ -3440,7 +3443,7 @@ void StopProcessingLoop()
 {
     for (;;) {
         CheckFactoryConfigFunction();
-        CheckFwUpdateFunction();
+        //CheckFwUpdateFunction();
         if (pSysWarning->Level == WARN_LV_ER) {
             ChkPrimaryStatus();
             if (pSysWarning->Level == WARN_LV_NL) {
@@ -4403,7 +4406,7 @@ int main(void)
            ) {
             CheckFactoryConfigFunction();
 
-            CheckFwUpdateFunction();
+            //CheckFwUpdateFunction();
         }
 
         // OCPP 邏輯

+ 17 - 1
EVSE/Projects/DD360Audi/Apps/Makefile

@@ -19,6 +19,7 @@ INC_FLAGS += -I $(TOP)/CSU
 INC_FLAGS += -I $(TOP)/DataBase
 INC_FLAGS += -I $(TOP)/ModuleInternalComm
 INC_FLAGS += -I $(TOP)/ModuleEvComm
+INC_FLAGS += -I $(TOP)/ModuleUpdateFW
 INC_FLAGS += -I $(TOP)/ModulePrimary
 INC_FLAGS += -I $(TOP)/ModuleLcmCtrl
 INC_FLAGS += -I $(TOP)/ModuleDoComm
@@ -31,6 +32,7 @@ CSULib = $(TOP)/CSU
 DataBaseLib = $(TOP)/DataBase
 InternalCommLib = $(TOP)/ModuleInternalComm
 EvCommLib = $(TOP)/ModuleEvComm
+UpdateFWLib = $(TOP)/ModuleUpdateFW
 PrimaryLib = $(TOP)/ModulePrimary
 LcmLib = $(TOP)/ModuleLcmCtrl
 DoCommLib = $(TOP)/ModuleDoComm
@@ -97,6 +99,12 @@ EVCOMM_SRC_FILES = $(patsubst %.o, %.c, $(EVCOMM_OBJ_FILES))
 %.o: %.c
 	$(CC) $(CFLAGS) -c $<
 
+#Update FW
+UPDATEFW_OBJ_FILES = $(COMMON_OBJ_FILES) $(UpdateFWLib)/Module_UpdateFW.o
+UPDATEFW_SRC_FILES = $(patsubst %.o, %.c, $(UPDATEFW_OBJ_FILES))
+%.o: %.c
+	$(CC) $(CFLAGS) -c $<
+
 #Event Log
 EVENTLOG_OBJ_FILES = $(COMMON_OBJ_FILES) $(DataBaseLib)/DataBase.o \
 						$(EventLogLib)/Module_EventLogging.o
@@ -123,7 +131,7 @@ READCMDLINE_SRC_FILES = $(patsubst %.o, %.c, $(READCMDLINE_OBJ_FILES))
 
 all: CopyFile apps
 
-apps: MainTask DoCommTask EvCommTask \
+apps: MainTask DoCommTask EvCommTask UpdateFWTask \
 		EventLoggingTask InternalCommTask LcmControlTask \
 			PrimaryCommTask ReadCmdlineTask UnsafetyOutputTool \
 				FactoryConfigApp OtherTools CleanExec
@@ -149,6 +157,11 @@ EvCommTask:
 	#$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Module_EvComm.o $(EvCommLib)/Module_EvComm.c
 	#$(CC) -o Module_EvComm Ev_Comm.o Module_EvComm.o $(Lib_Module_RatedCurrent)
 
+UpdateFWTask:
+	$(CC) $(DEFINE) $(UPDATEFW_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(Lib_Module_Upgrade) $(ModuleUpgrade_H) -o Module_UpdateFW
+	#$(CC) $(DEFINE) $(CFLAGS) -c -o Module_UpdateFW.o $(UpdateFWLib)/Module_UpdateFW.c
+	#$(CC) -o Module_UpdateFW Module_UpdateFW.o
+
 EventLoggingTask:
 	$(CC) $(DEFINE) $(EVENTLOG_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(SQLite3_H) $(Lib_SQLite3) -o Module_EventLogging
 	#$(CC) $(DEFINE) $(CFLAGS) -c -o define.o $(DefineLib)/define.c
@@ -204,6 +217,7 @@ OtherTools:
 	cp -f main $(RootPath)
 	cp -f Module_DoComm $(RootPath)
 	cp -f Module_EvComm $(RootPath)
+	cp -f Module_UpdateFW $(RootPath)
 	cp -f Module_EventLogging $(RootPath)
 	cp -f Module_InternalComm $(RootPath)
 	cp -f Module_LcmControl $(RootPath)
@@ -221,6 +235,7 @@ OtherTools:
 	cp -f main $(OutputPath)
 	cp -f Module_DoComm $(OutputPath)
 	cp -f Module_EvComm $(OutputPath)
+	cp -f Module_UpdateFW $(OutputPath)
 	cp -f Module_EventLogging $(OutputPath)
 	cp -f Module_InternalComm $(OutputPath)
 	cp -f Module_LcmControl $(OutputPath)
@@ -238,6 +253,7 @@ CleanExec:
 	rm -f *.o
 	rm main
 	rm Module_EvComm
+	rm Module_UpdateFW
 	rm Module_EventLogging
 	rm Module_InternalComm
 	rm Module_LcmControl

+ 509 - 0
EVSE/Projects/DD360Audi/Apps/ModuleUpdateFW/Module_UpdateFW.c

@@ -0,0 +1,509 @@
+#include <stdio.h>      /*標準輸入輸出定義*/
+#include <stdlib.h>     /*標準函數庫定義*/
+#include <string.h>
+#include <stdint.h>
+
+#include <sys/types.h>
+#include <dirent.h>
+
+#include "../Config.h"
+#include "../Log/log.h"
+#include "../Define/define.h"
+
+#include "../ShareMemory/shmMem.h"
+#include "../CSU/main.h"
+
+struct SysConfigData *pSysConfig = NULL;
+struct SysInfoData *pSysInfo = NULL;
+struct OCPP16Data *ShmOCPP16Data = NULL;
+struct ChargingInfoData *pAcChargingInfo = NULL;
+static struct ChargingInfoData *pDcChargingInfo = NULL;
+#define MODELNAME_FAIL                          (0)
+#define UPGRADE_FAN                             (0x02)
+#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#define UPGRADE_RB                              (0x09) //0x09 for DD360 dispenser
+#else
+#define UPGRADE_RB                              (0x03) //other module use
+#endif //defined DD360 ||defined DD360Audi || defined DD360ComBox
+#define UPGRADE_PRI                             (0x04)
+#define UPGRADE_AC                              (0x05)
+#define UPGRADE_LED                             (0x06)
+
+//------------------------------------------------------------------------------
+static char *_priPortName = "/dev/ttyS1";
+static char *_485PortName = "/dev/ttyS5";
+
+//------------------------------------------------------------------------------
+
+void KillAllTask(void)
+{
+    pSysInfo->PageIndex = _LCM_FIX;
+
+    system("killall Module_EventLogging");
+    system("killall Module_PrimaryComm");
+    system("killall Module_EvComm");
+    system("killall Module_LcmControl");
+    system("killall Module_InternalComm");
+
+#if defined DD360 || defined DD360Audi || defined DD360ComBox
+    system("killall Module_DoComm");
+    return ;
+#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+
+    system("killall Module_PsuComm");
+    system("killall OcppBackend &");
+    system("killall Module_4g &");
+    system("killall Module_Wifi &");
+}
+
+void KillTask(void)
+{
+    pSysInfo->PageIndex = _LCM_FIX;
+
+    system("killall Module_EventLogging");
+    system("killall Module_PrimaryComm");
+    system("killall Module_EvComm");
+    system("killall Module_LcmControl");
+    system("killall Module_InternalComm");
+    //system("killall Module_DoComm");
+#if defined DD360 || defined DD360Audi || defined DD360ComBox
+    return ;
+#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+
+    system("killall Module_PsuComm");
+    system("killall OcppBackend &");
+    system("killall Module_4g &");
+    system("killall Module_Wifi &");
+}
+void setChargerMode(uint8_t gunIndex, uint8_t mode)
+{
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
+
+    pDcChargingInfo->SystemStatus = mode;
+}
+void TryCloseWatchdog()
+{
+    system("echo V > /dev/watchdog");
+}
+static int InitComPort(uint8_t target)
+{
+    int fd;
+    struct termios tios;
+
+    if (target == UPGRADE_PRI) {
+        fd = open(_priPortName, O_RDWR);
+    } else if (target == UPGRADE_FAN ||
+               target == UPGRADE_RB ||
+               target == UPGRADE_AC ||
+               target == UPGRADE_LED
+              ) {
+        fd = open(_485PortName, O_RDWR);
+    }
+
+    if (fd <= 0) {
+        log_error("open 407 Communication port NG \n");
+        return -1;
+    }
+
+    ioctl (fd, TCGETS, &tios);
+    tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
+    tios.c_lflag = 0;
+    tios.c_iflag = 0;
+    tios.c_oflag = 0;
+    tios.c_cc[VMIN] = 0;
+    tios.c_cc[VTIME] = (uint8_t)1;
+    tios.c_lflag = 0;
+    tcflush(fd, TCIFLUSH);
+    ioctl (fd, TCSETS, &tios);
+
+    return fd;
+}
+bool IsConnectorWholeIdle()
+{
+    bool result = true;
+
+    for (uint8_t count = 0; count < pSysConfig->TotalConnectorCount; count++) {
+        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(count);
+
+        if (pDcChargingInfo->SystemStatus != S_IDLE &&
+                pDcChargingInfo->SystemStatus != S_RESERVATION) {
+            result = false;
+            break;
+        }
+    }
+
+    for (uint8_t count = 0; count < pSysConfig->AcConnectorCount; count++) {
+        pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(count);
+
+        if (pAcChargingInfo->SystemStatus != S_IDLE &&
+                pAcChargingInfo->IsErrorOccur == NO) {
+            result = false;
+            break;
+        }
+    }
+
+    return result;
+}
+
+
+static int InitCanBus(void)
+{
+    int fd = -1;
+    int nbytes;
+    struct timeval tv;
+    struct ifreq ifr0;
+    struct sockaddr_can addr0;
+
+    system("/sbin/ip link set can0 down");
+    system("/sbin/ip link set can0 type can bitrate 500000 restart-ms 100");
+    system("/sbin/ip link set can0 up");
+
+    fd = socket(PF_CAN, SOCK_RAW, CAN_RAW);
+
+    tv.tv_sec = 0;
+    tv.tv_usec = 10000;
+    if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct  timeval)) < 0) {
+        log_error("Set SO_RCVTIMEO NG");
+    }
+    nbytes = 40960;
+    if (setsockopt(fd, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
+        log_error("Set SO_RCVBUF NG");
+    }
+    nbytes = 40960;
+    if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
+        log_error("Set SO_SNDBUF NG");
+    }
+
+    strcpy(ifr0.ifr_name, "can0");
+    ioctl(fd, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
+    addr0.can_family = AF_CAN;
+    addr0.can_ifindex = ifr0.ifr_ifindex;
+    bind(fd, (struct sockaddr *)&addr0, sizeof(addr0));
+
+    return fd;
+}
+
+static int CheckUpdateProcess(void)
+{
+    //bool isPass = true;
+    uint8_t retSucc = 0;
+    uint8_t retFail = 0;
+    uint8_t index = 0;
+    uint8_t target = 0;
+    char Buf[256];
+    char *new_str = NULL;
+    uint8_t *ptr = NULL;
+    int fd = 0;
+    int CanFd = 0;
+    int uartFd = 0;
+    unsigned int Type = 0;
+    long int MaxLen = 48 * 1024 * 1024, ImageLen = 0;
+    DIR *d;
+    struct dirent *dir;
+    DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
+    struct ChargingInfoData *pDcChargingInfo = NULL;
+
+    pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
+    d = opendir("/mnt/");
+    if (d) {
+        while ((dir = readdir(d)) != NULL) {
+            if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) {
+                continue;
+            }
+
+            new_str = calloc(strlen("/mnt/") + strlen(dir->d_name) + 1, sizeof(char));
+            //new_str[0] = '\0';
+            strcat(new_str, "/mnt/");
+            strcat(new_str, dir->d_name);
+            log_info("%s%s\r\n", "/mnt/", dir->d_name);
+            
+            fd = open(new_str, O_RDONLY);
+            if (fd < 0) {
+                return FAIL;
+            }
+
+            ptr = calloc(MaxLen, sizeof(char)); //-48 is take out the header
+            //memset(ptr, 0xFF, MaxLen);  //-48 is take out the header
+
+            //get the image length
+            ImageLen = read(fd, ptr, MaxLen);
+            for (uint8_t i = 0; i < 16; i++) {
+                if (pSysConfig->ModelName[i] != ptr[i]) {
+                    return FAIL;
+                }
+            }
+
+            log_info("model name check pass. \n");
+            if (ImageLen > 20) {
+                Type = (((unsigned int)ptr[16]) << 24 |
+                        ((unsigned int)ptr[17]) << 16 |
+                        ((unsigned int)ptr[18]) << 8  |
+                        ((unsigned int)ptr[19]));
+                log_info("Typed...%x \r\n", Type);
+
+                switch (Type) {
+                case 0x10000001:
+                case 0x10000002:
+                case 0x10000003:
+                case 0x10000004:
+                case 0x10000005:
+                    if (Upgrade_Flash(Type, new_str, (char *)pSysConfig->ModelName) == PASS) {
+                        //return PASS;
+                        retSucc++;
+                    } else {
+                        log_info("Upgrade %x Failed\r\n", Type);
+                        //return FAIL;
+                        retFail++;
+                    }
+                    break;
+
+                case 0x10000007:
+                case 0x10000008:
+                case 0x10000009:
+                case 0x1000000A:
+                    CanFd = InitCanBus();
+                    if (CanFd > 0) {
+                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
+                            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
+
+                            if (pDcChargingInfo->Type == _Type_CCS_2) {
+                                uint8_t targetID = pDcChargingInfo->Evboard_id;
+
+                                if (pSysConfig->TotalConnectorCount == 1 &&
+                                        ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
+                                    //targetID += 1;
+                                }
+
+                                system("echo 3 > /proc/sys/vm/drop_caches");
+                                sleep(2);
+                                log_info("Upgrade CCS Processing..target id = %d \n", targetID);
+                                if (Upgrade_CCS(CanFd,
+                                                Type,
+                                                targetID,
+                                                new_str,
+                                                (char *)pSysConfig->ModelName) == FAIL) {
+                                    log_info("Upgrade CCS Failed \n");
+                                    retFail++;
+                                } else {
+                                    retSucc++;
+                                }
+                            }
+                        }
+                        close(CanFd);
+                    }
+                    memset(Buf, 0, sizeof(Buf));
+                    sprintf(Buf, "rm -rvf /mnt/%s", new_str);
+                    system(Buf);
+                    //isPass = true;
+#if 0
+                    CanFd = InitCanBus();
+                    if (CanFd > 0) {
+                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
+                            //if (!isPass) {
+                            //    break;
+                            //}
+                            if (chargingInfo[index]->Type == _Type_CCS_2) {
+                                if (Upgrade_CCS(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, (char *)pSysConfig->ModelName) == FAIL) {
+                                    //isPass = false;
+                                    log_info("Upgrade %x Failed\r\n", Type);
+                                    retFail++;
+                                }
+                            }
+                        }
+                    } else {
+                        log_error("Upgrade CCS open CAN FD fail.\n");
+                        //isPass = false;
+                        return FAIL;
+                    }
+
+                    if (retFail != 0) {
+                        break;
+                    } else {
+                        retSucc++;
+                    }
+                    //return isPass;
+#endif //0
+                    break;
+
+                case 0x10000006:
+                case 0x1000000D:
+                case 0x1000000E:
+                case 0x20000002:
+                case 0x10000014:
+                    // CSU_PRIMARY_CONTROLLER : 0x10000006
+                    target = 0x00;
+
+                    if (Type == 0x10000006) {
+                        target = UPGRADE_PRI;
+                    } else if (Type == 0x1000000D) {
+                        target = UPGRADE_RB;
+                    } else if (Type == 0x1000000E) {
+                        target = UPGRADE_FAN;
+                    } else if (Type == 0x20000002) {
+                        target = UPGRADE_AC;
+                    } else if (Type == 0x10000014) {
+                        target = UPGRADE_LED;
+                    }
+
+                    uartFd = InitComPort(target);
+
+                    if (Upgrade_UART(uartFd, Type, target, new_str, (char *)pSysConfig->ModelName) == PASS) {
+                        //return PASS;
+                        retSucc++;
+                    } else {
+                        log_info("Upgrade %x Failed\r\n", Type);
+                        //return FAIL;
+                        return FAIL;
+                    }
+
+                    if (uartFd > 0) {
+                        close(uartFd);
+                    }
+                    break;
+
+                case 0x1000000B:
+                case 0x1000000C:
+                    // CHAdeMO_BOARD : 0x1000000B, GBT : 0x1000000C
+                    //bool isPass = true;
+                    CanFd = InitCanBus();
+                    if (CanFd > 0) {
+                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
+                            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
+
+                            //if (!isPass) {
+                            //    break;
+                            //}
+
+                            if ((Type == 0x1000000B && pDcChargingInfo->Type == _Type_Chademo) ||
+                                    (Type == 0x1000000C && pDcChargingInfo->Type == _Type_GB)) {
+                                if (Upgrade_CAN(CanFd, Type, pDcChargingInfo->Evboard_id, new_str, (char *)pSysConfig->ModelName) == PASS) {
+                                    //isPass = PASS;
+                                    retSucc++;
+                                } else {
+                                    log_info("Upgrade %x Failed\r\n", Type);
+                                    //isPass = FAIL;
+                                    retFail++;
+                                }
+                            }
+                        }
+                    } else {
+                        log_info("Upgrad FD fail. \n");
+                        //isPass = false;
+                        return FAIL;
+                    }
+
+                    //return isPass;
+                    break;
+                }
+            }
+            free(new_str);
+            free(ptr);
+        }
+    }
+    free(dir);
+    closedir(d);
+
+    if (retFail != 0) {
+        return FAIL;
+    }
+
+    return PASS;
+}
+
+void CheckFwUpdateFunction(void)
+{
+    log_info("pSysInfo->FirmwareUpdate = %d \n", pSysInfo->FirmwareUpdate);
+    if (pSysInfo->FirmwareUpdate == YES) {
+        log_info("ftp : update start. \n");
+        TryCloseWatchdog();
+
+        for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
+            setChargerMode(gun_index, MODE_UPDATE);
+        }
+        sleep(1);
+        uint8_t updateResult = CheckUpdateProcess();
+
+        if (updateResult == PASS) {
+            log_info("ftp : update complete. \n");
+        } else if (updateResult == MODELNAME_FAIL) {
+            log_info("ftp : model name is none match. \n");
+            KillAllTask();
+            pSysInfo->FirmwareUpdate = NO;
+            sleep(5);
+            system("/usr/bin/run_evse_restart.sh");
+            return;
+        } else {
+            log_info("ftp : update fail. \n");
+        }
+
+        pSysInfo->FirmwareUpdate = NO;
+        sleep(5);
+        system("reboot -f");
+    } else if (ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq == YES) {
+        ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = NO;
+
+        if (strcmp((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Downloaded") == EQUAL) {
+            log_info("Backend : update start. \n");
+            TryCloseWatchdog();
+            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "");
+            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installing");
+            ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
+            KillTask();
+
+            for (uint8_t _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
+                setChargerMode(_index, MODE_UPDATE);
+            }
+
+            for (uint8_t _index = 0; _index < pSysConfig->AcConnectorCount; _index++) {
+                pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(_index);
+
+                pAcChargingInfo->SystemStatus = MODE_UPDATE;
+            }
+            sleep(1);
+
+            uint8_t updateResult = CheckUpdateProcess();
+
+            if (updateResult == PASS) {
+                log_info("Backend : update complete. \n");
+                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
+            } else if (updateResult == MODELNAME_FAIL) {
+                log_info("Backend : model name is none match. \n");
+                KillAllTask();
+                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
+                ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
+                sleep(5);
+                system("/usr/bin/run_evse_restart.sh");
+                return;
+            } else {
+                log_info("Backend : update fail. \n");
+                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
+            }
+
+            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
+            ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
+            sleep(5);
+            system("reboot -f");
+        }
+    }
+}
+
+int main(int argc, char *argv[])
+{
+    if (CreateAllCsuShareMemory() == FAIL) {
+        log_error("create share memory error\r\n");
+        return FAIL;
+    }
+    
+    MappingGunChargingInfo("Upgrade Task");
+
+    pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
+    pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
+    ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
+   
+    while (1) {
+        if (IsConnectorWholeIdle() || (pSysInfo->PageIndex == _LCM_FIX) )
+            CheckFwUpdateFunction();
+        sleep(3);
+    } //while
+    return 0;
+}

+ 2 - 0
EVSE/Projects/DD360Audi/Apps/Script/init.sh

@@ -5,6 +5,8 @@ chmod 777 Module_InternalComm
 chmod 777 Module_EventLogging
 chmod 777 Module_EvComm
 chmod 777 Module_PsuComm
+chmod 777 Module_UpdateFW
+chmod 777 Module_ChkSysTask
 chmod 777 OcppBackend
 chmod 777 kill.sh
 chmod 777 ReadCmdline

+ 2 - 0
EVSE/Projects/DD360Audi/Apps/Script/kill.sh

@@ -5,6 +5,8 @@ pkill Module_InternalComm;
 pkill Module_EventLogging;
 pkill Module_EvComm;
 pkill Module_PsuComm;
+pkill Module_UpdateFW;
+pkill Module_ChkSysTask;
 pkill Module_4g;
 pkill Module_Wifi;
 pkill OcppBackend;

BIN
EVSE/Projects/DD360Audi/Images/ramdisk.gz


BIN
EVSE/Projects/DD360Audi/output/Module_UpdateFW


+ 2 - 0
EVSE/Projects/DD360Audi/output/init.sh

@@ -5,6 +5,8 @@ chmod 777 Module_InternalComm
 chmod 777 Module_EventLogging
 chmod 777 Module_EvComm
 chmod 777 Module_PsuComm
+chmod 777 Module_UpdateFW
+chmod 777 Module_ChkSysTask
 chmod 777 OcppBackend
 chmod 777 kill.sh
 chmod 777 ReadCmdline

+ 2 - 0
EVSE/Projects/DD360Audi/output/kill.sh

@@ -5,6 +5,8 @@ pkill Module_InternalComm;
 pkill Module_EventLogging;
 pkill Module_EvComm;
 pkill Module_PsuComm;
+pkill Module_UpdateFW;
+pkill Module_ChkSysTask;
 pkill Module_4g;
 pkill Module_Wifi;
 pkill OcppBackend;

BIN
EVSE/Projects/DD360Audi/output/main


+ 11 - 0
build_rootfs_copy.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+sudo rm /dev/ram*
+sleep 3
+rm /mnt/e/Temp/IMAGE/*
+sudo make DD360Audi-rootfs
+cp /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360Audi/Images/* /mnt/e/Image/DD360Audi/
+#sudo make DD360-rootfs
+#cp /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360/Images/* /mnt/e/Image/DD360/
+#sudo make DD360ComBox-rootfs
+#cp /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360ComBox/Images/* /mnt/e/Image/DD360ComBox/
+