Explorar el Código

Merge branch 'AW-CCS' of https://git.phihong.com.tw:30000/System_Integration/CSU3_AM335x into AW-CCS

8009 hace 2 años
padre
commit
5d19329e50

+ 82 - 1
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -5078,6 +5078,15 @@ void CheckSystemValue(void)
 			memset(&ShmOCPP16Data->SessionTarget[gun_index], 0x00, sizeof(struct StructSessionTarget));
 		}
 
+		//==========================================
+		// Charger OCMF message
+		//==========================================
+		if(/*(server_sign == TRUE) &&*/ ((ShmOCPP16Data->OcmfData[gun_index].SendOcmfDataReq == 1)))
+		{
+			sendOcmfByDataTransferRequest(gun_index);
+			ShmOCPP16Data->OcmfData[gun_index].SendOcmfDataReq = 0;
+		}
+
 		//==========================================
 		// Charger status report
 		//==========================================
@@ -5858,6 +5867,39 @@ int sendUnplugByDataTransferRequest(int gun_index)
 	return result;
 }
 
+int sendOcmfByDataTransferRequest(int gun_index)
+{
+	sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, (char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor);
+	sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].MessageId, "ID_OCMF");
+	sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].Data, "{\\\"txId\\\":%d,\\\"dataString\\\":\\\"%s\\\",\\\"publicKey\\\":\\\"%s\\\"}", ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId, ShmOCPP16Data->OcmfData[gun_index].DataString, ShmOCPP16Data->OcmfData[gun_index].PublicKey);
+
+	mtrace();
+	char message[3000]={0};
+	char guid[37]={0};
+	char tempdata[65]={0};
+	int result = FAIL;
+
+	random_uuid(guid);
+	sprintf(message,"%d,[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
+			(gun_index+1),
+			MESSAGE_TYPE_CALL,
+			guid,
+			ShmOCPP16Data->DataTransfer[gun_index].VendorId,
+			ShmOCPP16Data->DataTransfer[gun_index].MessageId,
+			ShmOCPP16Data->DataTransfer[gun_index].Data);
+
+	sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
+	if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
+	{
+		result = PASS;
+		DEBUG_INFO("DataTransfer mapItem pass\n");
+	}
+
+	queue_operation(QUEUE_OPERATION_ADD, guid, message);
+
+	return result;
+}
+
 int sendDiagnosticsStatusNotificationRequest(char *status)
 {
 	mtrace();
@@ -16346,7 +16388,7 @@ int initialConfigurationTable(void)
 	char sstr[256]={0};
 	int c = 0;
 	char *loc;
-	int	confVersion = 18;
+	int	confVersion = 19;
 
 	DEBUG_INFO("initialConfigurationTable...version: %d\n", confVersion);
 	//start_t = clock();
@@ -16811,6 +16853,12 @@ int initialConfigurationTable(void)
 
 		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","CharingProfileRefreshInterval", "false", ShmOCPP16Data->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData);
 
+		// Ocpp Software certificated version
+		ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = 0;
+		strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemName, "OcppSoftwareVersion");
+		sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "%s", "V1.00");
+
+		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","OcppSoftwareVersion", "true", ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData);
 
 		//* Local Auth List Management Profile*/
 		#if 0
@@ -17311,6 +17359,12 @@ int initialConfigurationTable(void)
 					sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData, "%s", valuestr);
 				}
 
+				if(strcmp(keystr, "OcppSoftwareVersion") == 0)
+				{
+					ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
+					sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "%s", valuestr);
+				}
+
 				if(strcmp(keystr, "LocalAuthListEnabled") == 0)
 				{
 					ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
@@ -17918,6 +17972,15 @@ void StoreConfigurationTable(void)
 
 	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","CharingProfileRefreshInterval", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData);
 
+	// OcppSoftwareVersion
+	/*
+	ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = 1;
+	strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemName, "OcppSoftwareVersion");
+	strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "" );
+	*/
+
+	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","OcppSoftwareVersion", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData);
+
 	//* Local Auth List Management Profile*/
 	//LocalAuthListEnabled
 	/*
@@ -19059,6 +19122,24 @@ void getKeyValue(char *keyReq)
 			  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_CharingProfileRefreshInterval].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData );
 			  isKnowKey = TRUE;
 		  }
+
+		  if(isEmpty ||  strcmp(keyReq, "OcppSoftwareVersion") == 0 )
+		  {
+			  strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_OcppSoftwareVersion].Item, "OcppSoftwareVersion");
+			  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].Key, "OcppSoftwareVersion");
+
+			  if(ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility == 1)
+			  {
+				  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].ReadOnly, "0"/*"FALSE"*/);
+			  }
+			  else
+			  {
+				  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].ReadOnly, "1"/*"TRUE"*/);
+			  }
+
+			  strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData );
+			  isKnowKey = TRUE;
+		  }
 #if 1
 	      if(isEmpty ||  strcmp(keyReq, "LocalAuthListEnabled") == 0 )
 	      {

+ 2 - 0
EVSE/Modularization/ocppfiles/MessageHandler.h

@@ -418,6 +418,7 @@ enum GetConfigurationKey {
 	GetConfiguration_MaxChargingProfilesInstalled,
 	GetConfiguration_ConfigurationVersion,
 	GetConfiguration_CharingProfileRefreshInterval,
+	GetConfiguration_OcppSoftwareVersion,
 	_GetConfiguration_CNT
 };
 
@@ -468,6 +469,7 @@ int sendAuthorizeRequest(int gun_index);
 int sendBootNotificationRequest(void);
 int sendDataTransferRequest(int gun_index);
 int sendUnplugByDataTransferRequest(int gun_index);
+int sendOcmfByDataTransferRequest(int gun_index);
 int sendFirmwareVersionByDataTransfer(void);
 int sendDiagnosticsStatusNotificationRequest(char *status);
 int sendFirmwareStatusNotificationRequest(char *status);

+ 30 - 0
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -34,6 +34,7 @@ char OcppPath[384]={0};
 char OcppProtocol[10]={0},OcppHost[128]={0}, OcppTempPath[256]={0};
 int OcppPort=0;
 unsigned char StartTransactionIdTagTemp[20]={0};
+int LastQueuedTransactionId[8] = {0};
 uint8_t	isWebsocketSendable = 1;
 uint8_t	isQueueSendable = 1;
 uint8_t	counterLwsRestart = 0;
@@ -1045,6 +1046,7 @@ int sentqueue()
 							{
 								transactionId_map = transactionId_org;
 							}
+							LastQueuedTransactionId[connectorId-1] = transactionId_map;
 							DEBUG_INFO("Final transactionId       = %d\n", transactionId_map);
 						}
 
