Browse Source

2020-10-08 / Eason Yang
Action
1. Improve : All debug info ouput format alignment
2. Added : Cusomization configuration item
3. Improve : Flash operation method changed to nandwrite & nanddump tools
4. Improve : Default Ocpp Configuration
5. Improve : Initialization() function for initial DB, InitRfidPort & InitWatchDog
6. Improve : CheckTask() function for wifi + 4g model
7. Rename : Version
8. Added : Module_Debug.c
9. Added : Module_ConfigTools.c
10. Improve : Include Module_Debug & Module_ConfigTools into Makefile
11. Improve : spwan() function for wifi + 4g model

File
1.main.c
Action1
Action3
Action4
Action5
Action6
Action7
Action8

2.Module_AlarmDetect.c
Action1

3.Module_FactoryConfig.c
Action1
Action2
Action3

4.Module_InternalComm.c
Action1

5.Module_Speaker.c
Action1

6.AW-Reqular Project
Action 8
Action 9

7.Makefile
Action

Version : V0.59.XX.XXXX.XX

8009 4 years ago
parent
commit
708aa64d73

+ 21 - 2
EVSE/Projects/AW-Regular/Apps/Makefile

@@ -7,8 +7,27 @@ Lib_Module_Upgrade = "-L../../../Modularization" -lModule_Upgrade
 Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
 
 all: CopyFile apps
-apps: Module_InternalComm_Task Module_FactoryConfig_Task Module_AlarmDetect_Task Module_CSU_Task Module_Speaker_Task
+apps: Module_InternalComm_Task Module_FactoryConfig_Task Module_AlarmDetect_Task Module_CSU_Task Module_Speaker_Task Module_ConfigTools_Task Module_Debug_Task
 
+Module_ConfigTools_Task:
+	@echo "===== Module_ConfigTools_Task  ==================================="
+	rm -f Module_ConfigTools
+	rm -f Module_InternalComm
+	$(CC) -D $(Project) "-I../../" -O0 -g3 -Wall -c -fmessage-length=0 -o Module_ConfigTools.o "./Module_ConfigTools.c"
+	$(CC) -o Module_ConfigTools Module_ConfigTools.o
+	rm -f *.o
+	mv -f Module_ConfigTools ../Images/root
+	@echo \
+
+Module_Debug_Task:
+	@echo "===== Module_Debug_Task  ==================================="
+	rm -f Module_Debug
+	rm -f Module_Debug
+	$(CC) -D $(Project) "-I../../" -O0 -g3 -Wall -c -fmessage-length=0 -o Module_Debug.o "./Module_Debug.c"
+	$(CC) -o Module_Debug Module_Debug.o
+	rm -f *.o
+	mv -f Module_Debug ../Images/root
+	@echo \
 
 Module_InternalComm_Task:
 	@echo "===== Module_InternalComm_Task ==================================="
@@ -61,7 +80,7 @@ Module_CSU_Task:
 	@echo \
 
 Module_Speaker_Task:
-	@echo "===== Module_Speaker_Task ===================================="
+	@echo "===== Module_Speaker_Task ======================================="
 	rm -f Module_Speaker
 	$(CC) -D $(Project) "-I../../"  -O0 -g3 -Wall -c -fmessage-length=0 -o Module_Speaker.o  "./Module_Speaker.c"
 	$(CC) -o Module_Speaker Module_Speaker.o 

+ 7 - 5
EVSE/Projects/AW-Regular/Apps/Module_AlarmDetect.c

@@ -80,6 +80,7 @@ int StoreLogMsg(const char *fmt, ...)
 	char buffer[4096];
 	time_t CurrentTime;
 	struct tm *tm;
+	struct timeval tv;
 	va_list args;
 
 	va_start(args, fmt);
@@ -89,11 +90,12 @@ int StoreLogMsg(const char *fmt, ...)
 	memset(Buf,0,sizeof(Buf));
 	CurrentTime = time(NULL);
 	tm=localtime(&CurrentTime);
+	gettimeofday(&tv, NULL); // get microseconds, 10^-6
 
 	if((ShmSysConfigAndInfo->SysConfig.ModelName != NULL) && (ShmSysConfigAndInfo->SysConfig.SerialNumber != NULL) && (strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) >= 14))
 	{
-		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]%s_%s_SystemLog",
-					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/SystemLog/[%04d.%02d]%s_%s_SystemLog",
+					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
 					buffer,
 					tm->tm_year+1900,tm->tm_mon+1,
 					ShmSysConfigAndInfo->SysConfig.ModelName,
@@ -101,8 +103,8 @@ int StoreLogMsg(const char *fmt, ...)
 	}
 	else
 	{
-		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
+					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
 					buffer,
 					tm->tm_year+1900,tm->tm_mon+1);
 	}
@@ -112,7 +114,7 @@ int StoreLogMsg(const char *fmt, ...)
 #endif
 
 #ifdef ConsloePrintLog
-	printf("[%04d.%02d.%02d %02d:%02d:%02d] - %s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec, buffer);
+	printf("[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec, buffer);
 #endif
 
 	return rc;

+ 100 - 97
EVSE/Projects/AW-Regular/Apps/Module_FactoryConfig.c

@@ -57,6 +57,7 @@ int StoreLogMsg(const char *fmt, ...)
 	char buffer[4096];
 	time_t CurrentTime;
 	struct tm *tm;
+	struct timeval tv;
 	va_list args;
 
 	va_start(args, fmt);
@@ -66,17 +67,32 @@ int StoreLogMsg(const char *fmt, ...)
 	memset(Buf,0,sizeof(Buf));
 	CurrentTime = time(NULL);
 	tm=localtime(&CurrentTime);
-	sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/%04d-%02d_%s_%s_SystemLog",
-			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
-			buffer,
-			tm->tm_year+1900,tm->tm_mon+1,
-			SysConfig.ModelName,
-			SysConfig.SerialNumber);
+	gettimeofday(&tv, NULL); // get microseconds, 10^-6
+
+	if((ShmSysConfigAndInfo->SysConfig.ModelName != NULL) && (ShmSysConfigAndInfo->SysConfig.SerialNumber != NULL) && (strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) >= 14))
+	{
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]-%s\" >> /Storage/SystemLog/[%04d.%02d]%s_%s_SystemLog",
+					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
+					buffer,
+					tm->tm_year+1900,tm->tm_mon+1,
+					ShmSysConfigAndInfo->SysConfig.ModelName,
+					ShmSysConfigAndInfo->SysConfig.SerialNumber);
+	}
+	else
+	{
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]-%s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
+					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
+					buffer,
+					tm->tm_year+1900,tm->tm_mon+1);
+	}
+
 #ifdef SystemLogMessage
 	system(Buf);
 #endif
 
-	printf("[%04d.%02d.%02d %02d:%02d:%02d] - %s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec, buffer);
+#ifdef ConsloePrintLog
+	printf("[%04d.%02d.%02d %02d:%02d:%02d.%06ld] - %s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec, buffer);
+#endif
 
 	return rc;
 }
@@ -145,6 +161,26 @@ void split(char **arr, char *str, const char *del)
 	}
 }
 
+int runShellCmd(const char*cmd)
+{
+	int result = FAIL;
+	char buf[256];
+	FILE *fp;
+
+	fp = popen(cmd, "r");
+	if(fp != NULL)
+	{
+		while(fgets(buf, sizeof(buf), fp) != NULL)
+		{
+			DEBUG_INFO("%s\n", buf);
+		}
+
+		result = PASS;
+	}
+	pclose(fp);
+
+	return result;
+}
 
 //==========================================
 // Init all share memory
@@ -191,12 +227,12 @@ int InitShareMemory()
 
 void helpOutput(void)
 {
-	printf("Usage: Module_FactoryConfig [OPTION]...\r\n\r\n");
-	printf("Generate factory default configuration value\r\n\r\n");
-	printf("OPTION:\r\n");
-	printf("	-a Write to file(/mnt) & flash\r\n");
-	printf("	-f Write to file(/mnt)\r\n");
-	printf("	-m Write to flash\r\n");
+	printf("Usage: Module_FactoryConfig [OPTION]...\n\n");
+	printf("Generate factory default configuration value\n\n");
+	printf("OPTION:\n");
+	printf("	-a Write to file(/mnt) & flash\n");
+	printf("	-f Write to file(/mnt)\n");
+	printf("	-m Write to flash\n");
 }
 
 //================================================
