소스 검색

2021.07.09 / Jerry Wang

Actions:
1. Merge branch 'master' into DD360Audi
2. Version release to v1.10

Files:
1. As follow as commit history.
Jerry_Wang 3 년 전
부모
커밋
e354ad1c11

+ 100 - 4
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -875,6 +875,96 @@ typedef union
 }CpinitiateMsg;
 
 CpinitiateMsg cpinitateMsg;
+
+//=========================================
+// Save configuration
+//=========================================
+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;
+}
+
+int StoreUsrConfigData(struct SysConfigData *UsrData)
+{
+	int result = PASS;
+	int fd,wrd;
+	unsigned int i,Chk;
+	unsigned char *ptr, *BufTmp;
+	int MtdBlockSize = 0x300000;
+
+	Chk=0;
+	ptr=(unsigned char *)UsrData;
+	if((BufTmp=malloc(MtdBlockSize))!=NULL)
+	{
+		memset(BufTmp,0,MtdBlockSize);
+		memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
+		for(i=ARRAY_SIZE(UsrData->CsuBootLoadFwRev);i<MtdBlockSize-4;i++)
+			Chk+=*(BufTmp+i);
+		memcpy(BufTmp+MtdBlockSize-4, &Chk, 4);
+
+		// Output configuration to file.
+		fd = open("/mnt/EvseConfig.bin", O_RDWR|O_CREAT);
+		if (fd < 0)
+		{
+			DEBUG_ERROR("open /mnt/EvseConfig.bin NG\n");
+
+			free(BufTmp);
+			return 0;
+		}
+		wrd=write(fd, BufTmp, MtdBlockSize);
+		close(fd);
+		if(wrd<MtdBlockSize)
+		{
+			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 0");
+		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 0");
+		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\r\n");
+			result = FAIL;
+	}
+
+	if(BufTmp!=NULL)
+		free(BufTmp);
+
+	return result;
+}
+
 //=========================================
 // Date time related function
 //=========================================
@@ -2124,7 +2214,7 @@ int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char
 		ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]);
-		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, " ");
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword);
 		DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
 
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
@@ -2158,7 +2248,7 @@ int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
-		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "0");
+		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "%d", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
 		DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
 
 		sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
@@ -12585,7 +12675,7 @@ void* GetLogProcess(void* data)
 				   protocol, user, password, host, &port, path);
 	}
 
-	if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
+	if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0)&&(strcmp(protocol,"https")!=0))
 	{
 		DEBUG_INFO("protocol is not ftp/http ! \n");
 		sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
@@ -15120,6 +15210,12 @@ int handleSetVariablesRequest(char *uuid, char *payload)
 							}
 							else
 								strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
+
+							if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SecurityCtrlr") != NULL) &&
+							   ((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "SecurityProfile") != NULL) || (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "BasicAuthPassword") != NULL)))
+							{
+								StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
+							}
 						}
 					}
 				}
@@ -17039,7 +17135,7 @@ uint8_t GetOcppSecurityProfile()
 
 void GetOcppChargerBoxId(uint8_t *data)
 {
-	sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
+	sprintf((char*)data, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
 }
 
 void GetOcppSecurityPassword(uint8_t *data)

+ 110 - 14
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -405,6 +405,95 @@ static char * UnitOfMeasureStr[] = {
 	MACROSTR(Percent)
 };
 
+//=========================================
+// Save configuration
+//=========================================
+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;
+}
+
+int StoreUsrConfigData(struct SysConfigData *UsrData)
+{
+	int result = PASS;
+	int fd,wrd;
+	unsigned int i,Chk;
+	unsigned char *ptr, *BufTmp;
+	int MtdBlockSize = 0x300000;
+
+	Chk=0;
+	ptr=(unsigned char *)UsrData;
+	if((BufTmp=malloc(MtdBlockSize))!=NULL)
+	{
+		memset(BufTmp,0,MtdBlockSize);
+		memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
+		for(i=ARRAY_SIZE(UsrData->CsuBootLoadFwRev);i<MtdBlockSize-4;i++)
+			Chk+=*(BufTmp+i);
+		memcpy(BufTmp+MtdBlockSize-4, &Chk, 4);
+
+		// Output configuration to file.
+		fd = open("/mnt/EvseConfig.bin", O_RDWR|O_CREAT);
+		if (fd < 0)
+		{
+			DEBUG_ERROR("open /mnt/EvseConfig.bin NG\n");
+
+			free(BufTmp);
+			return 0;
+		}
+		wrd=write(fd, BufTmp, MtdBlockSize);
+		close(fd);
+		if(wrd<MtdBlockSize)
+		{
+			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 0");
+		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 0");
+		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\r\n");
+			result = FAIL;
+	}
+
+	if(BufTmp!=NULL)
+		free(BufTmp);
+
+	return result;
+}
+
 //=========================================
 // Sqlite3 related function
 //=========================================
@@ -9012,7 +9101,7 @@ void* GetDiagnosticsProcess(void* data)
 				   protocol, user, password, host, &port, path);
 	}
 