@@ -1091,6 +1093,33 @@ int sentqueue()
 								}
 								DEBUG_INFO("Final transactionId       = %d\n", transactionId_map);
 
+								json_object_object_add(objPayload, "data", json_object_new_string(json_object_to_json_string_ext(objData, JSON_C_TO_STRING_PLAIN)));
+								json_object_array_put_idx(obj, 3, objPayload);
+								LWS_Send((char*)json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PLAIN));
+							}
+						}
+						else if(strstr(json_object_get_string(json_object_object_get(objPayload, "messageId")), "ID_OCMF") != NULL)
+						{
+							objData = json_tokener_parse(json_object_get_string(json_object_object_get(objPayload, "data")));
+							if(!is_error(objData))
+							{
+								transactionId_org = json_object_get_int(json_object_object_get(objData, "txId"));
+								DEBUG_INFO("original  transactionId   = %d\n", transactionId_org);
+
+								if(transactionId_org == 0)
+								{
+									//replace transactionId
+									transactionId_map = GetStartTransactionId(connectorId-1);
+									if(transactionId_map == 0)
+										transactionId_map = LastQueuedTransactionId[connectorId-1];
+									json_object_object_add(objData, "txId", json_object_new_int(transactionId_map));
+								}
+								else
+								{
+									transactionId_map = transactionId_org;
+								}
+								DEBUG_INFO("Final transactionId       = %d\n", transactionId_map);
+
 								json_object_object_add(objPayload, "data", json_object_new_string(json_object_to_json_string_ext(objData, JSON_C_TO_STRING_PLAIN)));
 								json_object_array_put_idx(obj, 3, objPayload);
 								LWS_Send((char*)json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PLAIN));
@@ -1328,6 +1357,7 @@ int main(void)
 	queueOpInfo.TransactionMessageResend = 0;
 
 	DEBUG_INFO("Module_OcppBackend task initialization...\n");
+	DEBUG_INFO("Last update date: 2022/08/05 \n");
 	//lws_set_log_level(LLL_PARSER | LLL_HEADER | LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO | LLL_DEBUG | LLL_EXT | LLL_CLIENT | LLL_LATENCY  , NULL);
 
 	if(ProcessShareMemory()== FAIL)

+ 40 - 1
EVSE/Modularization/ocppph/MessageHandler.c

@@ -15838,7 +15838,7 @@ int initialConfigurationTable(void)
 	char sstr[256]={0};
 	int c = 0;
 	char *loc;
-	int	confVersion = 17;
+	int	confVersion = 18;
 
 	DEBUG_INFO("initialConfigurationTable...version: %d\n", confVersion);
 	//start_t = clock();
@@ -16275,6 +16275,13 @@ int initialConfigurationTable(void)
 
 		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","CharingProfileRefreshInterval", "false", ShmOCPP16DataPH->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData);
 
+		// Ocpp Software certificated version
+		ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = 0;
+		strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemName, "OcppSoftwareVersion");
+		sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "%s", "V1.00");
+
+		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","OcppSoftwareVersion", "true", ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData);
+
 		//* Local Auth List Management Profile*/
 		#if 0
 			//For OCTT Test Case
@@ -16751,6 +16758,12 @@ int initialConfigurationTable(void)
 					sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData, "%s", valuestr);
 				}
 
+				if(strcmp(keystr, "OcppSoftwareVersion") == 0)
+				{
+					ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
+					sprintf((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "%s", valuestr);
+				}
+
 				if(strcmp(keystr, "LocalAuthListEnabled") == 0)
 				{
 					ShmOCPP16DataPH->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
@@ -17321,6 +17334,14 @@ void StoreConfigurationTable(void)
 
 	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","CharingProfileRefreshInterval", "false", (char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData);
 
+	// OcppSoftwareVersion
+	/*
+	ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility = 1;
+	strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemName, "OcppSoftwareVersion");
+	strcpy((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData, "" );
+	*/
+
+	fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","OcppSoftwareVersion", "true", (char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData);
 
 	//* Local Auth List Management Profile*/
 	//LocalAuthListEnabled
@@ -18391,6 +18412,24 @@ void getKeyValue(char *keyReq)
 			  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_CharingProfileRefreshInterval].Value, (const char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[CharingProfileRefreshInterval].ItemData );
 			  isKnowKey = TRUE;
 		  }