@@ -232,16 +268,16 @@ int main(int argc, char *argv[])
 	{
 		DEBUG_ERROR("InitShareMemory NG\n");
 
-		strcpy((char*)SysConfig.ModelName,"");
-		strcpy((char*)SysConfig.SerialNumber,"");
+		strcpy((char*)SysConfig.ModelName, "");
+		strcpy((char*)SysConfig.SerialNumber, "");
 		sleep(5);
 	}
 	else
 	{
-		memcpy((char*)SysConfig.ModelName,ShmSysConfigAndInfo->SysConfig.ModelName,ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ModelName));
-		memcpy((char*)SysConfig.SerialNumber,ShmSysConfigAndInfo->SysConfig.SerialNumber,ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SerialNumber));
+		memcpy((char*)SysConfig.ModelName, ShmSysConfigAndInfo->SysConfig.ModelName, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ModelName));
+		memcpy((char*)SysConfig.SerialNumber, ShmSysConfigAndInfo->SysConfig.SerialNumber, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SerialNumber));
 
-		DEBUG_INFO("InitShareMemory OK.\r\n");
+		DEBUG_INFO("InitShareMemory OK.\n");
 	}
 	
 	sprintf((char*)SysConfig.SystemId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
@@ -280,14 +316,25 @@ int main(int argc, char *argv[])
 	SysConfig.TelecomInterface.TelcomModemMode = 0;	//0: No services	1: CDMA		2: GSM/GPRS	3: WCDMA	4: GSM/WCDMA	5: TD_SCDMA		6: Unknown
 
 	// Backend configuration
+	strcpy((char*)SysConfig.OcppServerURL, "");
+	sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 	SysConfig.BackendConnTimeout=300; 		// 300 seconds
 	SysConfig.OfflinePolicy = 2;			// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
 	SysConfig.OfflineMaxChargeEnergy = 0;	// 0: Same as MaxChargeEnergy	Other: 1~65535KWH
 	SysConfig.OfflineMaxChargeDuration = 0; // 0: Same as MaxChargeDuration Other: 1~65535 minutes
-	strcpy((char*)SysConfig.OcppServerURL, "");
-	sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 
 
+	// Customization configuration item
+	if(strstr((char*)&SysConfig.ModelName[12], "P0") != NULL)
+	{
+		strcpy((char*)SysConfig.OcppServerURL, "");
+		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
+	}
+	else
+	{
+
+	}
+
 	// Copy default configuration to pointer
 	memcpy(ptr,&SysConfig,sizeof(struct SysConfigData));
 
@@ -297,7 +344,7 @@ int main(int argc, char *argv[])
 	{
 		Chk+=*(ptr+i);
 	}
-	memcpy(	ptr+MtdBlockSize-4,&Chk,4);
+	memcpy(ptr+MtdBlockSize-4, &Chk, 4);
 
 	/*
 	 * Parameter process
@@ -338,98 +385,54 @@ int main(int argc, char *argv[])
 	/*
 	 * Configuration bin file generate
 	 */
-	if((outType&OUTPUT_FILE)>0)
+	// Save factory default setting value to file
+	fd = open("/mnt/FactoryDefaultConfig.bin", O_RDWR|O_CREAT);
+	if (fd < 0)
 	{
-		// Save factory default setting value to file
-		fd = open("/mnt/FactoryDefaultConfig.bin", O_RDWR|O_CREAT);
-		if (fd < 0)
-		{
 
-			DEBUG_ERROR("open /mnt/FactoryDefaultConfig.bin NG\r\n");
+		DEBUG_ERROR("open /mnt/FactoryDefaultConfig.bin NG\n");
 
-			free(ptr);
-			return 0;
-		}
-		wrd=write(fd, ptr, MtdBlockSize);
-		close(fd);
-		if(wrd<MtdBlockSize)
-		{
-			DEBUG_ERROR("write /mnt/FactoryDefaultConfig.bin NG\r\n");
-
-			free(ptr);
-			return 0;
-		}
+		free(ptr);
+		return 0;
+	}
+	wrd=write(fd, ptr, MtdBlockSize);
+	close(fd);
+	if(wrd<MtdBlockSize)
+	{
+		DEBUG_ERROR("write /mnt/FactoryDefaultConfig.bin NG\n");
 
-		DEBUG_INFO("FactoryConfig write to file in /mnt OK.\r\n");
+		free(ptr);
+		return 0;
 	}
 
+	DEBUG_INFO("FactoryConfig write to file in /mnt OK.\n");
+
+
 	/*
 	 * Flash memory write
 	 */
 	if((outType&OUTPUT_FLASH)>0)
 	{
-		// Save factory default setting value to flash factory default setting block
-		fd = open("/dev/mtdblock12", O_RDWR);
-		if (fd < 0)
-		{
+		DEBUG_INFO("Erase /dev/mtd10.\n");
+		runShellCmd("flash_erase /dev/mtd10 0 12");
+		DEBUG_INFO("Write /dev/mtd10.\n");
+		runShellCmd("nandwrite -p /dev/mtd10 /mnt/FactoryDefaultConfig.bin");
 
-			DEBUG_ERROR("open /dev/mtdblock12 NG\r\n");
+		DEBUG_INFO("Erase /dev/mtd11.\n");
+		runShellCmd("flash_erase /dev/mtd11 0 12");
+		DEBUG_INFO("Write /dev/mtd11.\n");
+		runShellCmd("nandwrite -p /dev/mtd11 /mnt/FactoryDefaultConfig.bin");
 
-			free(ptr);
-			return 0;
-		}
-		wrd=write(fd, ptr, MtdBlockSize);
-		close(fd);
-		if(wrd<MtdBlockSize)
-		{
-			DEBUG_ERROR("write /dev/mtdblock12 NG\r\n");
+		DEBUG_INFO("Erase /dev/mtd12.\n");
+		runShellCmd("flash_erase /dev/mtd12 0 12");
+		DEBUG_INFO("Write /dev/mtd12.\n");
+		runShellCmd("nandwrite -p /dev/mtd12 /mnt/FactoryDefaultConfig.bin");
 
-			free(ptr);
-			return 0;
-		}
+		system("rm -f /mnt/FactoryDefaultConfig.bin");
 
-		// Save factory default setting value to flash backup setting block
-		fd = open("/dev/mtdblock11", O_RDWR);
-		if (fd < 0)
-		{
-			DEBUG_ERROR("open /dev/mtdblock11 NG\r\n");
-
-			free(ptr);
-			return 0;
-		}
-		wrd=write(fd, ptr, MtdBlockSize);
-		close(fd);
-		if(wrd<MtdBlockSize)
-		{
-			DEBUG_ERROR("write /dev/mtdblock11 NG\r\n");
-
-			free(ptr);
-			return 0;
-		}
-
-		// Save factory default setting value to flash setting block
-		fd = open("/dev/mtdblock10", O_RDWR);
-		if (fd < 0)
-		{
-			DEBUG_ERROR("open /dev/mtdblock10 NG\r\n");
-
-			free(ptr);
-			return 0;
-		}
-		wrd=write(fd, ptr, MtdBlockSize);
-		close(fd);
-		if(wrd<MtdBlockSize)
-		{
-			DEBUG_ERROR("write /dev/mtdblock10 NG\r\n");
-
-			free(ptr);
-			return 0;
-		}
-
-		DEBUG_INFO("FactoryConfig write to flash OK\r\n");
+		DEBUG_INFO("FactoryConfig write to flash OK\n");
 	}
-
 	free(ptr);
 
-	return FAIL;
+	return PASS;
 }

+ 9 - 19
EVSE/Projects/AW-Regular/Apps/Module_InternalComm.c

@@ -67,6 +67,7 @@ int StoreLogMsg(const char *fmt, ...)
 	char buffer[4096];
 	time_t CurrentTime;
 	struct tm *tm;
+	struct timeval tv;
 	va_list args;
 
 	va_start(args, fmt);
@@ -76,30 +77,19 @@ int StoreLogMsg(const char *fmt, ...)
 	memset(Buf,0,sizeof(Buf));
 	CurrentTime = time(NULL);
 	tm=localtime(&CurrentTime);
+	gettimeofday(&tv, NULL); // get microseconds, 10^-6
 
-	if((ShmSysConfigAndInfo->SysConfig.ModelName != NULL) && (ShmSysConfigAndInfo->SysConfig.SerialNumber != NULL) && (strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) >= 14))
-	{
-		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]%s_%s_SystemLog",
-					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
-					buffer,
-					tm->tm_year+1900,tm->tm_mon+1,
-					ShmSysConfigAndInfo->SysConfig.ModelName,
-					ShmSysConfigAndInfo->SysConfig.SerialNumber);
-	}
-	else
-	{
-		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
-					buffer,
-					tm->tm_year+1900,tm->tm_mon+1);
-	}
+	sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/SystemLog/[%04d.%02d]Module_InterComm",
+				tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
+				buffer,
+				tm->tm_year+1900,tm->tm_mon+1);
 
 #ifdef SystemLogMessage
 	system(Buf);
 #endif
 
 #ifdef ConsloePrintLog