-	if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
+	if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0)&&(strcmp(protocol,"https")!=0))
 	{
 		DEBUG_INFO("protocol is not ftp/http ! \n");
 		sprintf((char*)ShmOCPP16Data->DiagnosticsStatusNotification.Status, "%s", DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
@@ -11017,8 +11106,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 				{
-					if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
-					   (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
+					if((SYS_MODE_PREPARING <= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus) &&
+					   (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -11044,8 +11133,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 				{
-					if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
-					   (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
+					if((SYS_MODE_PREPARING <= ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus) &&
+					   (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -11072,8 +11161,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 				{
-					if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
-					   (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
+					if((SYS_MODE_PREPARING <= ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus) &&
+					   (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -11092,8 +11181,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
 				{
-					if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
-					   (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
+					if((SYS_MODE_PREPARING <= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus) &&
+					   (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -12997,14 +13086,14 @@ int initialConfigurationTable(void)
 		// AuthorizationKey
 		ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemAccessibility = 1;
 		strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemName, "AuthorizationKey");
-		strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, "" );
+		strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, (char*)ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword);
 
 		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","AuthorizationKey", "false", ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData);
 
 		// SecurityProfile
 		ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemAccessibility = 1;
 		strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemName, "SecurityProfile");
-		strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData, "0" );
+		sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData, "%d", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
 
 		fprintf(outfile,"{\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}\n","SecurityProfile", "false", ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData);
 
@@ -13405,13 +13494,14 @@ int initialConfigurationTable(void)
 				if(strcmp(keystr, "AuthorizationKey") == 0)
 				{
 					ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
-					sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, "%s", valuestr);
+					//sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, "%s", valuestr);
+					sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, "%s", ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword);
 				}
 
 				if(strcmp(keystr, "SecurityProfile") == 0)
 				{
 					ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
-					sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData, "%d", atoi(valuestr) );
+					sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData, "%d", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
 				}
 
 				if(strcmp(keystr, "DefaultPrice") == 0)
@@ -15734,6 +15824,9 @@ int setKeyValue(char *key, char *value)
     	{
     		strcpy(str, (const char*)value);
     		sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData, "%s", str);
+    		strcpy((char*)ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword, (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationKey].ItemData);
+    		StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
+
     		isSuccess = ConfigurationStatus_Accepted;
     	}
     	else
@@ -15760,6 +15853,9 @@ int setKeyValue(char *key, char *value)
     			if(atoi((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData) <= (check_ascii - 0x30))
     			{
     				sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SecurityProfile].ItemData, "%d", atoi(value) );
+    				ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile = atoi(value);
+    				StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
+
     				isSuccess = ConfigurationStatus_Accepted;
     			}
     			else
@@ -17622,7 +17718,7 @@ uint8_t GetOcppSecurityProfile()
 
 void GetOcppChargerBoxId(uint8_t *data)
 {
-	sprintf((char*)data, "%s", ShmOCPP16Data->ChargeBoxId);
+	sprintf((char*)data, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
 }
 
 void GetOcppSecurityPassword(uint8_t *data)

+ 2 - 0
EVSE/Projects/define.h

@@ -473,6 +473,8 @@ struct SysConfigData
 	unsigned char 			OcppServerURL[512];			//http: non-secure OCPP 1.5-S, https: secure OCPP 1.5-S, ws: non-secure OCPP 1.6-J, wss: secure OCPP 1.6-J"
 	unsigned char 			ChargeBoxId[128];
 	unsigned char			chargePointVendor[20];		//the Vendor of the ChargePoint
+	unsigned char			OcppSecurityProfile;		//OCPP security profile 0~3
+	unsigned char			OcppSecurityPassword[41];	//OCPP AuthorizationKey for security profile
 	unsigned int 			Checksum;					//4 bytes checksum
 	struct LED				LedInfo;					// LED configuration info
 	unsigned char			ShowInformation;

+ 3 - 1
EVSE/rootfs/var/www/ocpp_upload.php

@@ -20,7 +20,9 @@ curl_setopt_array($curl, array(
   CURLOPT_CONNECTTIMEOUT => 30,
   CURLOPT_STDERR          => $curl_log,
   CURLOPT_FOLLOWLOCATION => 0,
-  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2TLS,
+  CURLOPT_SSL_VERIFYPEER => 0,
+  CURLOPT_SSL_VERIFYHOST => 0,
   CURLOPT_CUSTOMREQUEST => "POST",
   CURLOPT_POSTFIELDS => array(''=> new CURLFILE(trim($content[1]),"application/zip",$file)),
   CURLOPT_HTTPHEADER => array(

+ 5 - 5
Makefile

@@ -545,7 +545,7 @@ AW-Regular-uboot:
 	@echo    Building U-boot
 	@echo ===================================
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[AW-Regular]am335x-evm.dts board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/am335x-evm.dts
-	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08
+	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F16G08_BCH16
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/AW-Regular/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/AW-Regular/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/AW-Regular/Images/
@@ -617,7 +617,7 @@ BYTON-GB-uboot:
 	@echo    Building U-boot
 	@echo ===================================
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[BYTON-GB]am335x-evm.dts board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/am335x-evm.dts
-	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F16G08
+	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F16G08_BCH16
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/BYTON-GB/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/BYTON-GB/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/BYTON-GB/Images/
@@ -1041,7 +1041,7 @@ Noodoe-uboot:
 	@echo    Building U-boot
 	@echo ===================================
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[Noodoe]am335x-evm.dts board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/am335x-evm.dts
-	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08
+	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F16G08_BCH16
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/Noodoe/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/Noodoe/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/Noodoe/Images/
@@ -1187,7 +1187,7 @@ AW-CCS-uboot:
 	@echo    Building U-boot
 	@echo ===================================
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[AW-CCS]am335x-evm.dts board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/am335x-evm.dts
-	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08
+	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08_BCH16
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/AW-CCS/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/AW-CCS/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/AW-CCS/Images/
@@ -1623,7 +1623,7 @@ AW-ChargeLab-uboot:
 	@echo    Building U-boot
 	@echo ===================================
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/[AW-ChargeLab]am335x-evm.dts board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/am335x-evm.dts
-	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F8G08
+	$(MAKE) -j $(MAKE_JOBS) -C $(TI_SDK_PATH)/board-support/u-boot-* CROSS_COMPILE=$(CROSS_COMPILE) FLASH_IC=MT29F16G08_BCH16
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/MLO EVSE/Projects/AW-ChargeLab/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/u-boot.img EVSE/Projects/AW-ChargeLab/Images/
 	@cp -f board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/spl/u-boot-spl.bin EVSE/Projects/AW-ChargeLab/Images/

+ 7 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/common/autoboot.c

@@ -17,7 +17,13 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define uboot_version "01.02"
+#if defined(MT29F16G08_BCH16)
+	#define uboot_version "02.01"
+#elif defined(MT29F8G08_BCH16)
+	#define uboot_version "03.01"
+#else
+	#define uboot_version "01.01"
+#endif
 
 #define MAX_DELAY_STOP_STR 32
 

+ 51 - 13
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/include/configs/am335x_evm.h

@@ -230,7 +230,7 @@
 
 #ifdef CONFIG_NAND
 /* NAND: device related configs */
-#if defined(MT29F8G08)
+#if defined(MT29F8G08_BCH16)
 	#define CONFIG_SYS_NAND_ECCPOS	{ 2, 3, 4, 5, 6, 7, 8, 9, \
 					  10, 11, 12, 13, 14, 15, 16, 17, 18, 19, \
 					  20, 21, 22, 23, 24, 25, 26, 27, 28, 29, \
@@ -257,6 +257,33 @@
 	#define CONFIG_SYS_NAND_OOBSIZE		256//64 /*++++ vern,NAND,20161127 ---*/
 	#define CONFIG_SYS_NAND_PAGE_SIZE	4096//2048 /*++++ vern,NAND,20161127 ---*/
 	#define CONFIG_SYS_NAND_BLOCK_SIZE	(64*4096)//(128*1024)/*++++ vern,NAND,20161127 ---*/
+#elif defined(MT29F16G08_BCH16)
+	#define CONFIG_SYS_NAND_ECCPOS  { 2, 3, 4, 5, 6, 7, 8, 9, \
+                                          10, 11, 12, 13, 14, 15, 16, 17, 18, 19, \
+                                          20, 21, 22, 23, 24, 25, 26, 27, 28, 29, \
+                                          30, 31, 32, 33, 34, 35, 36, 37, 38, 39, \
+                                          40, 41, 42, 43, 44, 45, 46, 47, 48, 49, \
+                                          50, 51, 52, 53, 54, 55, 56, 57, 58, 59, \
+                                          60, 61, 62, 63, 64, 65, 66, 67, 68, 69, \
+                                          70, 71, 72, 73, 74, 75, 76, 77, 78, 79, \
+                                          80, 81, 82, 83, 84, 85, 86, 87, 88, 89, \
+                                          90, 91, 92, 93, 94, 95, 96, 97, 98, 99, \
+                                          100, 101, 102, 103, 104, 105, 106, 107, 108, 109, \
+                                          110, 111, 112, 113, 114, 115, 116, 117, 118, 119, \
+                                          120, 121, 122, 123, 124, 125, 126, 127, 128, 129, \
+                                          130, 131, 132, 133, 134, 135, 136, 137, 138, 139, \
+                                          140, 141, 142, 143, 144, 145, 146, 147, 148, 149, \
+                                          150, 151, 152, 153, 154, 155, 156, 157, 158, 159, \
+                                          160, 161, 162, 163, 164, 165, 166, 167, 168, 169, \
+                                          170, 171, 172, 173, 174, 175, 176, 177, 178, 179, \
+                                          180, 181, 182, 183, 184, 185, 186, 187, 188, 189, \
+                                          190, 191, 192, 193, 194, 195, 196, 197, 198, 199, \
+                                          200, 201, 202, 203, 204, 205, 206, 207, 208, 209, }
+        #define CONFIG_SYS_NAND_ECCBYTES        26
+        #define CONFIG_NAND_OMAP_ECCSCHEME      OMAP_ECC_BCH16_CODE_HW
+        #define CONFIG_SYS_NAND_OOBSIZE         224//64 /*++++ vern,NAND,20161127 ---*/
+        #define CONFIG_SYS_NAND_PAGE_SIZE       4096//2048 /*++++ vern,NAND,20161127 ---*/
+        #define CONFIG_SYS_NAND_BLOCK_SIZE      (64*4096)//(128*1024)/*++++ vern,NAND,20161127 ---*/
 #elif defined(MT29F16G08)
 	#define CONFIG_SYS_NAND_ECCPOS	{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, \
 					 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, \
@@ -274,18 +301,29 @@
 	#define CONFIG_SYS_NAND_PAGE_SIZE	4096//2048 /*++++ vern,NAND,20161127 ---*/
 	#define CONFIG_SYS_NAND_BLOCK_SIZE	(64*4096)//(128*1024)/*++++ vern,NAND,20161127 ---*/
 #else
-	#define CONFIG_SYS_NAND_ECCPOS  {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, \
-                                         16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, \
-                                         28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, \
-                                         40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, \
-                                         52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, \
-                                         64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, \
-                                         76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, \
-                                         88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, \
-                                         100, 101, 102, 103, 104, 105, 106, 107, 108, 109, \
-                                         110, 111, 112, 113 }
-        #define CONFIG_SYS_NAND_ECCBYTES        14
-        #define CONFIG_NAND_OMAP_ECCSCHEME      OMAP_ECC_BCH8_CODE_HW
+	#define CONFIG_SYS_NAND_ECCPOS  { 2, 3, 4, 5, 6, 7, 8, 9, \
+                                          10, 11, 12, 13, 14, 15, 16, 17, 18, 19, \
+                                          20, 21, 22, 23, 24, 25, 26, 27, 28, 29, \
+                                          30, 31, 32, 33, 34, 35, 36, 37, 38, 39, \
+                                          40, 41, 42, 43, 44, 45, 46, 47, 48, 49, \
+                                          50, 51, 52, 53, 54, 55, 56, 57, 58, 59, \
+                                          60, 61, 62, 63, 64, 65, 66, 67, 68, 69, \
+                                          70, 71, 72, 73, 74, 75, 76, 77, 78, 79, \
+                                          80, 81, 82, 83, 84, 85, 86, 87, 88, 89, \
+                                          90, 91, 92, 93, 94, 95, 96, 97, 98, 99, \
+                                          100, 101, 102, 103, 104, 105, 106, 107, 108, 109, \
+                                          110, 111, 112, 113, 114, 115, 116, 117, 118, 119, \
+                                          120, 121, 122, 123, 124, 125, 126, 127, 128, 129, \
+                                          130, 131, 132, 133, 134, 135, 136, 137, 138, 139, \
+                                          140, 141, 142, 143, 144, 145, 146, 147, 148, 149, \
+                                          150, 151, 152, 153, 154, 155, 156, 157, 158, 159, \
+                                          160, 161, 162, 163, 164, 165, 166, 167, 168, 169, \
+                                          170, 171, 172, 173, 174, 175, 176, 177, 178, 179, \
+                                          180, 181, 182, 183, 184, 185, 186, 187, 188, 189, \
+                                          190, 191, 192, 193, 194, 195, 196, 197, 198, 199, \
+                                          200, 201, 202, 203, 204, 205, 206, 207, 208, 209, }
+        #define CONFIG_SYS_NAND_ECCBYTES        26
+        #define CONFIG_NAND_OMAP_ECCSCHEME      OMAP_ECC_BCH16_CODE_HW
         #define CONFIG_SYS_NAND_OOBSIZE         224//64 /*++++ vern,NAND,20161127 ---*/
         #define CONFIG_SYS_NAND_PAGE_SIZE       4096//2048 /*++++ vern,NAND,20161127 ---*/
         #define CONFIG_SYS_NAND_BLOCK_SIZE      (64*4096)//(128*1024)/*++++ vern,NAND,20161127 ---*/