+
+		  if(isEmpty ||  strcmp(keyReq, "OcppSoftwareVersion") == 0 )
+		  {
+			  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.Key[GetConfiguration_OcppSoftwareVersion].Item, "OcppSoftwareVersion");
+			  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].Key, "OcppSoftwareVersion");
+
+			  if(ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemAccessibility == 1)
+			  {
+				  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].ReadOnly, "0"/*"FALSE"*/);
+			  }
+			  else
+			  {
+				  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].ReadOnly, "1"/*"TRUE"*/);
+			  }
+
+			  strcpy((char *)ShmOCPP16DataPH->GetConfiguration.ResponseConfigurationKey[GetConfiguration_OcppSoftwareVersion].Value, (const char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[OcppSoftwareVersion].ItemData );
+			  isKnowKey = TRUE;
+		  }
 #if 1
 	      if(isEmpty ||  strcmp(keyReq, "LocalAuthListEnabled") == 0 )
 	      {

+ 1 - 0
EVSE/Modularization/ocppph/MessageHandler.h

@@ -414,6 +414,7 @@ enum GetConfigurationKey {
 	GetConfiguration_MaxChargingProfilesInstalled,
 	GetConfiguration_ConfigurationVersion,
 	GetConfiguration_CharingProfileRefreshInterval,
+	GetConfiguration_OcppSoftwareVersion,
 	_GetConfiguration_CNT
 };
 

+ 2 - 1
EVSE/Modularization/ocppph/Module_OcppBackend.c

@@ -1326,7 +1326,8 @@ int main(void)
 	queueOpInfo.IsUsing = FALSE;
 	queueOpInfo.TransactionMessageResend = 0;
 
-	DEBUG_INFO("Module_OcppBackend task initialization...\n");
+	DEBUG_INFO("Module_OcppBackendPH task initialization...\n");
+	DEBUG_INFO("Last update date: 2022/08/05 \n");
 	//lws_set_log_level(LLL_PARSER | LLL_HEADER | LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO | LLL_DEBUG | LLL_EXT | LLL_CLIENT | LLL_LATENCY  , NULL);
 
 	if(ProcessShareMemory()== FAIL)

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

@@ -4,7 +4,10 @@ export PATH=/bin:/sbin:/usr/bin:$(SDK_PATH_TARGET)/usr/bin:$PATH
 #define library variable
 Lib_Module_RFID = "-L../../../Modularization" -lModule_RFID
 Lib_Module_Upgrade = "-L../../../Modularization" -lModule_Upgrade
+Lib_Module_RatedCurrent = "-L../../../Modularization" -lm -lModule_RatedCurrent
 Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
+Lib_JSONC = "-L../../../GPL/json-c-json-c-0.13.1-20180305/release/lib" -ljson-c
+
 
 all: CopyFile apps
 apps: Module_InternalComm_Task Module_FactoryConfig_Task Module_AlarmDetect_Task Module_CSU_Task Module_Speaker_Task Module_ConfigTools_Task Module_Debug_Task
@@ -73,8 +76,8 @@ Module_AlarmDetect_Task:
 Module_CSU_Task:
 	@echo "===== Module_CSU_Task ============================================"
 	rm -f main 
-	$(CC) -D $(Project) "-I../../" "-include../../../Modularization/ocppfiles/sqlite3.h" "-include../../../Modularization/Module_Upgrade.h" "-include../../../Modularization/Module_RFID.h" -O0  -Wall -c -fmessage-length=0 -o main.o "./main.c"
-	$(CC) -o main main.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3}
+	$(CC) -D $(Project) "-I../../" "-include../../../GPL/json-c-json-c-0.13.1-20180305/release/include/json-c/json.h" "-include../../../Modularization/ocppfiles/sqlite3.h" "-include../../../Modularization/Module_Upgrade.h" "-include../../../Modularization/Module_RFID.h" "-include../../../Modularization/Module_RatedCurrent.h" -O0  -Wall -c -fmessage-length=0 -o main.o "./main.c"
+	$(CC) -o main main.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3} ${Lib_Module_RatedCurrent} ${Lib_JSONC} 
 	rm -f *.o
 	mv -f main ../Images/root		
 	@echo \

+ 52 - 39
EVSE/Projects/AW-Regular/Apps/Module_FactoryConfig.c

@@ -15,12 +15,12 @@
 
 #include 	<unistd.h>
 #include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
+#include    <stdio.h>
+#include    <stdlib.h>
+#include    <unistd.h>
+#include    <fcntl.h>
+#include    <termios.h>
+#include    <errno.h>
 #include 	<errno.h>
 #include 	<string.h>
 #include	<time.h>