-	printf("[%04d.%02d.%02d %02d:%02d:%02d] - %s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec, buffer);
+	printf("[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec, buffer);
 #endif
 
 	return rc;
@@ -2619,8 +2609,6 @@ int main(void)
 					}
 					else
 					{}
-
-					usleep(100000);
 				}
 			}
 			stepIndex++;
@@ -2649,6 +2637,8 @@ int main(void)
 					ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.comm_timeout = OFF;
 				}
 			}
+
+			usleep(100000);
 		}
 	}
 

+ 7 - 5
EVSE/Projects/AW-Regular/Apps/Module_Speaker.c

@@ -70,6 +70,7 @@ int StoreLogMsg(const char *fmt, ...)
 	char buffer[4096];
 	time_t CurrentTime;
 	struct tm *tm;
+	struct timeval tv;
 	va_list args;
 
 	va_start(args, fmt);
@@ -79,11 +80,12 @@ int StoreLogMsg(const char *fmt, ...)
 	memset(Buf,0,sizeof(Buf));
 	CurrentTime = time(NULL);
 	tm=localtime(&CurrentTime);
+	gettimeofday(&tv, NULL); // get microseconds, 10^-6
 
 	if((ShmSysConfigAndInfo->SysConfig.ModelName != NULL) && (ShmSysConfigAndInfo->SysConfig.SerialNumber != NULL) && (strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) >= 14))
 	{
-		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]%s_%s_SystemLog",
-					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/SystemLog/[%04d.%02d]%s_%s_SystemLog",
+					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
 					buffer,
 					tm->tm_year+1900,tm->tm_mon+1,
 					ShmSysConfigAndInfo->SysConfig.ModelName,
@@ -91,8 +93,8 @@ int StoreLogMsg(const char *fmt, ...)
 	}
 	else
 	{
-		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
+					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
 					buffer,
 					tm->tm_year+1900,tm->tm_mon+1);
 	}
@@ -102,7 +104,7 @@ int StoreLogMsg(const char *fmt, ...)
 #endif
 
 #ifdef ConsloePrintLog
-	printf("[%04d.%02d.%02d %02d:%02d:%02d] - %s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec, buffer);
+	printf("[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec, buffer);
 #endif
 
 	return rc;

+ 127 - 132
EVSE/Projects/AW-Regular/Apps/main.c

@@ -145,6 +145,7 @@ int StoreLogMsg(const char *fmt, ...)
 	char buffer[4096];
 	time_t CurrentTime;
 	struct tm *tm;
+	struct timeval tv;
 	va_list args;
 
 	va_start(args, fmt);
@@ -154,11 +155,12 @@ int StoreLogMsg(const char *fmt, ...)
 	memset(Buf,0,sizeof(Buf));
 	CurrentTime = time(NULL);
 	tm=localtime(&CurrentTime);
+	gettimeofday(&tv, NULL); // get microseconds, 10^-6
 
 	if((ShmSysConfigAndInfo->SysConfig.ModelName != NULL) && (ShmSysConfigAndInfo->SysConfig.SerialNumber != NULL) && (strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) >= 14))
 	{
-		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]%s_%s_SystemLog",
-					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/SystemLog/[%04d.%02d]%s_%s_SystemLog",
+					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
 					buffer,
 					tm->tm_year+1900,tm->tm_mon+1,
 					ShmSysConfigAndInfo->SysConfig.ModelName,
@@ -166,8 +168,8 @@ int StoreLogMsg(const char *fmt, ...)
 	}
 	else
 	{
-		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
+					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
 					buffer,
 					tm->tm_year+1900,tm->tm_mon+1);
 	}
@@ -177,7 +179,7 @@ int StoreLogMsg(const char *fmt, ...)
 #endif
 
 #ifdef ConsloePrintLog
