浏览代码

2020-01-14 / Jerry Wang
Actions:
1. Fix flash upgrade writing location problem.
2. Delete unused comment and code.

Files:
1. Module_Upgrade.c

8054 5 年之前
父节点
当前提交
3c99f74bb3
共有 1 个文件被更改,包括 14 次插入14 次删除
  1. 14 14
      EVSE/Modularization/Module_Upgrade.c

+ 14 - 14
EVSE/Modularization/Module_Upgrade.c

@@ -1,9 +1,9 @@
 /*
  * Module_RFID.c
  *
- *  Created on: 2019-12-24
+ *  Created on: 2019-01-14
  *      Author: Jerry Wang
- *     Version: D0.01
+ *     Version: D0.02
  */
 #include	"Module_Upgrade.h"
 
@@ -133,8 +133,8 @@ int Upgrade_Flash(unsigned int Type,char *SourcePath,char *ModelName)
 		return result;
 	}
 
-	unsigned char *ptr = malloc(MaxLen); //-48 is take out the header
-	memset(ptr,0xFF,MaxLen);  //-48 is take out the header
+	unsigned char *ptr = malloc(MaxLen);
+	memset(ptr,0xFF,MaxLen);
 
 	//get the image length
 	ImageLen = read(fd,ptr,MaxLen);
@@ -169,7 +169,7 @@ int Upgrade_Flash(unsigned int Type,char *SourcePath,char *ModelName)
 				// calculate the image CRC
 				DEBUG_INFO("CRC32 in image: 0x%08X\r\n",ImageCRC);
 				DEBUG_INFO("CRC32 by calculation: 0x%08X\r\n",crc32(ptr,ImageLen));
-				if(crc32(ptr,ImageLen/*34+DataLength*/) == ImageCRC)
+				if(crc32(ptr,ImageLen) == ImageCRC)
 				{
 					// Write image to target flash block
 					switch(Type)
@@ -185,7 +185,7 @@ int Upgrade_Flash(unsigned int Type,char *SourcePath,char *ModelName)
 							{
 								// Write image to flash
 								DEBUG_INFO("Writing image to mtdblock0...\n");
-								wrd=write(fd, ptr, DataLength);
+								wrd=write(fd, ptr+48, DataLength);
 								close(fd);
 								DEBUG_INFO(">> mtdblock0 Written length: 0x%x\r\n", wrd);
 								if(wrd != DataLength)
@@ -229,7 +229,7 @@ int Upgrade_Flash(unsigned int Type,char *SourcePath,char *ModelName)
 									{
 										// Write image to flash
 										DEBUG_INFO("Writing image to mtdblock3...\n");
-										wrd=write(fd, ptr, DataLength);
+										wrd=write(fd, ptr+48, DataLength);
 										close(fd);
 										DEBUG_INFO(">> mtdblock3 written length: 0x%x\r\n", wrd);
 										if(wrd != DataLength)
@@ -648,8 +648,8 @@ int Upgrade_UART(unsigned char uartfd,unsigned int Type,unsigned char TargetAddr
 		return result;
 	}
 
-	unsigned char *ptr = malloc(MaxLen); //-48 is take out the header
-	memset(ptr,0xFF,MaxLen);  //-48 is take out the header
+	unsigned char *ptr = malloc(MaxLen);
+	memset(ptr,0xFF,MaxLen);
 
 	//get the image length
 	ImageLen = read(fd,ptr,MaxLen);
@@ -684,7 +684,7 @@ int Upgrade_UART(unsigned char uartfd,unsigned int Type,unsigned char TargetAddr
 				// calculate the image CRC
 				DEBUG_INFO("CRC32 in image: 0x%08X\r\n",ImageCRC);
 				DEBUG_INFO("CRC32 by calculation: 0x%08X\r\n",crc32(ptr,ImageLen));
-				if(crc32(ptr,ImageLen/*34+DataLength*/) == ImageCRC)
+				if(crc32(ptr,ImageLen) == ImageCRC)
 				{
 					if(uart_update_start(uartfd, TargetAddr, crc32(ptr+48,DataLength))==PASS)
 					{
@@ -900,8 +900,8 @@ int Upgrade_CAN(int canfd,unsigned int Type,unsigned char TargetAddr,char *Sourc
 		return result;
 	}
 
-	unsigned char *ptr = malloc(MaxLen); //-48 is take out the header
-	memset(ptr,0xFF,MaxLen);  //-48 is take out the header
+	unsigned char *ptr = malloc(MaxLen);
+	memset(ptr,0xFF,MaxLen);
 
 	//get the image length
 	ImageLen = read(fd,ptr,MaxLen);
@@ -917,7 +917,7 @@ int Upgrade_CAN(int canfd,unsigned int Type,unsigned char TargetAddr,char *Sourc
 
 	if(isModelNameOK == FAIL)
 	{
-		DEBUG_ERROR("The model name is wrong...\n");
+		DEBUG_ERROR("Model name mismatch...\n");
 		return result;
 	}
 	else
@@ -935,7 +935,7 @@ int Upgrade_CAN(int canfd,unsigned int Type,unsigned char TargetAddr,char *Sourc
 				// calculate the image CRC
 				DEBUG_INFO("CRC32 in image: 0x%08X\r\n",ImageCRC);
 				DEBUG_INFO("CRC32 by calculation: 0x%08X\r\n",crc32(ptr,ImageLen));
-				if(crc32(ptr,ImageLen/*34+DataLength*/) == ImageCRC)
+				if(crc32(ptr,ImageLen) == ImageCRC)
 				{
 					unsigned int Checksum[16];