@@ -264,23 +264,25 @@ int main(int argc, char *argv[])
 	{
 		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.CsuBootLoadFwRev, ShmSysConfigAndInfo->SysConfig.CsuBootLoadFwRev, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.CsuBootLoadFwRev));
 
 		DEBUG_INFO("InitShareMemory OK.\n");
 	}
 	
 	sprintf((char*)SysConfig.SystemId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 	sprintf((char*)SysConfig.SystemDateTime, "%d-%d-%d %d:%d:%d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
-	SysConfig.AuthorisationMode = 0;	// 0: enable, 1: disable
-	SysConfig.DefaultLanguage  = 0;		// 0:English	1:Big5				2: GB			3: JN		4: Français 	5: Italiano		6: Español		7: Deutsch		8: Nederland	9: Norsk	10: Suomalainen		11: Svenska		12: Pусский		13: ไทย
-	SysConfig.RfidCardNumEndian = 0;	// 0: Little endian		1: Big endian
+	SysConfig.AuthorisationMode = 0;		// 0: enable, 1: disable
+	SysConfig.DefaultLanguage  = 0;			// 0: English 1: Big5 2: GB 3: JN 4: Français 5: Italiano 6: Español 7: Deutsch 8: Nederland 9: Norsk 10: Suomalainen 11: Svenska 12: Pусский 13: ไทย
+	SysConfig.RfidCardNumEndian = 0;		// 0: Little endian 1: Big endian
+	SysConfig.BillingData.isBilling = 0;	// 0: not for business	1: for business
 
 	// Charging configuration
-	SysConfig.MaxChargingEnergy = 0;	// 0: No limit	Other: 1~65536 KWH
-	SysConfig.MaxChargingPower = 0;		// 0: No limit	Other: 1~65536 KW
-	SysConfig.MaxChargingCurrent = 0;	// 0: Rating value	Other: 1~Rating A
-	SysConfig.MaxChargingDuration = 0;	// 0: No limit	Other: 1~65536 Minute
-	SysConfig.PhaseLossPolicy = 0;		// 0: Charging	1: Stop charging
-	SysConfig.AcPhaseCount = 1;			// 1: One phase	3: Three phase
+	SysConfig.MaxChargingEnergy = 0;		// 0: No limit	Other: 1~65536 KWH
+	SysConfig.MaxChargingPower = 0;			// 0: No limit	Other: 1~65536 KW
+	SysConfig.MaxChargingCurrent = 0;		// 0: Rating value	Other: 1~Rating A
+	SysConfig.MaxChargingDuration = 0;		// 0: No limit	Other: 1~65536 Minute
+	SysConfig.PhaseLossPolicy = 0;			// 0: Charging	1: Stop charging
+	SysConfig.AcPhaseCount = 1;				// 1: One phase	3: Three phase
 
 	// Network configuration
 	strcpy((char*)SysConfig.FtpServer, "");
@@ -294,26 +296,37 @@ int main(int argc, char *argv[])
 	strcpy((char*)SysConfig.Eth1Interface.EthSubmaskAddress, "255.255.255.0");
 	strcpy((char*)SysConfig.Eth1Interface.EthGatewayAddress, "192.168.0.254");
 
-	SysConfig.AthInterface.WifiMode = 2;		// 0: Disable	1: Infrastructure client	2: Infrastructure server	3: Ad-Hoc
-	SysConfig.AthInterface.WifiRssi = 0;		// Wifi rssi value
-	SysConfig.AthInterface.WifiDhcpServer = 0;	// 0: Enable	1: Disable
-	SysConfig.AthInterface.WifiDhcpClient = 0;	// 0: Enable	1: Disable
-
-	strcpy((char*)SysConfig.TelecomInterface.TelcomApn, "");
-	SysConfig.TelecomInterface.TelcomEnabled = 1; 	//0: disable, 1: enable
-	SysConfig.TelecomInterface.TelcomSimStatus = 0;	// SIM card status
-	SysConfig.TelecomInterface.TelcomModemMode = 0;	//0: No services	1: CDMA		2: GSM/GPRS	3: WCDMA	4: GSM/WCDMA	5: TD_SCDMA		6: Unknown
+	// Wifi configuration
+	SysConfig.AthInterface.WifiMode = 2;								// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
+	SysConfig.AthInterface.WifiRssi = 0;								// Wifi rssi value
+	strcpy((char *) SysConfig.AthInterface.WifiSsid, "");				// default: Null
+	strcpy((char *) SysConfig.AthInterface.WifiPassword, "");			// default: Null
+	SysConfig.AthInterface.WifiDhcpServer = 0;							// 0: Enable 1: Disable
+	SysConfig.AthInterface.WifiDhcpClient = 0;							// 0: Enable 1: Disable
+	SysConfig.AthInterface.WifiBroadcastSsid = 1;						// 0: hidden 1: broadcast
+
+	// Telecom configuration
+	strcpy((char*)SysConfig.TelecomInterface.TelcomApn, "");			// default: Null
+	SysConfig.TelecomInterface.TelcomEnabled = 1; 						// 0: disable, 1: enable
+	SysConfig.TelecomInterface.TelcomRssi = 0;							// default: 0
+	SysConfig.TelecomInterface.TelcomSimStatus = 0;						// SIM card status
+	SysConfig.TelecomInterface.TelcomModemMode = 0;						// 0: No services 1: CDMA 2: GSM/GPRS 3: WCDMA 4: GSM/WCDMA 5: TD_SCDMA 6: Unknown
+	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapId, "");	// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapPwd, "");	// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomModemImei, "");	// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomSimImsi, "");		// default: Null
+	strcpy((char *) SysConfig.TelecomInterface.TelcomSimIccid, "");		// default: Null
 
 	// Backend configuration
 	strcpy((char*)SysConfig.OcppServerURL, "");
 	sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
-	strcpy((char *)SysConfig.chargePointVendor, "");	// default: Null
+	strcpy((char *)SysConfig.chargePointVendor, "");					// default: Null
 	strcpy((char*)SysConfig.MaintainServerURL, "");
-	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
-	//SysConfig.isReqFirstUpgrade = 1;		// 0: Skip first upgrade, 	1: Process first upgrade
+	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
+	//SysConfig.isReqFirstUpgrade = 1;									// 0: Skip first upgrade, 	1: Process first upgrade
 
 	// Customization configuration item
 	if(SysConfig.ModelName[12] == 'P')
@@ -321,16 +334,16 @@ int main(int argc, char *argv[])
 		// Phihong standard configuration
 		strcpy((char*)SysConfig.OcppServerURL, "");
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
-		strcpy((char *)SysConfig.chargePointVendor, "");	// default: Null
+		strcpy((char *)SysConfig.chargePointVendor, "");				// default: Null
 		strcpy((char*)SysConfig.MaintainServerURL, "wss://ocpp.phihong.com.tw:2013/");
 	}
 	else if(SysConfig.ModelName[12] == 'A')
 	{
 		// ChargeLab customization configuration
-		SysConfig.AuthorisationMode = 0;	// 0: enable, 1: disable
-		SysConfig.RfidCardNumEndian = 1;	// 0: Little endian	1: Big endian
+		SysConfig.AuthorisationMode = 0;								// 0: enable, 1: disable
+		SysConfig.RfidCardNumEndian = 1;								// 0: Little endian	1: Big endian
 		
-		SysConfig.AthInterface.WifiMode = 1;		// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
+		SysConfig.AthInterface.WifiMode = 1;							// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
 		strcpy((char*)SysConfig.AthInterface.WifiSsid, "ChargeLab-EVC");
 		strcpy((char*)SysConfig.AthInterface.WifiPassword, "evc-pwd-default-21");
 		
@@ -339,15 +352,15 @@ int main(int argc, char *argv[])
 		strcpy((char*)SysConfig.OcppServerURL, "wss://ocpp.io");
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 		strcpy((char*)SysConfig.chargePointVendor, "ChargeLab");
-		SysConfig.OfflinePolicy = 0;			// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
+		SysConfig.OfflinePolicy = 0;									// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
 	}
 	else if(SysConfig.ModelName[12] == 'T')
 	{
 		// ChargeLab customization configuration
-		SysConfig.AuthorisationMode = 0;	// 0: enable, 1: disable
-		SysConfig.RfidCardNumEndian = 1;	// 0: Little endian	1: Big endian
+		SysConfig.AuthorisationMode = 0;								// 0: enable, 1: disable
+		SysConfig.RfidCardNumEndian = 1;								// 0: Little endian	1: Big endian
 		
-		SysConfig.AthInterface.WifiMode = 1;		// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
+		SysConfig.AthInterface.WifiMode = 1;							// 0: Disable 1: Infrastructure client 2: Infrastructure server	3: Ad-Hoc
 		strcpy((char*)SysConfig.AthInterface.WifiSsid, "ChargeLab-EVC");
 		strcpy((char*)SysConfig.AthInterface.WifiPassword, "evc-pwd-default-21");
 		
@@ -356,7 +369,7 @@ int main(int argc, char *argv[])
 		strcpy((char*)SysConfig.OcppServerURL, "wss://ocpp.io");
 		sprintf((char*)SysConfig.ChargeBoxId, "%s%s", SysConfig.ModelName, SysConfig.SerialNumber);
 		strcpy((char*)SysConfig.chargePointVendor, "ChargeLab");
-		SysConfig.OfflinePolicy = 0;			// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
+		SysConfig.OfflinePolicy = 0;									// 0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
 	}
 	else
 	{

+ 125 - 3
EVSE/Projects/AW-Regular/Apps/main.c

@@ -91,6 +91,7 @@ struct timeb					endChargingTime[AC_QUANTITY];
 sqlite3 *localDb;
 
 struct SysConfigData			SysConfigOrg;
+ParsingRatedCur 				modelnameInfo={0};
 
 struct PreviousData
 {
@@ -432,6 +433,31 @@ int getEth0MacAddress()
 	return result;
 }
 
+int isUap0up(void)
+{
+	int result = FAIL;
+
+	FILE *fp;
+	char cmd[256];
+	char buf[512];
+
+	strcpy(cmd, "ifconfig uap0");;
+	fp = popen(cmd, "r");
+	if(fp != NULL)
+	{
+		while(fgets(buf, sizeof(buf), fp) != NULL)
+		{
+			if(strstr(buf, "uap0") > 0)
+			{
+				result = PASS;
+			}
+		}
+	}
+	pclose(fp);
+
+	return result;
+}
+
 //======================================================
 // OCPP routine
 //======================================================
@@ -1729,13 +1755,20 @@ void InitGPIO()
 	system("echo \"out\" > /sys/class/gpio/gpio65/direction");
 	system("echo 0 > /sys/class/gpio/gpio65/value");
 
-	/*POWER (4G/WIFI) RST:GPIO3_14 => H:ON; L:OFF*/
+	/*(FOR ACCSU-01-RW) 4G POWER RST:GPIO3_14 => H:ON; L:OFF*/
 	system("echo 110 > /sys/class/gpio/export");
 	system("echo \"out\" > /sys/class/gpio/gpio110/direction");
 	system("echo 1 > /sys/class/gpio/gpio110/value");
 	sleep(3);
 	system("echo 0 > /sys/class/gpio/gpio110/value");
 
+	/*(FOR ACCSU3P5-01-RW) 4G POWER RST:GPIO3_18 => H:ON; L:OFF*/
+	system("echo 114 > /sys/class/gpio/export");
+	system("echo \"out\" > /sys/class/gpio/gpio114/direction");
+	system("echo 1 > /sys/class/gpio/gpio114/value");
+	sleep(3);
+	system("echo 0 > /sys/class/gpio/gpio114/value");
+
 	DEBUG_INFO("Initial GPIO OK\n");
 }
 