-	printf("[%04d.%02d.%02d %02d:%02d:%02d] - %s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec, buffer);
+	printf("[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec, buffer);
 #endif
 
 	return rc;
@@ -455,7 +457,7 @@ int DB_Open(sqlite3 *db)
 	if(sqlite3_open(DB_FILE, &db))
 	{
 		result = FAIL;
-		DEBUG_INFO( "Can't open database: %s\n", sqlite3_errmsg(db));
+		DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
 		sqlite3_close(db);
 	}
 	else
@@ -465,7 +467,7 @@ int DB_Open(sqlite3 *db)
 		if (sqlite3_exec(db, createRecordSql, 0, 0, &errMsg) != SQLITE_OK)
 		{
 			result = FAIL;
-			DEBUG_INFO( "Create local charging record table error message: %s\n", errMsg);
+			DEBUG_ERROR( "Create local charging record table error message: %s\n", errMsg);
 		}
 		else
 		{
@@ -475,7 +477,7 @@ int DB_Open(sqlite3 *db)
 		if (sqlite3_exec(db, createCfgSql, 0, 0, &errMsg) != SQLITE_OK)
 		{
 			result = FAIL;
-			DEBUG_INFO( "Create local config table error message: %s\n", errMsg);
+			DEBUG_ERROR( "Create local config table error message: %s\n", errMsg);
 		}
 		else
 		{
@@ -495,17 +497,17 @@ int DB_Insert_Record(sqlite3 *db, int gun_index)
 	char sqlStr[1024];
 
 	sprintf(sqlStr, "insert into charging_record(reservationId, transactionId, startMethod, userId, dateTimeStart, dateTimeStop, socStart, socStop, chargeEnergy, stopReason) "
-				    "values('%d', '%d', '%d', '%s', '%s', '%s', '%d', '%d', '%f', '%s');",
-				    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId,
-				    ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId,
-				    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod,
-				    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId,
-				    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime,
-				    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StopDateTime,
-				    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc,
-				    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc,
-				    ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy,
-				    ShmOCPP16Data->StopTransaction[gun_index].StopReason);
+					   "values('%d', '%d', '%d', '%s', '%s', '%s', '%d', '%d', '%f', '%s');",
+					   ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId,
+					   ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId,
+					   ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod,
+					   ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId,
+					   ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime,
+					   ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StopDateTime,
+					   ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc,
+					   ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc,
+					   ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy,
+					   ShmOCPP16Data->StopTransaction[gun_index].StopReason);
 
 	if(sqlite3_open(DB_FILE, &db))
 	{
@@ -613,7 +615,7 @@ int DB_Get_Operactive(sqlite3 *db, uint8_t gun_index)
 		}
 		else
 		{
-			DEBUG_INFO("Query connector-%d fail, set default value to operactive.\n", gun_index);
+			DEBUG_INFO("Query connector-%d fail, default value as operactive.\n", gun_index);
 		}
 
 		sqlite3_free_table(rs);
@@ -704,7 +706,8 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 	//================================================
 	// Load configuration from mtdblock10
 	//================================================
-	fd = open("/dev/mtdblock10", O_RDWR);
+	system("nanddump /dev/mtd10 -f /mnt/EvseConfig.bin");
+	fd = open("/mnt/EvseConfig.bin", O_RDWR);
 	if (fd < 0)
 	{
 		free(buf);
@@ -750,8 +753,8 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 	if(ChkSum!=ChkSumOrg)
 	{
 		DEBUG_ERROR("Primary SysConfigData checksum NG, read backup\n");
-
-		fd = open("/dev/mtdblock11", O_RDWR);
+		system("nanddump /dev/mtd11 -f /mnt/EvseConfig.bin");
+		fd = open("/mnt/EvseConfig", O_RDWR);
 		if (fd < 0)
 		{
 			free(buf);
@@ -798,8 +801,8 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 		if(ChkSum!=ChkSumOrg)
 		{
 			DEBUG_WARN("backup SysConfigData checksum NG, read Factory default\n");
-
-			fd = open("/dev/mtdblock12", O_RDWR);
+			system("nanddump /dev/mtd12 -f /mnt/EvseConfig.bin");
+			fd = open("/mnt/EvseConfig.bin", O_RDWR);
 			if (fd < 0)
 			{
 				DEBUG_ERROR("open mtdblock12 (Factory default) NG,rebooting..\n");
@@ -842,6 +845,7 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 				DEBUG_WARN("factory default  SysConfigData checksum NG, restore factory default\n");
 				free(buf);
 				system("cd /root;./Module_FactoryConfig -m");
+				system("rm -f /Storage/OCPP/OCPPConfiguration");
 				system("sync");
 				sleep(5);
 				system("reboot -f");
@@ -857,6 +861,7 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 	memcpy((struct SysConfigData *)ptr,buf,sizeof(struct SysConfigData));
 	free(buf);
 
+	system("rm -f /mnt/EvseConfig.bin");
 	DEBUG_INFO("Load SysConfigData OK\n");
 
 	return PASS;
@@ -877,49 +882,47 @@ int StoreUsrConfigData(struct SysConfigData *UsrData)
 		memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
 		for(i=0;i<MtdBlockSize-4;i++)
 			Chk+=*(BufTmp+i);
-		memcpy(	BufTmp+MtdBlockSize-4,&Chk,4);
-		fd = open("/dev/mtdblock10", O_RDWR);
-		if (fd>0)
+		memcpy(BufTmp+MtdBlockSize-4, &Chk, 4);
+
+		// Output configuration to file.
+		fd = open("/mnt/EvseConfig.bin", O_RDWR|O_CREAT);
+		if (fd < 0)
 		{
-			wrd=write(fd, BufTmp, MtdBlockSize);
-			close(fd);
-			if(wrd>=MtdBlockSize)
-			{
-				fd = open("/dev/mtdblock11", O_RDWR);
-				if (fd>0)
-				{
-					wrd=write(fd, BufTmp, MtdBlockSize);
-    					close(fd);
-				   	if(wrd<MtdBlockSize)
-					{
-						DEBUG_ERROR("write /dev/mtdblock11(backup) NG\n");
-				   		result = FAIL;
-					}
-				}
-				else
-				{
-					DEBUG_ERROR("open /dev/mtdblock11(backup) NG\n");
-					result = FAIL;
-				}
-			}
-			else
-			{
-		    	DEBUG_ERROR("write /dev/mtdblock10 NG\n");
-		    	result = FAIL;
-			}
+			DEBUG_ERROR("open /mnt/EvseConfig.bin NG\n");
+
+			free(BufTmp);
+			return 0;
 		}
-		else
+		wrd=write(fd, BufTmp, MtdBlockSize);
+		close(fd);
+		if(wrd<MtdBlockSize)
 		{
-			DEBUG_ERROR("open /dev/mtdblock10 NG\n");
-			result = FAIL;
+			DEBUG_ERROR("write /mnt/EvseConfig.bin NG\n");
+
+			free(BufTmp);
+			return 0;
 		}
+		DEBUG_INFO("EvseConfig write to file in /mnt OK.\n");
+
+		DEBUG_INFO("Erase /dev/mtd10.\n");
+		runShellCmd("flash_erase /dev/mtd10 0 12");
+		DEBUG_INFO("Write /dev/mtd10.\n");
+		runShellCmd("nandwrite -p /dev/mtd10 /mnt/EvseConfig.bin");
+
+		DEBUG_INFO("Erase /dev/mtd11.\n");
+		runShellCmd("flash_erase /dev/mtd11 0 12");
+		DEBUG_INFO("Write /dev/mtd11.\n");
+		runShellCmd("nandwrite -p /dev/mtd11 /mnt/EvseConfig.bin");
+
+		system("rm -f /mnt/EvseConfig.bin");
+		DEBUG_INFO("EvseConfig write to flash OK\n");
 	}
 	else
 	{
-		DEBUG_ERROR("alloc BlockSize NG\n");
-    	result = FAIL;
+		DEBUG_ERROR("alloc BlockSize NG\r\n");
+    		result = FAIL;
 	}
-	
+
 	if(BufTmp!=NULL)
 		free(BufTmp);
 
@@ -937,23 +940,23 @@ void InitEthernet()
 	if(isInterfaceUp("eth0")==PASS)
 	{
 		memset(tmpbuf,0,256);
-		sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up",
+		sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
 		ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
 		ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
 		system(tmpbuf);
 		memset(tmpbuf,0,256);
-		sprintf(tmpbuf,"route add default gw %s eth0 ",
+		sprintf(tmpbuf,"route add default gw %s eth0 &",
 		ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
 		system(tmpbuf);
-		system("/sbin/ifconfig eth0:1 192.168.201.201 netmask 255.255.255.248 up");
-		system("ifconfig lo up");
+		system("/sbin/ifconfig eth0:1 192.168.201.201 netmask 255.255.255.248 up &");
+		system("ifconfig lo up &");
 	}
 
 	if(isInterfaceUp("eth1")==PASS)
 	{
 		//Init Eth1 for administrator tool
 		memset(tmpbuf,0,256);
-		sprintf(tmpbuf,"/sbin/ifconfig eth1 %s netmask %s up",
+		sprintf(tmpbuf,"/sbin/ifconfig eth1 %s netmask %s up &",
 		ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthIpAddress,
 		ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthSubmaskAddress);
 		system(tmpbuf);
@@ -962,8 +965,8 @@ void InitEthernet()
     //Run DHCP client if enabled
 	system("killall udhcpc");
 	system("rm -rf /etc/resolv.conf");
-	system("echo nameserver 8.8.8.8 >> /etc/resolv.conf");			//Google DNS server
-	system("echo nameserver 180.76.76.76 >> /etc/resolv.conf");		//Baidu DNS server
+	system("echo nameserver 8.8.8.8 >> /etc/resolv.conf");		//Google DNS server
+	system("echo nameserver 180.76.76.76 >> /etc/resolv.conf");	//Baidu DNS server
 
 	if(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0)
 	{
@@ -986,7 +989,7 @@ void InitEthernet()
 			{
 				DEBUG_ERROR("eth0 not in route, restart eth0.\n");
 				system("/sbin/ifconfig eth0 down;/sbin/ifconfig eth0 up");
-				
+
 				if((ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0))
 				{
 					system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
@@ -994,7 +997,7 @@ void InitEthernet()
 					system(tmpbuf);
 				}
 			}
-			
+
 			if(isReachableInternet() == PASS)
 			{
 				ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=OFF;
@@ -1004,14 +1007,14 @@ void InitEthernet()
 			{
 				if(cnt_pingDNS_Fail >= 3)
 				{
-					ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=ON;					
+					ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=ON;
 				}
 				else
 				{
 					cnt_pingDNS_Fail++;
 				}
 			}
-			
+
 			if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet &&
 			   ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi &&
 			   ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi &&
@@ -1023,19 +1026,19 @@ void InitEthernet()
 			{
 				ShmSysConfigAndInfo->SysInfo.InternetConn = ON;
 			}
-			
+
 			//============================================================
-			// Priority for internet  0 : First / 1 : Second / 2: Third 
+			// Priority for internet  0 : First / 1 : Second / 2: Third
 			//============================================================
 			if(!ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet)
 			{
 				system("/sbin/ifmetric eth0 0");
-				
+
 				if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
 				{
 					system("/sbin/ifmetric mlan0 1");
 				}
-				
+
 				if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
 				{
 					system("/sbin/ifmetric ppp0 2");
@@ -1048,7 +1051,7 @@ void InitEthernet()
 					system("/sbin/ifmetric eth0 1");
 					system("/sbin/ifmetric mlan0 0");
 				}
-				
+
 				if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
 				{
 					system("/sbin/ifmetric ppp0 2");
@@ -1060,7 +1063,7 @@ void InitEthernet()
 				{
 					system("/sbin/ifmetric mlan0 2");
 				}
-				
+
 				if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
 				{
 					system("/sbin/ifmetric eth0 1");
@@ -1086,17 +1089,12 @@ int SpawnTask()
 	system ("pkill Module_Speaker");
 	system ("pkill Module_ProduceUtils");
 
-	if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T')
+	if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
 	{
 		system("/root/Module_4g &");
 	}
-	else if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W')
-	{
-		system("/root/Module_Wifi &");
-	}
-	else if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')
+	else if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
 	{
-		system("/root/Module_4g &");
 		system("/root/Module_Wifi &");
 	}
 
@@ -1129,17 +1127,25 @@ int Initialization()
 	InitEthernet();
 
 	if(DB_Open(localDb) != PASS)
+	{
+		DEBUG_ERROR("Local database initial fail.\n");
 		result = FAIL;
+	}
 
 	for(int gun_index=0;gun_index< AC_QUANTITY;gun_index++)
 		ShmCharger->gun_info[gun_index].isOperactive = DB_Get_Operactive(localDb, gun_index);
 
-	rfidFd = InitRfidPort();
-
-	wtdFd = InitWatchDog();
+	if((rfidFd = InitRfidPort()) == FAIL)
+	{
+		DEBUG_ERROR("RFID port initial fail.\n");
+		result = FAIL;
+	}
 
-	if((wtdFd < 0) || (rfidFd < 0))
+	if((wtdFd = InitWatchDog()) == FAIL)
+	{
+		DEBUG_ERROR("Watchdog initial fail.\n");
 		result = FAIL;
+	}
 
 	if(result == PASS)
 		DEBUG_INFO("Initialization OK.\n");
@@ -1259,7 +1265,7 @@ void get_firmware_version(unsigned char gun_index)
 	{
 		while(fgets(buf, sizeof(buf), fp) != NULL)
 		{
-			strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev, buf);
+			memcpy(ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev, buf, strlen(buf)-1);
 		}
 	}
 
@@ -1267,7 +1273,7 @@ void get_firmware_version(unsigned char gun_index)
 	strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 	// Get CSU root file system version
-	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "V0.58.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "V0.59.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -1346,14 +1352,14 @@ void get_firmware_version(unsigned char gun_index)
 	memcpy(&ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev[14], &ShmSysConfigAndInfo->SysConfig.ModelName[12], 0x02);
 	memcpy(&ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev[14], &ShmSysConfigAndInfo->SysConfig.ModelName[12], 0x02);
 
-	DEBUG_INFO("====================================================================\n");
+	DEBUG_INFO("========================================\n");
 	DEBUG_INFO("Model: %s\n", ShmSysConfigAndInfo->SysConfig.ModelName);
 	DEBUG_INFO("CSU hardware version: %s\n", ShmSysConfigAndInfo->SysInfo.CsuHwRev);
 	DEBUG_INFO("CSU boot loader version: %s\n", ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev);
 	DEBUG_INFO("CSU kernel version: %s\n", ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev);
 	DEBUG_INFO("CSU root file system version: %s\n", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
 	DEBUG_INFO("CSU MCU-%2d firmware version: %s\n", gun_index, ShmCharger->gun_info[gun_index].ver.Version_FW);
-	DEBUG_INFO("====================================================================\n");
+	DEBUG_INFO("========================================\n");
 }
 
 //===============================================
@@ -1774,7 +1780,7 @@ int isReachableInternet()
 		}
 		pclose(fp);
 	}
-	
+
 	return result;
 }
 
@@ -1784,20 +1790,20 @@ int isReachableInternet()
 int isRouteFail()
 {
 	int result = YES;
-	FILE *fp;	
-	char buf[512];	
-	
+	FILE *fp;
+	char buf[512];
+
 	fp = popen("route -n", "r");
-	if(fp != NULL)		
+	if(fp != NULL)
 	{
 		while(fgets(buf, sizeof(buf), fp) != NULL)
-		{			
+		{
 			if(strstr(buf, "eth0") != NULL)
 				result = NO;
-		}		
+		}
 	}
 	pclose(fp);
-	
+
 	return result;
 }
 
@@ -1993,7 +1999,7 @@ int getEth0MacAddress()
 //==========================================
 void checkTask()
 {
-	if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T')
+	if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
 	{
 		if(system("pidof -s Module_4g > /dev/null") != 0)
 		{
@@ -2001,22 +2007,9 @@ void checkTask()
 			system("/root/Module_4g &");
 		}
 	}
-	else if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W')
-	{
-		if(system("pidof -s Module_Wifi > /dev/null") != 0)
-		{
-			DEBUG_INFO("Module_Wifi not running, restart it.\n");
-			system("/root/Module_Wifi &");
-		}
-	}
-	else if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')
+
+	if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
 	{
-		if(system("pidof -s Module_4g > /dev/null") != 0)
-		{
-			DEBUG_INFO("Module_4g not running, restart it.\n");
-			system("/root/Module_4g &");
-		}
-		
 		if(system("pidof -s Module_Wifi > /dev/null") != 0)
 		{
 			DEBUG_INFO("Module_Wifi not running, restart it.\n");
@@ -2380,14 +2373,14 @@ int main(void)
 						DEBUG_INFO("System ID: %s\n",ShmSysConfigAndInfo->SysConfig.SystemId);
 						DEBUG_INFO("==========================================\n");
 
-						DEBUG_INFO("========== OCPP BootNotification information ==========\n");
-						DEBUG_INFO("OCPP OcppServerURL: %s\n",ShmSysConfigAndInfo->SysConfig.OcppServerURL);
-						DEBUG_INFO("OCPP ChargeBoxId: %s\n",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
-						DEBUG_INFO("OCPP ChargePointVendor: %s\n",ShmSysConfigAndInfo->SysConfig.chargePointVendor);
-						DEBUG_INFO("OCPP CpFwVersion: %s\n",ShmOCPP16Data->BootNotification.CpFwVersion);
-						DEBUG_INFO("OCPP CpMeterSerialNumber: %s\n",ShmOCPP16Data->BootNotification.CpMeterSerialNumber);
-						DEBUG_INFO("OCPP CpMeterType: %s\n",ShmOCPP16Data->BootNotification.CpMeterType);
-						DEBUG_INFO("=======================================================\n");
+						DEBUG_INFO("=== OCPP BootNotification information ====\n");
+						DEBUG_INFO("OcppServerURL: %s\n",ShmSysConfigAndInfo->SysConfig.OcppServerURL);
+						DEBUG_INFO("ChargeBoxId: %s\n",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
+						DEBUG_INFO("ChargePointVendor: %s\n",ShmSysConfigAndInfo->SysConfig.chargePointVendor);
+						DEBUG_INFO("CpFwVersion: %s\n",ShmOCPP16Data->BootNotification.CpFwVersion);
+						DEBUG_INFO("CpMeterSerialNumber: %s\n",ShmOCPP16Data->BootNotification.CpMeterSerialNumber);
+						DEBUG_INFO("CpMeterType: %s\n",ShmOCPP16Data->BootNotification.CpMeterType);
+						DEBUG_INFO("==========================================\n");
 
 						DEBUG_INFO("========== Set Wifi information ==========\n");
 						DEBUG_INFO("Wifi mode: %d\n",  ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode);
@@ -2806,7 +2799,7 @@ int main(void)
 									{
 										DEBUG_INFO("Should be remote stop charger... \n");
 										ShmCharger->gun_info[gun_index].rfidReq = OFF;
-									} 
+									}
 								}
 								else
 								{
@@ -2976,7 +2969,7 @@ int main(void)
 						{
 							ShmCharger->gun_info[gun_index].targetCurrent = ShmCharger->gun_info[gun_index].primaryMcuState.rating_current;
 						}
-						
+
 						// Determine max charging current to MCU
 						if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
 						{
@@ -3150,11 +3143,11 @@ int main(void)
 						{
 							setLedMotion(gun_index, LED_ACTION_STOP);
 						}
-						
+
 						if(ShmCharger->gun_info[gun_index].rfidReq)
 						{
 							DEBUG_INFO("Certified in terminating mode... \n");
-							
+
 							// If RFID SN different with start user, it need to authorize ID
 							if((ShmCharger->gun_info[gun_index].rfidReq == ON) && !isMatchStartUser(gun_index))
 							{
@@ -3203,7 +3196,7 @@ int main(void)
 												break;
 										}
 									}
-									
+
 									DEBUG_INFO("End request User Id : %s... \n", ShmSysConfigAndInfo->SysConfig.UserId);
 									DEBUG_INFO("Start method : %d... \n ", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod);
 
@@ -3246,7 +3239,7 @@ int main(void)
 									{
 										DEBUG_INFO("Should be remote stop charger... \n");
 										ShmCharger->gun_info[gun_index].rfidReq = OFF;
-									} 
+									}
 								}
 								else
 								{
@@ -3278,7 +3271,7 @@ int main(void)
 								}
 							}
 						}
-						
+
 						if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C) &&
 						   (ShmCharger->gun_info[gun_index].rfidReq != ON) &&
 						   (ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop != ON)  &&
@@ -3346,6 +3339,7 @@ int main(void)
 
 					break;
 				case SYS_MODE_ALARM:
+					setLedMotion(gun_index,LED_ACTION_ALARM);
 
 					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) ||
 					   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_TERMINATING))
@@ -3370,7 +3364,6 @@ int main(void)
 						}
 					}
 
-					setLedMotion(gun_index,LED_ACTION_ALARM);
 					break;
 				case SYS_MODE_FAULT:
 					if(isModeChange(gun_index))
@@ -3587,12 +3580,14 @@ int main(void)
 				case SYS_MODE_BOOKING:
 					if(isModeChange(gun_index))
 					{}
+
 					break;
 				case SYS_MODE_DEBUG:
 					if(isModeChange(gun_index))
 					{
 						setLedMotion(gun_index,LED_ACTION_DEBUG);
 					}
+
 					break;
 			}
 		}

+ 2 - 0
EVSE/Projects/AW-Regular/Apps/main.h

@@ -298,6 +298,7 @@ typedef struct AC_PRIMARY_MCU_CP_PWM_DUTY
 typedef struct LEGACY_REQUEST
 {
 	unsigned char isLegacyRequest:1;
+	uint8_t isRelayOn:1;
 }Legacy_Request;
 
 typedef struct POWER_CONSUMPTION
@@ -410,6 +411,7 @@ typedef struct GUN_INFO
 	Mcu_Reset_Request								mcuResetRequest;
 	Set_Breathe_Led_Timing							setBreatheLedTiming;
 	Set_Led_Brightness								setLedBrightness;
+	uint8_t											chargingMode;
 	uint16_t										targetCurrent;
 	uint16_t										isAuthPassEnd:1;
 	uint16_t										rfidReq:1;

BIN
EVSE/Projects/AW-Regular/Images/FactoryDefaultConfig.bin


BIN
EVSE/Projects/AW-Regular/Images/MLO


BIN
EVSE/Projects/AW-Regular/Images/ramdisk.gz


BIN
EVSE/Projects/AW-Regular/Images/u-boot.img


BIN
EVSE/Projects/AW-Regular/Images/zImage


+ 1 - 1
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_System.map

@@ -70354,7 +70354,7 @@ c0d4b850 T __initramfs_start
 c0d4b850 t __irf_start
 c0d4b850 T __security_initcall_end
 c0d4b850 T __security_initcall_start
-c0d4b8d7 t __irf_end
+c0d4b8d5 t __irf_end
 c0d4b8d8 T __initramfs_size
 c0e00000 D __data_loc
 c0e00000 D __init_end

+ 1 - 1
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_kallsyms1.S

@@ -70355,7 +70355,7 @@ kallsyms_offsets:
 	.long	0xc43850
 	.long	0xc43850
 	.long	0xc43850
-	.long	0xc438d7
+	.long	0xc438d5
 	.long	0xc438d8
 	.long	0xcf8000
 	.long	0xcf8000

+ 1 - 1
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.tmp_kallsyms2.S

@@ -70355,7 +70355,7 @@ kallsyms_offsets:
 	.long	0xd43850
 	.long	0xd43850
 	.long	0xd43850
-	.long	0xd438d7
+	.long	0xd438d5
 	.long	0xd438d8
 	.long	0xdf8000
 	.long	0xdf8000

+ 1 - 1
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.version

@@ -1 +1 @@
-17
+18

+ 19 - 100
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.dts.tmp

@@ -1199,37 +1199,22 @@
 
 
 
-   0x020 (((1 << 5) | (1 << 3)) | 7)
-   0x024 (((1 << 5) | (1 << 3)) | 7)
-   0x028 (((1 << 5) | (1 << 3)) | 7)
-   0x02C (((1 << 5) | (1 << 3)) | 7)
    0x144 (((1 << 5) | (1 << 3)) | 7)
    0x1B0 (((1 << 3)) | 7)
    0x1B4 (((1 << 5) | (1 << 3)) | 7)
 
 
-   0x030 (((1 << 5) | (1 << 3)) | 7)
-   0x034 (((1 << 5) | (1 << 3)) | 7)
-   0x038 (((1 << 5) | (1 << 3)) | 7)
-   0x03C (((1 << 5) | (1 << 3)) | 7)
-
-
-   0x0EC (((1 << 3)) | 7)
-   0x0E4 (((1 << 3)) | 7)
+   0x08C (((1 << 3)) | 7)
+   0x0A0 (((1 << 3)) | 7)
+   0x0A4 (((1 << 3)) | 7)
+   0x0A8 (((1 << 3)) | 7)
+   0x0AC (((1 << 3)) | 7)
+   0x0B0 (((1 << 3)) | 7)
+   0x0B4 (((1 << 3)) | 7)
    0x0E8 (((1 << 5) | (1 << 3)) | 7)
-   0x0E0 (((1 << 5) | (1 << 3)) | 7)
-
+   0x0E0 (((1 << 3)) | 7)
 
-    ((((0x9e4)) & 0xffff) - (0x0800)) (0 | 7)
-              ((((0x9e8)) & 0xffff) - (0x0800)) (((1 << 4)) | 7)
-   0x194 (((1 << 5) | (1 << 3)) | 7)
-   0x1A0 (((1 << 5) | (1 << 3)) | 7)
-   0x19C (((1 << 5) | (1 << 3)) | 7)
-   0x190 (((1 << 3)) | 7)
-   0x1A4 (((1 << 3)) | 7)
-   0x198 (((1 << 3)) | 7)
    0x1A8 (((1 << 3)) | 7)
-
   >;
  };
 
@@ -1274,14 +1259,7 @@
    0x164 (0 | 1)
   >;
  };
-
- uart5_pins: pinmux_uart5_pins {
-  pinctrl-single,pins = <
-   0x0C0 (0 | 4)
-   0x0C4 (((1 << 5) | (1 << 4)) | 4)
-  >;
- };
-
+# 136 "arch/arm/boot/dts/am335x-evm.dts"
  clkout2_pin: pinmux_clkout2_pin {
   pinctrl-single,pins = <
    0x1b4 (0 | 3)
@@ -1332,12 +1310,12 @@
   pinctrl-single,pins = <
 
 
-   0x108 (((1 << 5) | (1 << 4)) | 0)
-   0x10C(((1 << 5) | (1 << 4)) | 0)
+
+
    0x110 (((1 << 5) | (1 << 4)) | 0)
+   0x118 (((1 << 5) | (1 << 4)) | 0)
    0x12c (((1 << 5) | (1 << 4)) | 0)
    0x130 (((1 << 5) | (1 << 4)) | 0)
-   0x118 (((1 << 5) | (1 << 4)) | 0)
    0x134 (((1 << 5) | (1 << 4)) | 0)
    0x138 (((1 << 5) | (1 << 4)) | 0)
    0x13c (((1 << 5) | (1 << 4)) | 0)
@@ -1348,23 +1326,6 @@
    0x124 (0 | 0)
    0x128 (0 | 0)
 
-
-   ((((0x878)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
-   ((((0x888)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 2)
-
-   ((((0x858)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
-   ((((0x85c)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
-   ((((0x844)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
-   ((((0x860)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
-   ((((0x864)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
-   ((((0x868)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
-   ((((0x86c)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 1)
-   ((((0x840)) & 0xffff) - (0x0800)) (0 | 1)
-   ((((0x848)) & 0xffff) - (0x0800)) (0 | 1)
-   ((((0x84c)) & 0xffff) - (0x0800)) (0 | 1)
-   ((((0x850)) & 0xffff) - (0x0800)) (0 | 1)
-   ((((0x854)) & 0xffff) - (0x0800)) (0 | 1)
-
   >;
  };
 
@@ -1384,23 +1345,6 @@
    0x13c (((1 << 5)) | 7)
    0x140 (((1 << 5)) | 7)
 
-
-   ((((0x888)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x840)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x844)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x848)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x84c)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x850)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x854)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x858)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x85c)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x860)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x864)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x868)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-   ((((0x86c)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-
-   ((((0x878)) & 0xffff) - (0x0800)) (((1 << 5)) | 7)
-
   >;
  };
 
@@ -1439,14 +1383,7 @@
    0x17C (((1 << 5)) | 2)
   >;
  };
-
- dcan1_pins_default: dcan1_pins_default {
-  pinctrl-single,pins = <
-   0x168 (((1 << 4)) | 2)
-   0x16C (((1 << 5)) | 2)
-  >;
- };
-# 329 "arch/arm/boot/dts/am335x-evm.dts"
+# 280 "arch/arm/boot/dts/am335x-evm.dts"
 };
 
 
@@ -1478,14 +1415,7 @@
 
  status = "okay";
 };
-
-&uart5 {
- pinctrl-names = "default";
- pinctrl-0 = <&uart5_pins>;
-
- status = "okay";
-};
-
+# 319 "arch/arm/boot/dts/am335x-evm.dts"
 &i2c0 {
  pinctrl-names = "default";
  pinctrl-0 = <&i2c0_pins>;
@@ -1514,6 +1444,7 @@
                 compatible = "nxp,pcf85063";
                 reg = <0x51>;
         };
+
 };
 
 &usb {
@@ -1548,7 +1479,7 @@
 &elm {
  status = "okay";
 };
-# 451 "arch/arm/boot/dts/am335x-evm.dts"
+# 403 "arch/arm/boot/dts/am335x-evm.dts"
 &gpmc {
  status = "okay";
  pinctrl-names = "default", "sleep";
@@ -1734,7 +1665,7 @@
   };
  };
 };
-# 557 "arch/arm/boot/dts/am335x-evm.dts" 2
+# 509 "arch/arm/boot/dts/am335x-evm.dts" 2
 
 &tps {
  vcc1-supply = <&vbat>;
@@ -1817,7 +1748,6 @@
  pinctrl-names = "default", "sleep";
  pinctrl-0 = <&cpsw_default>;
  pinctrl-1 = <&cpsw_sleep>;
- dual_emac = <1>;
  status = "okay";
 };
 
@@ -1826,20 +1756,15 @@
  pinctrl-0 = <&davinci_mdio_default>;
  pinctrl-1 = <&davinci_mdio_sleep>;
  status = "okay";
+
 };
 
 &cpsw_emac0 {
  phy_id = <&davinci_mdio>, <1>;
   phy-mode = "mii";
-  dual_emac_res_vlan = <1>;
-};
 
-&cpsw_emac1 {
- phy_id = <&davinci_mdio>, <2>;
-  phy-mode = "mii";
-  dual_emac_res_vlan = <2>;
 };
-
+# 615 "arch/arm/boot/dts/am335x-evm.dts"
 &tscadc {
  status = "okay";
 
@@ -1886,9 +1811,3 @@
  pinctrl-names = "default";
  pinctrl-0 = <&dcan0_pins_default>;
 };
-
-&dcan1 {
- status = "okay";
- pinctrl-names = "default";
- pinctrl-0 = <&dcan1_pins_default>;
-};

+ 36 - 82
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/am335x-evm.dts

@@ -64,38 +64,23 @@
 		pinctrl-single,pins = <
 		
 			/** Offset: 0x800 */
-			/** GPIO 0 */   
-			0x020 (PIN_INPUT | MUX_MODE7)			/* GPMC_AD8			=> 	GPIO0_22 */	/*ID BD1_1*/
-			0x024 (PIN_INPUT | MUX_MODE7)    			/* GPMC_AD9			=>	GPIO0_23 */	/*ID BD1_2*/
-			0x028 (PIN_INPUT | MUX_MODE7)    			/* GPMC_AD10		=>	GPIO0_26 */	/*IO BD1_1*/
-			0x02C (PIN_INPUT | MUX_MODE7)    		/* GPMC_AD11		=>	GPIO0_27 */	/*IO BD1_2*/
+			/** GPIO 0 */ 
 			0x144 (PIN_INPUT | MUX_MODE7)    			/* RMII1_REF_CLK		=>	GPIO0_29 */	/*USB 0 OCP detection*/
 			0x1B0 (PIN_OUTPUT | MUX_MODE7)			/*XDMA_EVENT_INTR0	=>	GPIO0_19 */	/*AM_RFID_RST*/
 			0x1B4 (PIN_INPUT | MUX_MODE7)			/*XDMA_EVENT_INTR1	=>	GPIO0_20 */	/*AM_RFID_ICC*/
-			
-			/** GPIO 1 */
-			0x030 (PIN_INPUT | MUX_MODE7)			/* GPMC_AD12	=> 	GPIO1_12 */	/*ID BD2_1*/
-			0x034 (PIN_INPUT | MUX_MODE7)    			/* GPMC_AD13	=>	GPIO1_13 */	/*ID BD2_2*/
-			0x038 (PIN_INPUT | MUX_MODE7)    			/* GPMC_AD14	=>	GPIO1_14 */	/*IO BD2_1*/
-			0x03C (PIN_INPUT | MUX_MODE7)    		/* GPMC_AD15	=>	GPIO1_15 */	/*IO BD2_2*/
-			
+			/** GPIO 1 */			
 			/** GPIO 2 */
-			0x0EC (PIN_OUTPUT | MUX_MODE7)			/*LCD_AC_BIAS_EN	=>	GPIO2_25*/	/*RS-485 for module DE control*/
-			0x0E4 (PIN_OUTPUT | MUX_MODE7)			/*LCD_HSYNC		=>	GPIO2_23*/	/*RS-485 for module RE control*/
-			0x0E8 (PIN_INPUT | MUX_MODE7)			/*LCD_PCLK		=>	GPIO2_24*/	/*CCS communication board 1 proximity*/
-			0x0E0 (PIN_INPUT | MUX_MODE7)			/*LCD_VSYNC		=>	GPIO2_22*/	/*CCS communication board 2 proximity*/
-			
+			0x08C (PIN_OUTPUT | MUX_MODE7)			/*GPMC_CLK	=>	GPIO2_1*/	/*Speaker*/
+			0x0A0 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA0	=>	GPIO2_6*/	/*Panel LED control-BB_LEDR1*/
+			0x0A4 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA1	=>	GPIO2_7*/	/*Panel LED control-BB_LEDG1*/
+			0x0A8 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA2	=>	GPIO2_8*/	/*Panel LED control-BB_LEDB1*/
+			0x0AC (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA3	=>	GPIO2_9*/	/*Panel LED control-BB_LEDR2*/
+			0x0B0 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA4	=>	GPIO2_10*/	/*Panel LED control-BB_LEDG2*/
+			0x0B4 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA5	=>	GPIO2_11*/	/*Panel LED control-BB_LEDB2*/
+			0x0E8 (PIN_INPUT | MUX_MODE7)			/*LCD_PCLK	=>	GPIO2_24*/	/*communication board proximity*/
+			0x0E0 (PIN_OUTPUT | MUX_MODE7)			/*LCD_VSYNC	=>	GPIO2_22*/	/*Breath LED*/
 			/** GPIO 3 */
- 			AM33XX_IOPAD(0x9e4, PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* (C14) EMU0.gpio3[7] */  /*CP open/short feature enable/disable, pull low for default enable*/
-           			AM33XX_IOPAD(0x9e8, PIN_OUTPUT_PULLUP | MUX_MODE7)   /* (B14) EMU1.gpio3[8] */  /*4G module reset, pull high to reset when entry kernel, after Application start, it should be pull low.*/
-			0x194 (PIN_INPUT | MUX_MODE7)			/*MCASP0_FSX		=>	GPIO3_15*/	/*Emergency Stop button detect*/
-			0x1A0 (PIN_INPUT | MUX_MODE7)			/*MCASP0_ACLKR	=>	GPIO3_18*/	/*USB1 OCP detect*/
-			0x19C (PIN_INPUT | MUX_MODE7)			/*MCASP0_AHCLKR	=>	GPIO3_17*/	/*Emergency IO for AM3352 and STM32F407*/
-			0x190 (PIN_OUTPUT | MUX_MODE7)			/*MCASP0_ACLKX	=>	GPIO3_14*/	/*Ethernet PHY reset*/
-			0x1A4 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_FSR		=>	GPIO3_19 */	/*SMR Enable control_1*/
-			0x198 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_AXR0	=>	GPIO3_16 */	/*CSU board function OK indicator.*/
-			0x1A8 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_AXR1	=>	GPIO3_20 */	/*SMR Enable control_2*/
-			
+			0x1A8 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_AXR1	=>	GPIO3_20 */	/*control MCU to output CP PWM*/
 		>;
 	};
 	
@@ -140,14 +125,14 @@
 			0x164 (PIN_OUTPUT_PULLDOWN | MUX_MODE1)	/* ECAP0_IN_PWM0_OUT		=>	uart3_txd */
 		>;
 	};
-
+#if 0
 	uart5_pins: pinmux_uart5_pins {
 		pinctrl-single,pins = <
-			0x0C0 (PIN_OUTPUT_PULLDOWN | MUX_MODE4)		/* LCD_DATA8	=>	DUART5_TX*/
-			0x0C4 (PIN_INPUT_PULLUP | MUX_MODE4)			/* LCD_DATA9	=>	UART5_RX*/
+			0x0C0 (PIN_INPUT_PULLUP | MUX_MODE4)		/* LCD_DATA8	=>	UART5_RXD*/
+			0x0C4 (PIN_OUTPUT_PULLDOWN | MUX_MODE4)	/* LCD_DATA9	=>	UART5_TXD*/
 		>;
 	};
-	
+#endif	
 	clkout2_pin: pinmux_clkout2_pin {
 		pinctrl-single,pins = <
 			0x1b4 (PIN_OUTPUT_PULLDOWN | MUX_MODE3)	/* xdma_event_intr1.clkout2 */
@@ -198,12 +183,12 @@
 		pinctrl-single,pins = <					
 		
 			/* Slave 1 */
-			0x108 (PIN_INPUT_PULLUP | MUX_MODE0)		/* MII1_COL.gmii1_col */
-			0x10C(PIN_INPUT_PULLUP | MUX_MODE0)		/* MII1_CRS.MII1_CRS */
+			//0x108 (PIN_INPUT_PULLDOWN | MUX_MODE0)		/* MII1_COL.gmii1_col */
+			//0x10C(PIN_INPUT_PULLDOWN | MUX_MODE0)		/* MII1_CRS.MII1_CRS */
 			0x110 (PIN_INPUT_PULLUP | MUX_MODE0)		/* MII1_RX_ER.gmii1_rxerr */
+			0x118 (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxdv.mii1_rxdv */
 			0x12c (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_txclk.mii1_txclk */
 			0x130 (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxclk.mii1_rxclk */
-			0x118 (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxdv.mii1_rxdv */
 			0x134 (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxd3.rgmii1_rd3 */
 			0x138 (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxd2.rgmii1_rd2 */
 			0x13c (PIN_INPUT_PULLUP | MUX_MODE0)		/* mii1_rxd1.rgmii1_rd1 */
@@ -212,24 +197,7 @@
 			0x11c (PIN_OUTPUT_PULLDOWN | MUX_MODE0)		/* mii1_txd3.rgmii1_td3 */
 			0x120 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)		/* mii1_txd2.rgmii1_td2 */
 			0x124 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)		/* mii1_txd1.rgmii1_td1 */
-			0x128 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)		/* mii1_txd0.rgmii1_td0 */      	
-			
-			/* Slave 2 */
-			AM33XX_IOPAD(0x878, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_ben1.mii2_col */
-			AM33XX_IOPAD(0x888, PIN_INPUT_PULLUP | MUX_MODE2)					/* GPMC_CSn3.rmii2_crs_dv*/								
-			/*AM33XX_IOPAD(0x874, PIN_INPUT_PULLUP | MUX_MODE1)*/					/* gpmc_wpn.mii2_rxerr */
-			AM33XX_IOPAD(0x858, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a6.mii2_txclk */
-			AM33XX_IOPAD(0x85c, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a7.mii2_rxclk */
-			AM33XX_IOPAD(0x844, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a1.mii2_rxdv */
-			AM33XX_IOPAD(0x860, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a8.mii2_rxd3 */
-			AM33XX_IOPAD(0x864, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a9.mii2_rxd2 */
-			AM33XX_IOPAD(0x868, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a10.mii2_rxd1 */
-			AM33XX_IOPAD(0x86c, PIN_INPUT_PULLUP | MUX_MODE1)					/* gpmc_a11.mii2_rxd0 */
-			AM33XX_IOPAD(0x840, PIN_OUTPUT_PULLDOWN | MUX_MODE1)				/* gpmc_a0.mii2_txen */
-			AM33XX_IOPAD(0x848, PIN_OUTPUT_PULLDOWN | MUX_MODE1)				/* gpmc_a2.mii2_txd3 */
-			AM33XX_IOPAD(0x84c, PIN_OUTPUT_PULLDOWN | MUX_MODE1)				/* gpmc_a3.mii2_txd2 */
-			AM33XX_IOPAD(0x850, PIN_OUTPUT_PULLDOWN | MUX_MODE1)				/* gpmc_a4.mii2_txd1 */
-			AM33XX_IOPAD(0x854, PIN_OUTPUT_PULLDOWN | MUX_MODE1)				/* gpmc_a5.mii2_txd0 */
+			0x128 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)		/* mii1_txd0.rgmii1_td0 */      
 
 		>;
 	};
@@ -250,23 +218,6 @@
 			0x13c (PIN_INPUT_PULLDOWN | MUX_MODE7)
 			0x140 (PIN_INPUT_PULLDOWN | MUX_MODE7)		
 			
-			/* Slave 2 */
-			AM33XX_IOPAD(0x888, PIN_INPUT_PULLDOWN | MUX_MODE7)					/* GPMC_CSn3.rmii2_crs_dv*/	
-			AM33XX_IOPAD(0x840, PIN_INPUT_PULLDOWN | MUX_MODE7)				/* gpmc_a0.mii2_txen */
-			AM33XX_IOPAD(0x844, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a1.mii2_rxdv */
-			AM33XX_IOPAD(0x848, PIN_INPUT_PULLDOWN | MUX_MODE7)				/* gpmc_a2.mii2_txd3 */
-			AM33XX_IOPAD(0x84c, PIN_INPUT_PULLDOWN | MUX_MODE7)			/* gpmc_a3.mii2_txd2 */
-			AM33XX_IOPAD(0x850, PIN_INPUT_PULLDOWN | MUX_MODE7)				/* gpmc_a4.mii2_txd1 */
-			AM33XX_IOPAD(0x854, PIN_INPUT_PULLDOWN | MUX_MODE7)				/* gpmc_a5.mii2_txd0 */
-			AM33XX_IOPAD(0x858, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a6.mii2_txclk */
-			AM33XX_IOPAD(0x85c, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a7.mii2_rxclk */
-			AM33XX_IOPAD(0x860, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a8.mii2_rxd3 */
-			AM33XX_IOPAD(0x864, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a9.mii2_rxd2 */
-			AM33XX_IOPAD(0x868, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a10.mii2_rxd1 */
-			AM33XX_IOPAD(0x86c, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a11.mii2_rxd0 */
-			/*AM33XX_IOPAD(0x874, PIN_INPUT_PULLDOWN | MUX_MODE7)*/	/* gpmc_wpn.mii2_rxerr */
-			AM33XX_IOPAD(0x878, PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ben1.mii2_col */
-			
 		>;
 	};
 
@@ -305,14 +256,14 @@
 			0x17C (PIN_INPUT_PULLDOWN | MUX_MODE2)		/* uart1_rtsn	=>	d_can0_rx */
 		>;
 	};
-	
+#if 0	
 	dcan1_pins_default: dcan1_pins_default {
 		pinctrl-single,pins = <
 			0x168 (PIN_OUTPUT_PULLUP | MUX_MODE2)		/* UART0_CTSn		=>	d_can1_tx */
 			0x16C (PIN_INPUT_PULLDOWN | MUX_MODE2)	/* UART0_RTSn		=>	d_can1_rx */
 		>;
 	};
-#if 0
+
 	ehrpwm1_pins: ehrpwm1_pins {
 		pinctrl-single,pins = <			
 			0x0C8 (PIN_OUTPUT | MUX_MODE2) /* LCD_DATA10.eHRPWM1A */
@@ -357,14 +308,14 @@
 
 	status = "okay";
 };
-
+#if 0
 &uart5 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart5_pins>;
 
 	status = "okay";
 };
-
+#endif
 &i2c0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&i2c0_pins>;
@@ -375,11 +326,11 @@
 	tps: tps@2d {
 		reg = <0x2d>;
 	};
-	
+
 /*	rtc0: rtc@51 {
-                compatible = "nxp,pcf85063";
-                reg = <0x51>;
-        };*/	
+		compatible = "nxp,pcf85063";
+		reg = <0x51>;
+	};*/
 };
 #if 1
 &i2c1 {
@@ -393,6 +344,7 @@
                 compatible = "nxp,pcf85063";
                 reg = <0x51>;
         };
+
 };
 #endif
 &usb {
@@ -636,7 +588,6 @@
 	pinctrl-names = "default", "sleep";
 	pinctrl-0 = <&cpsw_default>;
 	pinctrl-1 = <&cpsw_sleep>;
-	dual_emac = <1>;
 	status = "okay";
 };
 
@@ -645,19 +596,21 @@
 	pinctrl-0 = <&davinci_mdio_default>;
 	pinctrl-1 = <&davinci_mdio_sleep>;
 	status = "okay";
+	//reset-gpios = <&gpio3 14 GPIO_ACTIVE_LOW>;
 };
 
 &cpsw_emac0 {
 	phy_id = <&davinci_mdio>, <1>;
  	phy-mode = "mii";
- 	dual_emac_res_vlan = <1>;
-};
 
+};
+#if 0
 &cpsw_emac1 {
 	phy_id = <&davinci_mdio>, <2>;
  	phy-mode = "mii";
- 	dual_emac_res_vlan = <2>;
+
 };
+#endif
 
 &tscadc {
 	status = "okay";
@@ -705,9 +658,10 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&dcan0_pins_default>;
 };
-
+#if 0
 &dcan1 {
 	status = "okay";	
 	pinctrl-names = "default";
 	pinctrl-0 = <&dcan1_pins_default>;
 };
+#endif