@@ -1972,6 +2005,8 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 	}
 
 	DEBUG_INFO("Load SysConfigData OK\n");
+	
+	RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo);
 
 	return PASS;
 }
@@ -2045,6 +2080,11 @@ void InitEthernet()
 	char tmpbuf[256];
 	unsigned int natInterface = 0;
 
+	// Detele bridge interface
+	system("/sbin/ifconfig uap0 down");
+	system("/sbin/ifconfig br0 down");
+	system("/usr/sbin/brctl delbr br0");
+
 	//Init Eth0 for internet
 	memset(tmpbuf,0,256);
 	sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
@@ -2266,17 +2306,34 @@ void InitEthernet()
 
 			// Check is need to reset WIFI/4G module power
 			if((!ShmSysConfigAndInfo->SysInfo.OcppConnStatus) &&
-			   ((system("pidof -s Module_Wifi > /dev/null") != 0) || (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 0) || ((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON)) || ((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))) &&
-			   ((system("pidof -s Module_4g > /dev/null") != 0) || (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 0) || ((ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApnDisconnectVia4Gi == ON))))
+			
+			   ((system("pidof -s Module_Wifi > /dev/null") != 0) || 
+			    (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 0) || 
+				((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON)) || 
+				((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))) &&
+				
+			    ((system("pidof -s Module_4g > /dev/null") != 0) || 
+				 (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 0) || 
+				 ((ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApnDisconnectVia4Gi == ON))))
 			{
 				if(DiffTimebWithNow(startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]) > TIMEOUT_SPEC_RESET_4G_WIFI_POWER)
 				{
 					if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode != 0) || (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled != 0))
 					{
 						DEBUG_WARN("WIFI/4G module reset.\n");
+
+						// FOR ACCSU-01-RW RESET 4G
 						system("echo 1 > /sys/class/gpio/gpio110/value");
+
+						// FOR ACCSU3P5-01-RW RESET 4G
+						system("echo 1 > /sys/class/gpio/gpio114/value");
 						sleep(3);
+
+						// FOR ACCSU-01-RW RESET 4G
 						system("echo 0 > /sys/class/gpio/gpio110/value");
+
+						// FOR ACCSU3P5-01-RW RESET 4G
+						system("echo 0 > /sys/class/gpio/gpio114/value");
 					}
 
 					ftime(&startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]);
@@ -2287,6 +2344,33 @@ void InitEthernet()
 				ftime(&startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]);
 			}
 
+			// Bridge ethernet to uap0 to get dynamic ip address
+			if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing &&
+			  (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) &&
+			  (isUap0up() == PASS) &&
+			  (access("/sys/class/net/br0/address", F_OK) == -1))
+			{
+				sleep(10);
+				system("/usr/sbin/brctl addbr br0");
+				system("/usr/sbin/brctl addif br0 eth0");
+				system("/usr/sbin/brctl addif br0 uap0");
+				system("/sbin/ifconfig br0 192.168.10.200 up");
+				system("/bin/sed -i '/interface/d' /etc/udhcpd.conf");
+				system("/bin/echo 'interface	br0' >> /etc/udhcpd.conf");
+				system("kill udhcpd");
+				system("/usr/sbin/udhcpd /etc/udhcpd.conf");
+
+				DEBUG_INFO("Bridge uap0 & eth0 for local power sharing by ethernet.\n");
+			}
+
+			// Change uap0 to low priority
+			if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing &&
+			  (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) &&
+			  (isUap0up() == PASS))
+			{
+				system("/sbin/ifmetric uap0 1");
+			}
+
 			sleep(5);
 		}
 	}
@@ -3462,6 +3546,13 @@ void checkTask()
 		DEBUG_INFO("Module_ProduceUtils not running, restart it.\n");
 		system ("/root/Module_ProduceUtils &");
 	}
+
+	if((system("pidof -s Module_PowerSharing > /dev/null") != 0) &&
+		ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing)
+	{
+		DEBUG_INFO("Module_PowerSharing not running, restart it.\n");
+		system ("/root/Module_PowerSharing &");
+	}
 }
 
 void checkConnectionTimeout()
@@ -3801,6 +3892,20 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 		}
 	}
 
+	// Charging session target current check if OCPP disconnect and power sharing server connected
+	if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing > 0)
+	{
+		if(ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer)
+		   ShmCharger->gun_info[gun_index].targetCurrent = ShmSysConfigAndInfo->SysInfo.localSharingInfo.AvailableShargingCurrent[gun_index]>ShmCharger->gun_info[gun_index].primaryMcuState.rating_current?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmSysConfigAndInfo->SysInfo.localSharingInfo.AvailableShargingCurrent[gun_index];
+		else
+		{
+			if(ShmCharger->gun_info[gun_index].targetCurrent != 0)
+				DEBUG_WARN("Disconnect from power sharing server, target current set to 0.\n");
+
+			ShmCharger->gun_info[gun_index].targetCurrent = 0;
+		}
+	}
+
 	switch(system_mode)
 	{
 		case SYS_MODE_IDLE:
@@ -4236,6 +4341,23 @@ int main(void)
 			}
 		}
 
+		//==============================================
+		// Check Local Power Sharing Communication
+		//==============================================
+		if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing > 0)
+		{
+			if(ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer)
+			{
+				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError == ON)
+					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError = OFF;
+			}
+			else
+			{
+				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError == OFF)
+					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError = ON;
+			}
+		}
+
 		//==============================================
 		// Connector loop
 		//==============================================

+ 11 - 0
EVSE/Projects/define.h

@@ -345,6 +345,7 @@ enum CoreProfile {
      OffLineMaxChargingPower,
      ConfigurationVersion,
 	 CharingProfileRefreshInterval,
+	 OcppSoftwareVersion,
 	 _CoreProfile_CNT
 };
 
@@ -4781,6 +4782,15 @@ struct StructTcciCustomData
     unsigned char ChargerInfoConf:1;
     unsigned char WeatherInfoReq:1;
     unsigned char WeatherInfoConf:1;
+    unsigned char :3;                  // bit 5-7 , reserved
+};
+
+struct OCMFData
+{
+	unsigned char SendOcmfDataReq:1;   // bit 0 , Flag to ask OCPP sending OCMF message to backend.
+	unsigned char :7;                  // bit 1-7 , reserved
+	unsigned char DataString[2048];    // Data got from meter.
+	unsigned char PublicKey[256];      // PublicKey with header got from meter.
 };
 
 struct OCPP16Data
@@ -4973,6 +4983,7 @@ struct OCPP16Data
     struct StructSignedFirmwareStatusNotification   SignedFirmwareStatusNotification;
     struct StructSessionTarget                      SessionTarget[CONNECTOR_QUANTITY];
     struct StructTcciCustomData                     TcciCustomData;
+    struct OCMFData                                 OcmfData[CONNECTOR_QUANTITY];
 };
 
 

+ 1 - 1
Makefile

@@ -547,7 +547,7 @@ AW-Regular-uboot:
 	@echo    Building U-boot
 	@echo ===================================
 	@cp -f $(UBOOT_INSTALL_DIR)/arch/arm/dts/[AW-Regular]am335x-evm.dts $(UBOOT_INSTALL_DIR)/arch/arm/dts/am335x-evm.dts
-	$(MAKE) -j $(MAKE_JOBS) -C $(UBOOT_INSTALL_DIR) CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08_BCH16 DDR_IC=MT41K256M16HA125E_303 PMIC=TPS65910
+	$(MAKE) -j $(MAKE_JOBS) -C $(UBOOT_INSTALL_DIR) CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08_BCH16 DDR_IC=MT41K256M16HA125E_303 PMIC=TPS65217
 	@cp -f $(UBOOT_INSTALL_DIR)/MLO EVSE/Projects/AW-Regular/Images/
 	@cp -f $(UBOOT_INSTALL_DIR)/u-boot.img EVSE/Projects/AW-Regular/Images/
 	@cp -f $(UBOOT_INSTALL_DIR)/spl/u-boot-spl.bin EVSE/Projects/AW-Regular/Images/

+ 44 - 53
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/[AW-Regular]am335x-evm.dts

@@ -25,7 +25,7 @@
 
 	cpus {
 		cpu@0 {
-			cpu0-supply = <&vdd1_reg>;
+			cpu0-supply = <&dcdc2_reg>;
 		};
 	};
 
@@ -65,7 +65,7 @@
 		
 			/** Offset: 0x800 */
 			/** GPIO 0 */ 
-			0x144 (PIN_INPUT | MUX_MODE7)    			/* RMII1_REF_CLK		=>	GPIO0_29 */	/*USB 0 OCP detection*/
+			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 */			
@@ -80,6 +80,7 @@
 			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 */
+			0x1A0 (PIN_OUTPUT | MUX_MODE7)          /* MCASP0_AXR1  =>  GPIO3_18 */ /*control 4G reset pin*/
 			0x1A8 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_AXR1	=>	GPIO3_20 */	/*control MCU to output CP PWM*/
 		>;
 	};
@@ -323,8 +324,8 @@
 	status = "okay";
 	clock-frequency = <400000>;
 
-	tps: tps@2d {
-		reg = <0x2d>;
+	tps: tps@24 {
+		reg = <0x24>;
 	};
 
 /*	rtc0: rtc@51 {
@@ -406,7 +407,7 @@
 	pinctrl-0 = <&nandflash_pins_default>;
 	pinctrl-1 = <&nandflash_pins_sleep>;
 	/*ranges = <0 0 0x08000000 0x10000000>;*/	/* CS0: NAND */
-	ranges = <0 0 0x08000000 0x80000000>;	/*+++ vern,NAND,20181030 ---*/
+	ranges = <0 0 0x08000000 0x40000000>;	/*+++ vern,NAND,20181030 ---*/
 	nand@0,0 {
 		compatible = "ti,omap2-nand";
 		reg = <0 0 4>; /* CS0, offset 0, IO size 4 */
@@ -500,85 +501,74 @@
 		};
 		partition@13 {
 			label = "Storage";
-			reg = <0x0A200000 0x75E00000>;
+			reg = <0x0A200000 0x35E00000>;
 		};
 	};
 };
 
-#include "tps65910.dtsi"
+/include/ "tps65217.dtsi"
 
 &tps {
-	vcc1-supply = <&vbat>;
-	vcc2-supply = <&vbat>;
-	vcc3-supply = <&vbat>;
-	vcc4-supply = <&vbat>;
-	vcc5-supply = <&vbat>;
-	vcc6-supply = <&vbat>;
-	vcc7-supply = <&vbat>;
-	vccio-supply = <&vbat>;
+	/*
+	 * Configure pmic to enter OFF-state instead of SLEEP-state ("RTC-only
+	 * mode") at poweroff.  Most BeagleBone versions do not support RTC-only
+	 * mode and risk hardware damage if this mode is entered.
+	 *
+	 * For details, see linux-omap mailing list May 2015 thread
+	 *	[PATCH] ARM: dts: am335x-bone* enable pmic-shutdown-controller
+	 * In particular, messages:
+	 *	http://www.spinics.net/lists/linux-omap/msg118585.html
+	 *	http://www.spinics.net/lists/linux-omap/msg118615.html
+	 *
+	 * You can override this later with
+	 *	&tps {  /delete-property/ ti,pmic-shutdown-controller;  }
+	 * if you want to use RTC-only mode and made sure you are not affected
+	 * by the hardware problems. (Tip: double-check by performing a current
+	 * measurement after shutdown: it should be less than 1 mA.)
+	 */
+	ti,pmic-shutdown-controller;
 
 	regulators {
-		vrtc_reg: regulator@0 {
+		dcdc1_reg: regulator@0 {
+			regulator-name = "vdds_dpr";
 			regulator-always-on;
 		};
 
-		vio_reg: regulator@1 {
-			regulator-always-on;
-		};
-
-		vdd1_reg: regulator@2 {
-			/* VDD_MPU voltage limits 0.95V - 1.325V with +/-4% tolerance */
+		dcdc2_reg: regulator@1 {
+			/* VDD_MPU voltage limits 0.95V - 1.26V with +/-4% tolerance */
 			regulator-name = "vdd_mpu";
-			regulator-min-microvolt = <912500>;
-			regulator-max-microvolt = <1378000>;
+			regulator-min-microvolt = <1100000>;
+			regulator-max-microvolt = <1351500>;
 			regulator-boot-on;
 			regulator-always-on;
 		};
 
-		vdd2_reg: regulator@3 {
+		dcdc3_reg: regulator@2 {
 			/* VDD_CORE voltage limits 0.95V - 1.1V with +/-4% tolerance */
 			regulator-name = "vdd_core";
-			regulator-min-microvolt = <912500>;
+			regulator-min-microvolt = <925000>;
 			regulator-max-microvolt = <1150000>;
 			regulator-boot-on;
 			regulator-always-on;
 		};
 
-		vdd3_reg: regulator@4 {
-			regulator-always-on;
-		};
-
-		vdig1_reg: regulator@5 {
+		ldo1_reg: regulator@3 {
+			regulator-name = "vio,vrtc,vdds";
 			regulator-always-on;
 		};
 
-		vdig2_reg: regulator@6 {
+		ldo2_reg: regulator@4 {
+			regulator-name = "vdd_3v3aux";
 			regulator-always-on;
 		};
 
-		vpll_reg: regulator@7 {
+		ldo3_reg: regulator@5 {
+			regulator-name = "vdd_1v8";
 			regulator-always-on;
 		};
 
-		vdac_reg: regulator@8 {
-			regulator-always-on;
-		};
-
-		vaux1_reg: regulator@9 {
-			regulator-always-on;
-		};
-
-		vaux2_reg: regulator@10 {
-			regulator-always-on;
-		};
-
-		vaux33_reg: regulator@11 {
-			regulator-always-on;
-		};
-
-		vmmc_reg: regulator@12 {
-			regulator-min-microvolt = <1800000>;
-			regulator-max-microvolt = <3300000>;
+		ldo4_reg: regulator@6 {
+			regulator-name = "vdd_3v3a";
 			regulator-always-on;
 		};
 	};
@@ -604,6 +594,7 @@
  	phy-mode = "mii";
 
 };
+
 #if 0
 &cpsw_emac1 {
 	phy_id = <&davinci_mdio>, <2>;
@@ -628,7 +619,7 @@
 
 &mmc1 {
 	status = "okay";
-	vmmc-supply = <&vmmc_reg>;
+	vmmc-supply = <&ldo4_reg>;
 	bus-width = <4>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc1_pins_default>;

+ 1 - 0
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/.MLO.byteswap.cmd

@@ -0,0 +1 @@
+cmd_MLO.byteswap := ./tools/mkimage -T omapimage -n byteswap -a 0x402F0400 -d spl/u-boot-spl.bin MLO.byteswap  >/dev/null

+ 1 - 0
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/.MLO.cmd

@@ -0,0 +1 @@
+cmd_MLO := ./tools/mkimage -T omapimage -a 0x402F0400 -d spl/u-boot-spl.bin MLO  >/dev/null