Quellcode durchsuchen

测试结束,OTA升级正常

yang684665 vor 1 Jahr
Ursprung
Commit
522ce69018
44 geänderte Dateien mit 8232 neuen und 92969 gelöschten Zeilen
  1. 5 2
      app/App/ec800m.h
  2. 1 0
      app/App/main.c
  3. 130 6
      app/App/otaEvent.c
  4. 4 0
      app/Proj/.vscode/keil-assistant.log
  5. 48 24
      app/Proj/.vscode/uv4.log
  6. 1 1
      app/Proj/.vscode/uv4.log.lock
  7. 4074 89264
      app/Proj/JLinkLog.txt
  8. 427 423
      app/Proj/Listings/Ringzle.map
  9. BIN
      app/Proj/Objects/Ringzle.axf
  10. BIN
      app/Proj/Objects/Ringzle.bin
  11. 18 18
      app/Proj/Objects/Ringzle.build_log.htm
  12. 22 22
      app/Proj/Objects/Ringzle.htm
  13. 7 7
      app/Proj/Objects/Ringzle_GD32F103C8T6.dep
  14. 2 2
      app/Proj/Objects/Ringzle_sct.Bak
  15. BIN
      app/Proj/Objects/ec800m.crf
  16. BIN
      app/Proj/Objects/main.crf
  17. BIN
      app/Proj/Objects/otaevent.crf
  18. BIN
      app/Proj/Objects/parsedevicemessage.crf
  19. BIN
      app/Proj/Objects/pc.crf
  20. 87 60
      app/Proj/Ringzle.uvguix.IBM
  21. 50 14
      app/Proj/Ringzle.uvoptx
  22. 9 0
      app/Proj/Ringzle.uvprojx
  23. 4 0
      bootloader/HW/Include/ec800m.h
  24. 131 8
      bootloader/HW/Source/boot.c
  25. 25 18
      bootloader/HW/Source/ota_message.c
  26. BIN
      bootloader/OBJ/boot.crf
  27. 2 0
      bootloader/OBJ/boot.d
  28. BIN
      bootloader/OBJ/bootloader.axf
  29. 11 17
      bootloader/OBJ/bootloader.build_log.htm
  30. 333 403
      bootloader/OBJ/bootloader.htm
  31. 10 8
      bootloader/OBJ/bootloader_bootloader.dep
  32. 2 2
      bootloader/OBJ/bootloader_sct.Bak
  33. BIN
      bootloader/OBJ/ec800m.crf
  34. BIN
      bootloader/OBJ/main.crf
  35. BIN
      bootloader/OBJ/ota_message.crf
  36. 4 0
      bootloader/USER/.vscode/keil-assistant.log
  37. 48 32
      bootloader/USER/.vscode/uv4.log
  38. 1 1
      bootloader/USER/.vscode/uv4.log.lock
  39. 2245 2044
      bootloader/USER/JLinkLog.txt
  40. 433 466
      bootloader/USER/Listings/bootloader.map
  41. 29 56
      bootloader/USER/bootloader.uvguix.IBM
  42. 27 29
      bootloader/USER/bootloader.uvoptx
  43. 41 41
      bootloader/USER/main.c
  44. 1 1
      bootloader/USER/main.h

+ 5 - 2
app/App/ec800m.h

@@ -21,17 +21,20 @@
 #define CMD_READ_FILE "AT+QFDWL=http.txt\r\n"
 
 #define OPEN_otaMSG_FILE "AT+QFOPEN=\"otaMSG.txt\",1\r\n"
-#define WRITE_otaMSG_FILE "AT+QFWRITE=1,1024,3\r\n"
+#define WRITE_otaMSG_FILE "AT+QFWRITE=1,8,3\r\n"
 #define CLOSE_otaMSG_FILE "AT+QFCLOSE=1\r\n"
 #define LOAD_otaMSG_FILE "AT+QFDWL=otaMSG.txt\r\n"
 #define DEL_otaMSG_FILE "AT+QFDEL=otaMSG.txt\r\n"
 
-#define OPEN_otaDATA_FILE "AT+QFOPEN=\"otaDATA.txt\",1\r\n"
+#define OPEN_otaDATA_FILE "AT+QFOPEN=\"otaDATA.txt\",0\r\n"
 #define WRITE_otaDATA_FILE "AT+QFWRITE=1,128,2\r\n"
 #define CLOSE_otaDATA_FILE "AT+QFCLOSE=1\r\n"
 #define LOAD_otaDATA_FILE "AT+QFDWL=otaDATA.txt\r\n"
 #define DEL_otaDATA_FILE "AT+QFDEL=otaDATA.txt\r\n"
 
+#define READ_otaDATA_FILE "AT+QFREAD=1,1024\r\n"
+#define TEST_DATA "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
+
 #define ATI "ATI"
 
 #define CMD_MQTT_DISCONNECT "AT+QMTDISC=0\r\n"

+ 1 - 0
app/App/main.c

@@ -124,6 +124,7 @@ int main(void)
 	mmodbus_init(1);
 	dlt645_init(1);
 
+	usart_data_transmit(COM_232, 'P');
 	//¿ªÆô¿´ÃŹ·
 //	fwdgt_init();
 	while (1)

+ 130 - 6
app/App/otaEvent.c

@@ -17,6 +17,122 @@
 int8_t xmodem(uint16_t timeout);
 OTA_T ota_data;
 uint16_t Xmodem_CRC16(uint8_t *data, uint16_t datalen);
+static OTA_MESSAGE ota_message;
+
+#if 0
+//测试用的
+int WaitForReadData(uint8_t* data,int timeout,int datalen)
+{
+	uint32_t len = 0;
+	bool timeoutFlag = false;
+	if (timeout >= 0)
+	{
+		timeoutFlag = true;
+	}
+	while (1)
+	{
+		delay_1ms(50);
+		if (UART0_RX_STAT > 0)
+		{
+			UART0_RX_STAT = 0;
+			char *p  = strstr((char *)&UART0_RX_BUF, "CONNECT ");
+			if (p)
+			{
+				p += 8;
+				sscanf(p, "%u\r", &len);		// 读取长度
+				if(len == datalen)
+				{
+					p = strchr(p, '\n') + 1;		// 跳过换行
+					memcpy(data,p,datalen);
+					Clear_DMA_Buffer();
+					return datalen;
+				}
+				else
+				{
+					Clear_DMA_Buffer();
+					return len;
+				}
+			}
+			
+		}
+		timeout -= 50;
+		if (timeoutFlag == true && timeout <= 0)
+		{
+			Clear_DMA_Buffer();
+			return -1;
+		}
+	}
+}
+static uint8_t app_programmer[1024];
+void read_ota_DATA(uint32_t app_byte)
+{
+	/* 打开UFS:otaDATA.txt */
+	EC800MSendCmd(CLOSE_otaDATA_FILE,strlen(CLOSE_otaDATA_FILE));
+	WaitResponse("QFCLOSE",1000);
+	EC800MSendCmd(OPEN_otaDATA_FILE,strlen(OPEN_otaDATA_FILE));
+	if(WaitResponse("QFOPEN:", 2000) == 0)
+		return;
+	for(uint8_t i=0;i<app_byte/1024;i++)				//一次读1KB
+	{
+		task_fwdgt_reload();
+		memset(app_programmer,0,1024);
+		// uint32_t addr=APP_PROGRAMMER_BLOCK*64*1024+i*1024;   //其在w25q32中的地址
+		// W25Q32_Read(app_programmer,addr,1024);
+		while(1)
+		{
+			int x = 0;
+			EC800MSendCmd(READ_otaDATA_FILE,strlen(READ_otaDATA_FILE));
+			x = WaitForReadData(app_programmer,2000,1024);
+			if((x != 1024) && (x != -1))
+			{
+				char* SEEK_otaDATA_FILE = "";
+				sprintf(SEEK_otaDATA_FILE,"AT+QFSEEK=1,%d,2\r\n",x);
+				EC800MSendCmd(SEEK_otaDATA_FILE,strlen(SEEK_otaDATA_FILE));	//出错的话文件指针向左偏移1024个字节
+			}
+			else if(x == 1024)
+			{
+				break;
+			}
+		}
+		delay_1ms(50);
+	}
+	//将不满1024数据单独写入
+	if(app_byte % 1024 != 0)
+	{
+		uint32_t startAddress=(app_byte/1024)*1024;
+		memset(app_programmer,0,1024);
+		// uint32_t addr=APP_PROGRAMMER_BLOCK*64*1024+(app_byte/1024)*1024;   														//其在w25q32中的地址
+		// W25Q32_Read(app_programmer,addr,app_byte%1024);	
+		while(1)
+		{
+			int x = 0;
+			EC800MSendCmd(READ_otaDATA_FILE,strlen(READ_otaDATA_FILE));
+			x = WaitForReadData(app_programmer,2000,app_byte % 1024);
+			if(x != (app_byte % 1024) && (x != -1))
+			{
+				char* SEEK_otaDATA_FILE = "";
+				sprintf(SEEK_otaDATA_FILE,"AT+QFSEEK=1,%d,2\r\n",x);
+				EC800MSendCmd(SEEK_otaDATA_FILE,strlen(SEEK_otaDATA_FILE));	//出错的话文件指针向左偏移读取字节数
+			}
+			else if(x == (app_byte % 1024))
+			{
+				break;
+			}
+		}		
+		delay_1ms(50);																	
+	}
+	// 关闭保存UFS文件
+	while(1)
+	{
+		EC800MSendCmd(CLOSE_otaDATA_FILE,strlen(CLOSE_otaDATA_FILE));
+		if(WaitResponse("OK", 2000) == 1)
+		{
+			break;
+		}
+	}
+}
+#endif
+
 /*
  *  函数名:uint8_t check_ota_event()
  *  输入参数:无
@@ -31,14 +147,15 @@ int8_t check_ota_event()
 	if (ota_data.ota_flag == 1)
 	{
 		// W25Q32_Erase64K(APPBLOCKNB);                    //程序文件在第三block以后
-		EC800MSendCmd(DEL_otaDATA_FILE, strlen(DEL_otaDATA_FILE));	//清空OTA数据文件
+		// EC800MSendCmd(DEL_otaDATA_FILE, strlen(DEL_otaDATA_FILE));	//清空OTA数据文件
 		int8_t recvSta = xmodem(1000);						//在1000秒内解决OTA更新
 		if (recvSta == 0)
 		{
 			return 0;
 		}
-		else  
+		else
 		{
+			// read_ota_DATA(ota_message.XmodemByte);
 			NVIC_SystemReset();
 		}
 	}
@@ -93,7 +210,9 @@ int8_t xmodem(uint16_t timeout)
 		delay_1ms(1000);
 		if(ota_data.done==1)
 		{
-			//打开otaMSG.txt文件
+			//打开otaData.txt文件
+			EC800MSendCmd(CLOSE_otaDATA_FILE,strlen(CLOSE_otaDATA_FILE));
+			WaitResponse("QFCLOSE",1000);
 			EC800MSendCmd(OPEN_otaDATA_FILE,strlen(OPEN_otaDATA_FILE));
 			if(WaitResponse("QFOPEN:", 2000) == 0)
 				return 0;
@@ -130,12 +249,13 @@ int8_t xmodem(uint16_t timeout)
 					while(sed_flg < 2)
 					{
 						EC800MSendCmd(ota_data.data + 3,128);
+//						EC800MSendCmd(TEST_DATA,128);
 						int x = WaitResponse_value(2000);
 						if(x != 128)
 						{
 							sed_flg++;
 							char* QFSEEK_CMD;
-							sprintf(QFSEEK_CMD,"AT+QFSEEK=1,%d,2",x);
+							sprintf(QFSEEK_CMD,"AT+QFSEEK=1,%d,2\r\n",x);
 							EC800MSendCmd(QFSEEK_CMD,strlen(QFSEEK_CMD));	//出错的话文件指针向左偏移x个字节
 						}
 						else
@@ -184,12 +304,13 @@ int8_t xmodem(uint16_t timeout)
 
 				usart_data_transmit(COM_232, ACK);
 				//完成xmodem协议的交互将完成的标志存储到内存中
-				OTA_MESSAGE ota_message;
 				ota_message.Completion_flag=1U;
 				ota_message.XmodemByte=data_flag.xmodemNB*128;//后续补齐的0x1A还需要进一步考虑
 
 				while(sed_flg < 2)
 				{
+					EC800MSendCmd(CLOSE_otaDATA_FILE,strlen(CLOSE_otaDATA_FILE));
+					WaitResponse("QFCLOSE",1000);
 					EC800MSendCmd(OPEN_otaMSG_FILE,strlen(OPEN_otaMSG_FILE));
 					if(WaitResponse("QFOPEN:", 2000) == 0)
 					{
@@ -220,6 +341,7 @@ int8_t xmodem(uint16_t timeout)
 				while(sed_flg < 2)
 				{
 					EC800MSendCmd((uint8_t *)&ota_message,sizeof(OTA_MESSAGE));
+					// delay_1ms(3000);
 					int x = WaitResponse_value(2000);
 					if(x != sizeof(OTA_MESSAGE))
 					{
@@ -251,7 +373,9 @@ int8_t xmodem(uint16_t timeout)
 
 				// W25Q32_Erase64K(OTA_EVENT_BLOCKNB);//擦除原先的数据
 				// W25Q32_PageWrite((uint8_t *)&ota_message,OTA_EVENT_BLOCKNB*256);
-			
+				ota_data.data_cnt = 0;
+				memset(ota_data.data, 0, 133);
+				ota_data.done = 0;
 				delay_1ms(50);
 				// 写入事件完成标志后重启设备,其他状态页无需回滚,写入完成会执行重启指令
 				return 1;

+ 4 - 0
app/Proj/.vscode/keil-assistant.log

@@ -12,3 +12,7 @@
 
 [info] Log at : 2023/10/30|19:23:45|GMT+0800
 
+[info] Log at : 2023/10/31|11:33:18|GMT+0800
+
+[info] Log at : 2023/11/2|10:29:27|GMT+0800
+

+ 48 - 24
app/Proj/.vscode/uv4.log

@@ -1,24 +1,48 @@
-*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\software\MDK5\ARM\ARMCC\Bin'
-Build target 'GD32F103C8T6'
-compiling otaEvent.c...
-..\App\otaEvent.h(26): warning:  #1295-D: Deprecated declaration check_ota_event - give arg types
-  int8_t check_ota_event();
-..\App\device_message.h(99): warning:  #1295-D: Deprecated declaration get_gateway_config_params - give arg types
-  GATEWAY_PARAMS *get_gateway_config_params();
-..\App\otaEvent.c(47): warning:  #940-D: missing return statement at end of non-void function "check_ota_event" 
-  }
-..\App\otaEvent.c(51): warning:  #188-D: enumerated type mixed with another type
-  	bool timeoutFlag = false;
-..\App\otaEvent.c(54): warning:  #188-D: enumerated type mixed with another type
-  		timeoutFlag = true;
-..\App\otaEvent.c(132): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *"
-  						EC800MSendCmd(ota_data.data + 3,128);
-..\App\otaEvent.c(222): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *"
-  					EC800MSendCmd((uint8_t *)&ota_message,sizeof(OTA_MESSAGE));
-..\App\otaEvent.c: 7 warnings, 0 errors
-linking...
-Program Size: Code=16396 RO-data=524 RW-data=164 ZI-data=82836  
-FromELF: creating hex file...
-After Build - User command #1: fromelf --bin --output ./Objects/Ringzle.bin ./Objects/Ringzle.axf
-".\Objects\Ringzle.axf" - 0 Error(s), 7 Warning(s).
-Build Time Elapsed:  00:00:03
+Load "d:\\project\\dtu_gateway\\app\\Proj\\Objects\\Ringzle.axf" 
+Set JLink Project File to "d:\project\dtu_gateway\app\Proj\JLinkSettings.ini"* JLink Info: Device "GD32F103VG" selected.
+
+JLink info:
+------------
+DLL: V6.84a, compiled Sep  7 2020 17:26:08
+Firmware: J-Link V9 compiled May  7 2021 16:26:12
+Hardware: V9.40
+S/N : 69405423 
+Feature(s) : RDI, GDB, FlashDL, FlashBP, JFlash 
+
+* JLink Info: Found SW-DP with ID 0x1BA01477
+* JLink Info: DPIDR: 0x1BA01477
+* JLink Info: Scanning AP map to find all available APs
+* JLink Info: AP[1]: Stopped AP scan as end of AP map has been reached
+* JLink Info: AP[0]: AHB-AP (IDR: 0x24770011)
+* JLink Info: Iterating through AP map to find AHB-AP to use
+* JLink Info: AP[0]: Core found
+* JLink Info: AP[0]: AHB-AP ROM base: 0xE00FF000
+* JLink Info: CPUID register: 0x412FC231. Implementer code: 0x41 (ARM)
+* JLink Info: Found Cortex-M3 r2p1, Little endian.
+* JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots
+* JLink Info: CoreSight components:
+* JLink Info: ROMTbl[0] @ E00FF000
+* JLink Info: ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB000 SCS
+* JLink Info: ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
+* JLink Info: ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
+* JLink Info: ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
+* JLink Info: ROMTbl[0][4]: E0040000, CID: B105900D, PID: 003BB923 TPIU-Lite
+* JLink Info: ROMTbl[0][5]: E0041000, CID: B105900D, PID: 003BB924 ETM-M3
+ROMTableAddr = 0xE00FF000
+* JLink Info: Reset: Halt core after reset via DEMCR.VC_CORERESET.
+* JLink Info: Reset: Reset device via AIRCR.SYSRESETREQ.
+
+Target info:
+------------
+Device: GD32F103VG
+VTarget = 3.282V
+State of Pins: TCK: 0, TDI: 0, TDO: 0, TMS: 1, TRES: 1, TRST: 0
+Hardware-Breakpoints: 6
+Software-Breakpoints: 8192
+Watchpoints:          4
+JTAG speed: 500 kHz
+
+Erase Done.Programming Done.Verify OK.* JLink Info: Reset: Halt core after reset via DEMCR.VC_CORERESET.
+* JLink Info: Reset: Reset device via AIRCR.SYSRESETREQ.
+Application running ...
+Flash Load finished at 10:29:55

+ 1 - 1
app/Proj/.vscode/uv4.log.lock

@@ -1 +1 @@
-2023/10/30 19:26:18
+2023/11/2 10:29:55

Datei-Diff unterdrückt, da er zu groß ist
+ 4074 - 89264
app/Proj/JLinkLog.txt


Datei-Diff unterdrückt, da er zu groß ist
+ 427 - 423
app/Proj/Listings/Ringzle.map


BIN
app/Proj/Objects/Ringzle.axf


BIN
app/Proj/Objects/Ringzle.bin


+ 18 - 18
app/Proj/Objects/Ringzle.build_log.htm

@@ -21,30 +21,30 @@ Target DLL:      Segger\JL2CM3.dll V2.99.40.0
 Dialog DLL:      TCM.DLL V1.53.0.0
  
 <h2>Project:</h2>
-D:\project\dtu_gateway\app\Proj\Ringzle.uvprojx
-Project File Date:  10/30/2023
+d:\project\dtu_gateway\app\Proj\Ringzle.uvprojx
+Project File Date:  10/31/2023
 
 <h2>Output:</h2>
 *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\software\MDK5\ARM\ARMCC\Bin'
 Build target 'GD32F103C8T6'
-compiling main.c...
-..\App\device_message.h(99): warning:  #1295-D: Deprecated declaration get_gateway_config_params - give arg types
-  GATEWAY_PARAMS *get_gateway_config_params();
-..\App\parseDeviceMessage.h(13): warning:  #1295-D: Deprecated declaration Read_Data - give arg types
-  void Read_Data();
+compiling otaEvent.c...
 ..\App\otaEvent.h(26): warning:  #1295-D: Deprecated declaration check_ota_event - give arg types
   int8_t check_ota_event();
-..\App\main.c(66): warning:  #1295-D: Deprecated declaration fwdgt_init - give arg types
-  void fwdgt_init();
-..\App\main.c(67): warning:  #1295-D: Deprecated declaration task_fwdgt_reload - give arg types
-  void task_fwdgt_reload();
-..\App\main.c(104): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "uint8_t *"
-   	http_load_config(httpURL);
-..\App\main.c(217): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *"
-  	if (EC800MGetUrl(httpURL,dmabuffer,BufferSize) == true) // 从http获取信息,获取成功则保存到本地
-..\App\main.c: 7 warnings, 0 errors
+..\App\device_message.h(99): warning:  #1295-D: Deprecated declaration get_gateway_config_params - give arg types
+  GATEWAY_PARAMS *get_gateway_config_params();
+..\App\otaEvent.c(164): warning:  #940-D: missing return statement at end of non-void function "check_ota_event" 
+  }
+..\App\otaEvent.c(168): warning:  #188-D: enumerated type mixed with another type
+  	bool timeoutFlag = false;
+..\App\otaEvent.c(171): warning:  #188-D: enumerated type mixed with another type
+  		timeoutFlag = true;
+..\App\otaEvent.c(251): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *"
+  						EC800MSendCmd(ota_data.data + 3,128);
+..\App\otaEvent.c(343): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *"
+  					EC800MSendCmd((uint8_t *)&ota_message,sizeof(OTA_MESSAGE));
+..\App\otaEvent.c: 7 warnings, 0 errors
 linking...
-Program Size: Code=16404 RO-data=524 RW-data=164 ZI-data=82836  
+Program Size: Code=16468 RO-data=524 RW-data=172 ZI-data=82836  
 FromELF: creating hex file...
 After Build - User command #1: fromelf --bin --output ./Objects/Ringzle.bin ./Objects/Ringzle.axf
 ".\Objects\Ringzle.axf" - 0 Error(s), 7 Warning(s).
@@ -60,7 +60,7 @@ Package Vendor: GigaDevice
   D:\software\MDK5\Pack\GigaDevice\GD32F10x_DFP\2.1.0\Device\Include
 
 <h2>Collection of Component Files used:</h2>
-Build Time Elapsed:  00:00:02
+Build Time Elapsed:  00:00:03
 </pre>
 </body>
 </html>

+ 22 - 22
app/Proj/Objects/Ringzle.htm

@@ -3,7 +3,7 @@
 <title>Static Call Graph - [.\Objects\Ringzle.axf]</title></head>
 <body><HR>
 <H1>Static Call Graph for image .\Objects\Ringzle.axf</H1><HR>
-<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060960: Last Updated: Mon Oct 30 19:43:31 2023
+<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060960: Last Updated: Thu Nov 02 10:29:39 2023
 <BR><P>
 <H3>Maximum Stack Usage =        352 bytes + Unknown(Cycles, Untraceable Function Pointers)</H3><H3>
 Call chain for Maximum Stack Depth:</H3>
@@ -449,18 +449,18 @@ Global Symbols
 </UL>
 
 <P><STRONG><a name="[5c]"></a>__aeabi_llsl</STRONG> (Thumb, 30 bytes, Stack size 0 bytes, llshl.o(.text), UNUSED)
-<BR><BR>[Called By]<UL><LI><a href="#[5b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dadd
-<LI><a href="#[64]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_uldivmod
-<LI><a href="#[5e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_double_epilogue
+<BR><BR>[Called By]<UL><LI><a href="#[5e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_double_epilogue
 <LI><a href="#[67]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_d2ulz
+<LI><a href="#[5b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dadd
+<LI><a href="#[64]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_uldivmod
 </UL>
 
 <P><STRONG><a name="[ed]"></a>_ll_shift_l</STRONG> (Thumb, 0 bytes, Stack size 0 bytes, llshl.o(.text), UNUSED)
 
 <P><STRONG><a name="[65]"></a>__aeabi_llsr</STRONG> (Thumb, 32 bytes, Stack size 0 bytes, llushr.o(.text), UNUSED)
-<BR><BR>[Called By]<UL><LI><a href="#[64]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_uldivmod
-<LI><a href="#[5e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_double_epilogue
+<BR><BR>[Called By]<UL><LI><a href="#[5e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_double_epilogue
 <LI><a href="#[67]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_d2ulz
+<LI><a href="#[64]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_uldivmod
 </UL>
 
 <P><STRONG><a name="[ee]"></a>_ll_ushift_r</STRONG> (Thumb, 0 bytes, Stack size 0 bytes, llushr.o(.text), UNUSED)
@@ -515,8 +515,8 @@ Global Symbols
 
 <P><STRONG><a name="[5f]"></a>_double_round</STRONG> (Thumb, 30 bytes, Stack size 8 bytes, depilogue.o(.text), UNUSED)
 <BR><BR>[Called By]<UL><LI><a href="#[63]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_ddiv
-<LI><a href="#[5b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dadd
 <LI><a href="#[5e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_double_epilogue
+<LI><a href="#[5b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dadd
 </UL>
 
 <P><STRONG><a name="[5e]"></a>_double_epilogue</STRONG> (Thumb, 156 bytes, Stack size 32 bytes, depilogue.o(.text), UNUSED)
@@ -524,8 +524,8 @@ Global Symbols
 <LI><a href="#[65]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_llsr
 <LI><a href="#[5c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_llsl
 </UL>
-<BR>[Called By]<UL><LI><a href="#[5b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dadd
-<LI><a href="#[62]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dmul
+<BR>[Called By]<UL><LI><a href="#[62]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dmul
+<LI><a href="#[5b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dadd
 </UL>
 
 <P><STRONG><a name="[67]"></a>__aeabi_d2ulz</STRONG> (Thumb, 48 bytes, Stack size 0 bytes, dfixul.o(.text), UNUSED)
@@ -625,7 +625,6 @@ Global Symbols
 <LI><a href="#[71]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;EC800MGetUrl
 <LI><a href="#[6b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ConnectMQTTSever
 <LI><a href="#[a7]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;xmodem
-<LI><a href="#[a6]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;check_ota_event
 <LI><a href="#[c8]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;http_load_config
 </UL>
 
@@ -887,11 +886,10 @@ Global Symbols
 <BR>[Called By]<UL><LI><a href="#[a3]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;addDevice
 </UL>
 
-<P><STRONG><a name="[a6]"></a>check_ota_event</STRONG> (Thumb, 74 bytes, Stack size 8 bytes, otaevent.o(i.check_ota_event))
-<BR><BR>[Stack]<UL><LI>Max Depth = 152<LI>Call Chain = check_ota_event &rArr; xmodem &rArr; WaitResponse_value &rArr; strtol &rArr; _strtoul
+<P><STRONG><a name="[a6]"></a>check_ota_event</STRONG> (Thumb, 66 bytes, Stack size 8 bytes, otaevent.o(i.check_ota_event))
+<BR><BR>[Stack]<UL><LI>Max Depth = 144<LI>Call Chain = check_ota_event &rArr; xmodem &rArr; WaitResponse_value &rArr; strtol &rArr; _strtoul
 </UL>
-<BR>[Calls]<UL><LI><a href="#[6c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;EC800MSendCmd
-<LI><a href="#[a7]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;xmodem
+<BR>[Calls]<UL><LI><a href="#[a7]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;xmodem
 </UL>
 <BR>[Called By]<UL><LI><a href="#[46]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;main
 </UL>
@@ -1218,7 +1216,7 @@ Global Symbols
 <BR>[Called By]<UL><LI><a href="#[46]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;main
 </UL>
 
-<P><STRONG><a name="[46]"></a>main</STRONG> (Thumb, 280 bytes, Stack size 8 bytes, main.o(i.main))
+<P><STRONG><a name="[46]"></a>main</STRONG> (Thumb, 288 bytes, Stack size 8 bytes, main.o(i.main))
 <BR><BR>[Stack]<UL><LI>Max Depth = 352<LI>Call Chain = main &rArr; http_load_config &rArr; WaitForUpData &rArr; addGatewayParams &rArr; addDevice &rArr; addSensorListParams &rArr; parseStringField &rArr; __0sscanf &rArr; __vfscanf_char &rArr; __vfscanf &rArr; _scanf_string
 </UL>
 <BR>[Calls]<UL><LI><a href="#[ce]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;get_gateway_config_params
@@ -1227,6 +1225,7 @@ Global Symbols
 <LI><a href="#[7e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;EC800MSetPDP
 <LI><a href="#[74]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;EC800MPwoerOn
 <LI><a href="#[6b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ConnectMQTTSever
+<LI><a href="#[7c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;usart_data_transmit
 <LI><a href="#[cb]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;systick_config
 <LI><a href="#[72]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;delay_1ms
 <LI><a href="#[d1]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;ring_buffer_init
@@ -1412,6 +1411,7 @@ Global Symbols
 <P><STRONG><a name="[7c]"></a>usart_data_transmit</STRONG> (Thumb, 8 bytes, Stack size 0 bytes, gd32f10x_usart.o(i.usart_data_transmit))
 <BR><BR>[Called By]<UL><LI><a href="#[6c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;EC800MSendCmd
 <LI><a href="#[a7]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;xmodem
+<LI><a href="#[46]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;main
 </UL>
 
 <P><STRONG><a name="[c2]"></a>usart_deinit</STRONG> (Thumb, 136 bytes, Stack size 8 bytes, gd32f10x_usart.o(i.usart_deinit))
@@ -1505,8 +1505,8 @@ Global Symbols
 <LI><a href="#[a8]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;config_485_port
 </UL>
 
-<P><STRONG><a name="[a7]"></a>xmodem</STRONG> (Thumb, 704 bytes, Stack size 48 bytes, otaevent.o(i.xmodem))
-<BR><BR>[Stack]<UL><LI>Max Depth = 144<LI>Call Chain = xmodem &rArr; WaitResponse_value &rArr; strtol &rArr; _strtoul
+<P><STRONG><a name="[a7]"></a>xmodem</STRONG> (Thumb, 764 bytes, Stack size 40 bytes, otaevent.o(i.xmodem))
+<BR><BR>[Stack]<UL><LI>Max Depth = 136<LI>Call Chain = xmodem &rArr; WaitResponse_value &rArr; strtol &rArr; _strtoul
 </UL>
 <BR>[Calls]<UL><LI><a href="#[d9]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;task_fwdgt_reload
 <LI><a href="#[6d]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;WaitResponse
@@ -1572,21 +1572,21 @@ Local Symbols
 
 <P><STRONG><a name="[9b]"></a>_fp_digits</STRONG> (Thumb, 366 bytes, Stack size 64 bytes, printfa.o(i._fp_digits), UNUSED)
 <BR><BR>[Calls]<UL><LI><a href="#[63]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_ddiv
-<LI><a href="#[5b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dadd
 <LI><a href="#[62]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dmul
 <LI><a href="#[9c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_cdrcmple
-<LI><a href="#[64]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_uldivmod
 <LI><a href="#[67]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_d2ulz
+<LI><a href="#[5b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dadd
+<LI><a href="#[64]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_uldivmod
 </UL>
 <BR>[Called By]<UL><LI><a href="#[99]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_core
 </UL>
 
 <P><STRONG><a name="[99]"></a>_printf_core</STRONG> (Thumb, 1704 bytes, Stack size 136 bytes, printfa.o(i._printf_core), UNUSED)
-<BR><BR>[Calls]<UL><LI><a href="#[64]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_uldivmod
-<LI><a href="#[9f]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_uidivmod
-<LI><a href="#[9d]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_pre_padding
+<BR><BR>[Calls]<UL><LI><a href="#[9d]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_pre_padding
 <LI><a href="#[9e]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_post_padding
 <LI><a href="#[9b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_fp_digits
+<LI><a href="#[64]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_uldivmod
+<LI><a href="#[9f]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_uidivmod
 </UL>
 <BR>[Called By]<UL><LI><a href="#[98]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__0sprintf
 </UL>

Datei-Diff unterdrückt, da er zu groß ist
+ 7 - 7
app/Proj/Objects/Ringzle_GD32F103C8T6.dep


+ 2 - 2
app/Proj/Objects/Ringzle_sct.Bak

@@ -2,8 +2,8 @@
 ; *** Scatter-Loading Description File generated by uVision ***
 ; *************************************************************
 
-LR_IROM1 0x08037000 0x00100000  {    ; load region size_region
-  ER_IROM1 0x08037000 0x00100000  {  ; load address = execution address
+LR_IROM1 0x08005000 0x00100000  {    ; load region size_region
+  ER_IROM1 0x08005000 0x00100000  {  ; load address = execution address
    *.o (RESET, +First)
    *(InRoot$$Sections)
    .ANY (+RO)

BIN
app/Proj/Objects/ec800m.crf


BIN
app/Proj/Objects/main.crf


BIN
app/Proj/Objects/otaevent.crf


BIN
app/Proj/Objects/parsedevicemessage.crf


BIN
app/Proj/Objects/pc.crf


Datei-Diff unterdrückt, da er zu groß ist
+ 87 - 60
app/Proj/Ringzle.uvguix.IBM


+ 50 - 14
app/Proj/Ringzle.uvoptx

@@ -120,7 +120,7 @@
         <SetRegEntry>
           <Number>0</Number>
           <Key>DLGUARM</Key>
-          <Name></Name>
+          <Name>d</Name>
         </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>
@@ -157,9 +157,9 @@
         <Bp>
           <Number>0</Number>
           <Type>0</Type>
-          <LineNumber>36</LineNumber>
+          <LineNumber>84</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>134248206</Address>
+          <Address>134253286</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
@@ -168,39 +168,55 @@
           <BreakIfRCount>1</BreakIfRCount>
           <Filename>..\App\otaEvent.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression>\\Ringzle\../App/otaEvent.c\36</Expression>
+          <Expression>\\Ringzle\../App/otaEvent.c\84</Expression>
         </Bp>
         <Bp>
           <Number>1</Number>
           <Type>0</Type>
-          <LineNumber>131</LineNumber>
+          <LineNumber>127</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>134251774</Address>
+          <Address>134253502</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
           <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\App\main.c</Filename>
+          <Filename>..\App\otaEvent.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression>\\Ringzle\../App/main.c\131</Expression>
+          <Expression>\\Ringzle\../App/otaEvent.c\127</Expression>
         </Bp>
         <Bp>
           <Number>2</Number>
           <Type>0</Type>
-          <LineNumber>50</LineNumber>
+          <LineNumber>109</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>134243688</Address>
+          <Address>134253410</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
           <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\App\PC.c</Filename>
+          <Filename>..\App\otaEvent.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression>\\Ringzle\../App/PC.c\50</Expression>
+          <Expression>\\Ringzle\../App/otaEvent.c\109</Expression>
+        </Bp>
+        <Bp>
+          <Number>3</Number>
+          <Type>0</Type>
+          <LineNumber>159</LineNumber>
+          <EnabledFlag>1</EnabledFlag>
+          <Address>134248376</Address>
+          <ByteObject>0</ByteObject>
+          <HtxType>0</HtxType>
+          <ManyObjects>0</ManyObjects>
+          <SizeOfObject>0</SizeOfObject>
+          <BreakByAccess>0</BreakByAccess>
+          <BreakIfRCount>1</BreakIfRCount>
+          <Filename>..\App\otaEvent.c</Filename>
+          <ExecCommand></ExecCommand>
+          <Expression>\\Ringzle\../App/otaEvent.c\159</Expression>
         </Bp>
       </Breakpoint>
       <WatchWindow1>
@@ -224,15 +240,35 @@
           <WinNumber>1</WinNumber>
           <ItemText>ota_data.data</ItemText>
         </Ww>
+        <Ww>
+          <count>4</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>UART0_RX_BUF</ItemText>
+        </Ww>
       </WatchWindow1>
+      <WatchWindow2>
+        <Ww>
+          <count>0</count>
+          <WinNumber>2</WinNumber>
+          <ItemText>UART0_RX_BUF</ItemText>
+        </Ww>
+      </WatchWindow2>
       <MemoryWindow1>
         <Mm>
           <WinNumber>1</WinNumber>
           <SubType>8</SubType>
-          <ItemText>RxPacket</ItemText>
+          <ItemText>app_programmer</ItemText>
           <AccSizeX>0</AccSizeX>
         </Mm>
       </MemoryWindow1>
+      <MemoryWindow2>
+        <Mm>
+          <WinNumber>2</WinNumber>
+          <SubType>0</SubType>
+          <ItemText>0x20014417</ItemText>
+          <AccSizeX>0</AccSizeX>
+        </Mm>
+      </MemoryWindow2>
       <Tracepoint>
         <THDelay>0</THDelay>
       </Tracepoint>
@@ -300,7 +336,7 @@
 
   <Group>
     <GroupName>Startup</GroupName>
-    <tvExp>0</tvExp>
+    <tvExp>1</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>

+ 9 - 0
app/Proj/Ringzle.uvprojx

@@ -675,4 +675,13 @@
     <files/>
   </RTE>
 
+  <LayerInfo>
+    <Layers>
+      <Layer>
+        <LayName>Ringzle</LayName>
+        <LayPrjMark>1</LayPrjMark>
+      </Layer>
+    </Layers>
+  </LayerInfo>
+
 </Project>

+ 4 - 0
bootloader/HW/Include/ec800m.h

@@ -22,6 +22,10 @@
 #define CLOSE_otaMSG_FILE "AT+QFCLOSE=1\r\n"
 #define LOAD_otaMSG_FILE "AT+QFDWL=otaMSG.txt\r\n"
 
+#define OPEN_otaDATA_FILE "AT+QFOPEN=\"otaDATA.txt\",0\r\n"
+#define READ_otaDATA_FILE "AT+QFREAD=1,1024\r\n"
+#define CLOSE_otaDATA_FILE "AT+QFCLOSE=1\r\n"
+
 #define ATI "ATI"
 
 #define CMD_MQTT_DISCONNECT "AT+QMTDISC=0\r\n"

+ 131 - 8
bootloader/HW/Source/boot.c

@@ -6,33 +6,156 @@
 #include "w25q32.h"
 #include <stdio.h>
 #include "ota_message.h"
+#include "ec800m.h"
+#include "usart.h"
 #define APP_PROGRAMMER_BLOCK 2   //程序在W25Q32中存放的位置
 
 load_a load_A;       
 
+//返回str在数组中的索引
+static char* find_string(char *strs, char *str,int first, int len)
+{
+    int i = 0;
+	char *start = NULL;
+	strs = strs + first;
+    while(i < len){
+		start = strstr(strs, str);
+        if(start != NULL){
+            break;
+        }
+        i++;
+        strs++;
+    }
+    if(i == len + 1){
+        return NULL;
+    }
+    return start;
+}
+
+
+int WaitForReadData(uint8_t* data,int timeout,int datalen)
+{
+	uint32_t len = 0;
+	bool timeoutFlag = false;
+	if (timeout >= 0)
+	{
+		timeoutFlag = true;
+	}
+	while (1)
+	{
+		Delay_Ms(50);
+		if ((UART0_RX_STAT > 0) && (find_string((char *)&UART0_RX_BUF, "\r\nOK\r\n",datalen, sizeof(UART0_RX_BUF))))
+		{
+			UART0_RX_STAT = 0;
+			// char *p = strstr((char *)&UART0_RX_BUF, "CONNECT ");
+			// if (p)
+			// {
+				// p += 8;
+				// sscanf(p, "%u\r", &len);		// 读取长度
+				// if(len == datalen)
+				// {
+					// p = strchr(p, '\n') + 1;		// 跳过换行
+					memcpy(data,(char *)&UART0_RX_BUF,datalen);
+					Clear_DMA_Buffer();
+					return datalen;
+				// }
+				// else
+				// {
+				// 	Clear_DMA_Buffer();
+				// 	return len;
+				// }
+		}
+			
+		
+		timeout -= 50;
+		if (timeoutFlag == true && timeout <= 0)
+		{
+			Clear_DMA_Buffer();
+			return -1;
+		}
+		
+	}
+	
+}
+
 //进入bootloader更新
 void BootLoader_Brance(uint32_t app_byte)
 {
 	GD32_EraseFlash(GD32_A_START_PAGE,GD32_A_PAGE_NUM);//擦除A区原有程序
-	for(uint8_t i=0;i<app_byte/1024;i++)
+	/* 打开UFS:otaDATA.txt */
+	EC800MSendCmd(CLOSE_otaDATA_FILE,strlen(CLOSE_otaDATA_FILE));
+	WaitResponse("QFCLOSE",1000);
+	EC800MSendCmd(OPEN_otaDATA_FILE,strlen(OPEN_otaDATA_FILE));
+	if(WaitResponse("QFOPEN:", 2000) == 0)
+		return;
+	for(uint8_t i=0;i<app_byte/1024;i++)				//1KB写一次
 	{
-		task_fwdgt_reload();
 		uint8_t app_programmer[1024];
 		memset(app_programmer,0,1024);
-		uint32_t addr=APP_PROGRAMMER_BLOCK*64*1024+i*1024;   //其在w25q32中的地址
-		W25Q32_Read(app_programmer,addr,1024);               
+		// uint32_t addr=APP_PROGRAMMER_BLOCK*64*1024+i*1024;   //其在w25q32中的地址
+		// W25Q32_Read(app_programmer,addr,1024);
+		while(1)
+		{
+			task_fwdgt_reload();
+			int x = 0;
+			EC800MSendCmd(READ_otaDATA_FILE,strlen(READ_otaDATA_FILE));
+			Delay_Ms(200);
+			x = WaitForReadData(app_programmer,2000,1024);
+			// if((x != 1024) && (x != -1))
+			// {
+			// 	char* SEEK_otaDATA_FILE = "";
+			// 	sprintf(SEEK_otaDATA_FILE,"AT+QFSEEK=1,%d,2\r\n",x);
+			// 	EC800MSendCmd(SEEK_otaDATA_FILE,strlen(SEEK_otaDATA_FILE));	//出错的话文件指针向左偏移1024个字节
+			// }
+			// else 
+			if(x == 1024)
+			{
+				break;
+			}
+		}
 		GD32_WriteFlash(GD32_A_SADDR+i*1024,(uint32_t *)&app_programmer,1024); //将读出的数据按页写入数据
+		Delay_Ms(50);
 	}
 	//将不满1024数据单独写入
-	if(app_byte%1024!=0)
+	if(app_byte % 1024 != 0)
 	{
 		uint32_t startAddress=(app_byte/1024)*1024;
 		uint8_t app_programmer[1024];
-		uint32_t addr=APP_PROGRAMMER_BLOCK*64*1024+(app_byte/1024)*1024;   														//其在w25q32中的地址
 		memset(app_programmer,0,1024);
-		W25Q32_Read(app_programmer,addr,app_byte%1024);																					
-		GD32_WriteFlash(GD32_A_SADDR+(app_byte/1024)*1024,(uint32_t *)&app_programmer,app_byte%1024);
+		// uint32_t addr=APP_PROGRAMMER_BLOCK*64*1024+(app_byte/1024)*1024;   														//其在w25q32中的地址
+		// W25Q32_Read(app_programmer,addr,app_byte%1024);	
+		while(1)
+		{
+			task_fwdgt_reload();
+			int x = 0;
+			EC800MSendCmd(READ_otaDATA_FILE,strlen(READ_otaDATA_FILE));
+			Delay_Ms(200);
+			x = WaitForReadData(app_programmer,2000,app_byte % 1024);
+			// if(x != (app_byte % 1024) && (x != -1))
+			// {
+			// 	char* SEEK_otaDATA_FILE = "";
+			// 	sprintf(SEEK_otaDATA_FILE,"AT+QFSEEK=1,%d,2\r\n",x);
+			// 	EC800MSendCmd(SEEK_otaDATA_FILE,strlen(SEEK_otaDATA_FILE));	//出错的话文件指针向左偏移读取字节数
+			// }
+			// else 
+			if(x == (app_byte % 1024))
+			{
+				break;
+			}
+		}																			
+		GD32_WriteFlash(GD32_A_SADDR+(app_byte/1024)*1024,(uint32_t *)&app_programmer,app_byte % 1024);
+		Delay_Ms(50);
+	}
+	// 保存UFS文件
+	while(1)
+	{
+		EC800MSendCmd(CLOSE_otaDATA_FILE,strlen(CLOSE_otaDATA_FILE));
+		if(WaitResponse("OK", 2000) == 1)
+		{
+			break;
+		}
 	}
+	Delay_Ms(50);
 	clear_ota_message_config_block();  
 	LOAD_A(GD32_A_SADDR);
 }

+ 25 - 18
bootloader/HW/Source/ota_message.c

@@ -169,29 +169,36 @@ OTA_MESSAGE *get_config_params()
  *  输入参数:无
  *  输出参数:无
  *  返回值:无
- *  函数作用:清除block内包含的ota事件信息
+ *  函数作用:清除ota事件信息
  */
 void clear_ota_message_config_block(void)
 {
 	static OTA_MESSAGE ota_message = {0};
-	ota_message.otaflag = 1;
-	ota_message.XmodemByte = 200 * 1024;
 	
-	EC800MSendCmd(OPEN_otaMSG_FILE,strlen(OPEN_otaMSG_FILE));
-	if(WaitResponse("QFOPEN:", 2000) == 0)
-		return;
-
-	EC800MSendCmd(WRITE_otaMSG_FILE,strlen(WRITE_otaMSG_FILE));
-	if(WaitResponse("CONNECT", 2000))
-		return;
-
-	EC800MSendCmd((uint8_t *)&ota_message,sizeof(OTA_MESSAGE));
-	if(WaitResponse("QFWRITE", 5000))
-		return;
-
-	EC800MSendCmd(CLOSE_otaMSG_FILE,strlen(CLOSE_otaMSG_FILE));
-	if(WaitResponse("OK", 2000))
-		return;
+	while(1)
+	{
+		EC800MSendCmd(OPEN_otaMSG_FILE,strlen(OPEN_otaMSG_FILE));
+		if(WaitResponse("QFOPEN:", 2000))
+			break;
+	}
+	while(1)
+	{
+		EC800MSendCmd(WRITE_otaMSG_FILE,strlen(WRITE_otaMSG_FILE));
+		if(WaitResponse("CONNECT", 2000))
+			break;
+	}
+	while (1)
+	{
+		EC800MSendCmd((uint8_t *)&ota_message,sizeof(OTA_MESSAGE));
+		if(WaitResponse("QFWRITE", 5000))
+			break;
+	}
+	while (1)
+	{
+		EC800MSendCmd(CLOSE_otaMSG_FILE,strlen(CLOSE_otaMSG_FILE));
+		if(WaitResponse("OK", 2000))
+			break;
+	}
 
 	// EC800MSendCmd("AT+QFDEL=\"UFS:otaMSG.txt\r\n\"",27);	//删除文件
 }

BIN
bootloader/OBJ/boot.crf


+ 2 - 0
bootloader/OBJ/boot.d

@@ -39,3 +39,5 @@
 ..\obj\boot.o: ..\HW\Include\w25q32.h
 ..\obj\boot.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdio.h
 ..\obj\boot.o: ..\HW\Include\ota_message.h
+..\obj\boot.o: ..\HW\Include\ec800m.h
+..\obj\boot.o: ..\HW\Include\usart.h

BIN
bootloader/OBJ/bootloader.axf


+ 11 - 17
bootloader/OBJ/bootloader.build_log.htm

@@ -21,36 +21,30 @@ Target DLL:      Segger\JL2CM3.dll V2.99.40.0
 Dialog DLL:      TCM.DLL V1.53.0.0
  
 <h2>Project:</h2>
-D:\project\dtu_gateway\bootloader\USER\bootloader.uvprojx
-Project File Date:  10/28/2023
+d:\project\dtu_gateway\bootloader\USER\bootloader.uvprojx
+Project File Date:  10/31/2023
 
 <h2>Output:</h2>
 *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\software\MDK5\ARM\ARMCC\Bin'
 Build target 'bootloader'
-compiling ota_message.c...
+compiling main.c...
 ..\CMSIS\Include\gd32f10x.h(44): warning:  #47-D: incompatible redefinition of macro "GD32F10X_XD" 
   #define GD32F10X_XD
+main.h(25): warning:  #1295-D: Deprecated declaration task_fwdgt_reload - give arg types
+  void task_fwdgt_reload();
 ..\HW\Include\ota_message.h(14): warning:  #1295-D: Deprecated declaration load_ota_message_config_params - give arg types
   extern int load_ota_message_config_params();
 ..\HW\Include\ota_message.h(16): warning:  #1295-D: Deprecated declaration get_config_params - give arg types
   extern OTA_MESSAGE *get_config_params();
-..\HW\Include\ec800m.h(28): warning:  #2532-D: support for trigraphs is disabled
+..\HW\Include\ec800m.h(32): warning:  #2532-D: support for trigraphs is disabled
   // ??MQTT??3.1.1 ??????--4(mqtt 3.1.1 )3(mqtt 3.1)
-..\HW\Source\ota_message.c(118): warning:  #188-D: enumerated type mixed with another type
-  			return true;
-..\HW\Source\ota_message.c(122): warning:  #188-D: enumerated type mixed with another type
-  			return false;
-..\HW\Source\ota_message.c(113): warning:  #177-D: variable "temp"  was declared but never referenced
-  			char *temp;
-..\HW\Source\ota_message.c(125): warning:  #940-D: missing return statement at end of non-void function "WaitForUpData" 
+main.c(97): warning:  #1-D: last line of file ends without a newline
   }
-..\HW\Source\ota_message.c(188): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *"
-  	EC800MSendCmd((uint8_t *)&ota_message,sizeof(OTA_MESSAGE));
-..\HW\Source\ota_message.c: 9 warnings, 0 errors
+main.c: 6 warnings, 0 errors
 linking...
-Program Size: Code=8444 RO-data=400 RW-data=128 ZI-data=73992  
+Program Size: Code=8092 RO-data=400 RW-data=112 ZI-data=73992  
 FromELF: creating hex file...
-"..\OBJ\bootloader.axf" - 0 Error(s), 9 Warning(s).
+"..\OBJ\bootloader.axf" - 0 Error(s), 6 Warning(s).
 
 <h2>Software Packages used:</h2>
 
@@ -63,7 +57,7 @@ Package Vendor: GigaDevice
   D:\software\MDK5\Pack\GigaDevice\GD32F10x_DFP\2.1.0\Device\Include
 
 <h2>Collection of Component Files used:</h2>
-Build Time Elapsed:  00:00:01
+Build Time Elapsed:  00:00:02
 </pre>
 </body>
 </html>

Datei-Diff unterdrückt, da er zu groß ist
+ 333 - 403
bootloader/OBJ/bootloader.htm


+ 10 - 8
bootloader/OBJ/bootloader_bootloader.dep

@@ -34,7 +34,7 @@ I (..\LIB\Include\gd32f10x_enet.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
 F (..\CMSIS\Source\startup_gd32f10x_xd.s)(0x6538DC55)(--cpu Cortex-M3 -g --apcs=interwork --pd "__MICROLIB SETA 1"

-ID:\software\MDK5\Pack\GigaDevice\GD32F10x_DFP\2.1.0\Device\Include

--pd "__UVISION_VERSION SETA 536" --pd "GD32F10X_XD SETA 1" --pd "USE_STDPERIPH_DRIVER SETA 1"

--list .\listings\startup_gd32f10x_xd.lst --xref -o ..\obj\startup_gd32f10x_xd.o --depend ..\obj\startup_gd32f10x_xd.d)
-F (..\HW\Source\boot.c)(0x653C670E)(--c99 --gnu -c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\USER -I ..\CMSIS\Include -I ..\HW\Include -I ..\LIB\Include

-ID:\software\MDK5\Pack\GigaDevice\GD32F10x_DFP\2.1.0\Device\Include

-D__UVISION_VERSION="536" -DGD32F10X_XD -DUSE_STDPERIPH_DRIVER

-o ..\obj\boot.o --omf_browse ..\obj\boot.crf --depend ..\obj\boot.d)
+F (..\HW\Source\boot.c)(0x6543082D)(--c99 --gnu -c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\USER -I ..\CMSIS\Include -I ..\HW\Include -I ..\LIB\Include

-ID:\software\MDK5\Pack\GigaDevice\GD32F10x_DFP\2.1.0\Device\Include

-D__UVISION_VERSION="536" -DGD32F10X_XD -DUSE_STDPERIPH_DRIVER

-o ..\obj\boot.o --omf_browse ..\obj\boot.crf --depend ..\obj\boot.d)
 I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
@@ -68,12 +68,14 @@ I (..\LIB\Include\gd32f10x_enet.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
 I (..\HW\Include\boot.h)(0x6538DC55)
-I (..\USER\main.h)(0x653C6774)
+I (..\USER\main.h)(0x6540C37B)
 I (..\HW\Include\delay.h)(0x6538DC55)
 I (..\HW\Include\fmc.h)(0x653C6670)
 I (..\HW\Include\w25q32.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdio.h)(0x60252374)
 I (..\HW\Include\ota_message.h)(0x653B9E15)
+I (..\HW\Include\ec800m.h)(0x65409CA8)
+I (..\HW\Include\usart.h)(0x653C8151)
 F (..\HW\Source\delay.c)(0x6538DC55)(--c99 --gnu -c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\USER -I ..\CMSIS\Include -I ..\HW\Include -I ..\LIB\Include

-ID:\software\MDK5\Pack\GigaDevice\GD32F10x_DFP\2.1.0\Device\Include

-D__UVISION_VERSION="536" -DGD32F10X_XD -DUSE_STDPERIPH_DRIVER

-o ..\obj\delay.o --omf_browse ..\obj\delay.crf --depend ..\obj\delay.d)
 I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
@@ -246,7 +248,7 @@ I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
 I (..\HW\Include\spi.h)(0x6538DC55)
 I (..\HW\Include\w25q32.h)(0x6538DC55)
-F (..\HW\Source\ota_message.c)(0x653F6C21)(--c99 --gnu -c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\USER -I ..\CMSIS\Include -I ..\HW\Include -I ..\LIB\Include

-ID:\software\MDK5\Pack\GigaDevice\GD32F10x_DFP\2.1.0\Device\Include

-D__UVISION_VERSION="536" -DGD32F10X_XD -DUSE_STDPERIPH_DRIVER

-o ..\obj\ota_message.o --omf_browse ..\obj\ota_message.crf --depend ..\obj\ota_message.d)
+F (..\HW\Source\ota_message.c)(0x6540B5A3)(--c99 --gnu -c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\USER -I ..\CMSIS\Include -I ..\HW\Include -I ..\LIB\Include

-ID:\software\MDK5\Pack\GigaDevice\GD32F10x_DFP\2.1.0\Device\Include

-D__UVISION_VERSION="536" -DGD32F10X_XD -DUSE_STDPERIPH_DRIVER

-o ..\obj\ota_message.o --omf_browse ..\obj\ota_message.crf --depend ..\obj\ota_message.d)
 I (..\HW\Include\ota_message.h)(0x653B9E15)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\HW\Include\fmc.h)(0x653C6670)
@@ -282,12 +284,12 @@ I (..\LIB\Include\gd32f10x_enet.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
 I (..\HW\Include\w25q32.h)(0x6538DC55)
-I (..\HW\Include\ec800m.h)(0x653F28AB)
+I (..\HW\Include\ec800m.h)(0x65409CA8)
 I (..\HW\Include\usart.h)(0x653C8151)
 I (..\HW\Include\delay.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdio.h)(0x60252374)
 F (..\HW\Source\ec800m.c)(0x653CB6AE)(--c99 --gnu -c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\USER -I ..\CMSIS\Include -I ..\HW\Include -I ..\LIB\Include

-ID:\software\MDK5\Pack\GigaDevice\GD32F10x_DFP\2.1.0\Device\Include

-D__UVISION_VERSION="536" -DGD32F10X_XD -DUSE_STDPERIPH_DRIVER

-o ..\obj\ec800m.o --omf_browse ..\obj\ec800m.crf --depend ..\obj\ec800m.d)
-I (..\HW\Include\ec800m.h)(0x653F28AB)
+I (..\HW\Include\ec800m.h)(0x65409CA8)
 I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
@@ -686,7 +688,7 @@ I (..\LIB\Include\gd32f10x_can.h)(0x6538DC55)
 I (..\LIB\Include\gd32f10x_enet.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
-F (.\main.c)(0x653F6749)(--c99 --gnu -c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\USER -I ..\CMSIS\Include -I ..\HW\Include -I ..\LIB\Include

-ID:\software\MDK5\Pack\GigaDevice\GD32F10x_DFP\2.1.0\Device\Include

-D__UVISION_VERSION="536" -DGD32F10X_XD -DUSE_STDPERIPH_DRIVER

-o ..\obj\main.o --omf_browse ..\obj\main.crf --depend ..\obj\main.d)
+F (.\main.c)(0x654309C3)(--c99 --gnu -c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\USER -I ..\CMSIS\Include -I ..\HW\Include -I ..\LIB\Include

-ID:\software\MDK5\Pack\GigaDevice\GD32F10x_DFP\2.1.0\Device\Include

-D__UVISION_VERSION="536" -DGD32F10X_XD -DUSE_STDPERIPH_DRIVER

-o ..\obj\main.o --omf_browse ..\obj\main.crf --depend ..\obj\main.d)
 I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
@@ -719,11 +721,11 @@ I (..\LIB\Include\gd32f10x_can.h)(0x6538DC55)
 I (..\LIB\Include\gd32f10x_enet.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
-I (main.h)(0x653C6774)
+I (main.h)(0x6540C37B)
 I (..\HW\Include\delay.h)(0x6538DC55)
 I (..\HW\Include\fmc.h)(0x653C6670)
 I (..\HW\Include\ota_message.h)(0x653B9E15)
 I (..\HW\Include\usart.h)(0x653C8151)
-I (..\HW\Include\ec800m.h)(0x653F28AB)
+I (..\HW\Include\ec800m.h)(0x65409CA8)
 I (..\HW\Include\boot.h)(0x6538DC55)
 I (..\HW\Include\w25q32.h)(0x6538DC55)

+ 2 - 2
bootloader/OBJ/bootloader_sct.Bak

@@ -2,8 +2,8 @@
 ; *** Scatter-Loading Description File generated by uVision ***
 ; *************************************************************
 
-LR_IROM1 0x08000000 0x00100000  {    ; load region size_region
-  ER_IROM1 0x08000000 0x00100000  {  ; load address = execution address
+LR_IROM1 0x08000000 0x00007800  {    ; load region size_region
+  ER_IROM1 0x08000000 0x00007800  {  ; load address = execution address
    *.o (RESET, +First)
    *(InRoot$$Sections)
    .ANY (+RO)

BIN
bootloader/OBJ/ec800m.crf


BIN
bootloader/OBJ/main.crf


BIN
bootloader/OBJ/ota_message.crf


+ 4 - 0
bootloader/USER/.vscode/keil-assistant.log

@@ -1,2 +1,6 @@
 [info] Log at : 2023/10/28|11:27:20|GMT+0800
 
+[info] Log at : 2023/10/31|11:18:49|GMT+0800
+
+[info] Log at : 2023/11/2|10:30:35|GMT+0800
+

+ 48 - 32
bootloader/USER/.vscode/uv4.log

@@ -1,32 +1,48 @@
-*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\software\MDK5\ARM\ARMCC\Bin'
-Build target 'bootloader'
-compiling gd32f10x_it.c...
-..\CMSIS\Include\gd32f10x.h(44): warning:  #47-D: incompatible redefinition of macro "GD32F10X_XD" 
-  #define GD32F10X_XD
-..\HW\Source\gd32f10x_it.c: 1 warning, 0 errors
-linking...
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol UART0_RX_STAT (referred from gd32f10x_it.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol dma_channel_disable (referred from gd32f10x_it.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol dma_channel_enable (referred from gd32f10x_it.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol dma_interrupt_flag_clear (referred from gd32f10x_it.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol usart_data_receive (referred from gd32f10x_it.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol usart_interrupt_flag_clear (referred from gd32f10x_it.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol usart_interrupt_flag_get (referred from gd32f10x_it.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol EC800MSendCmd (referred from ota_message.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol addGatewayParams (referred from ota_message.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol delay_1ms (referred from ota_message.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol dma_config (referred from ota_message.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol dma_config_change (referred from ota_message.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol extract_data_from_buffer (referred from ota_message.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol EC800MPwoerOn (referred from main.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol EC800MWaitReady (referred from main.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol WaitResponse (referred from main.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol gd_EC800M_pin_init (referred from main.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol gd_com_init (referred from main.o).
-..\OBJ\bootloader.axf: Error: L6218E: Undefined symbol nvic_config (referred from main.o).
-Not enough information to list image symbols.
-Not enough information to list load addresses in the image map.
-Finished: 2 information, 0 warning and 19 error messages.
-"..\OBJ\bootloader.axf" - 19 Error(s), 1 Warning(s).
-Target not created.
-Build Time Elapsed:  00:00:01
+Load "..\\OBJ\\bootloader.axf" 
+Set JLink Project File to "d:\project\dtu_gateway\bootloader\USER\JLinkSettings.ini"* JLink Info: Device "GD32F103VG" selected.
+
+JLink info:
+------------
+DLL: V6.84a, compiled Sep  7 2020 17:26:08
+Firmware: J-Link V9 compiled May  7 2021 16:26:12
+Hardware: V9.40
+S/N : 69405423 
+Feature(s) : RDI, GDB, FlashDL, FlashBP, JFlash 
+
+* JLink Info: Found SW-DP with ID 0x1BA01477
+* JLink Info: DPIDR: 0x1BA01477
+* JLink Info: Scanning AP map to find all available APs
+* JLink Info: AP[1]: Stopped AP scan as end of AP map has been reached
+* JLink Info: AP[0]: AHB-AP (IDR: 0x24770011)
+* JLink Info: Iterating through AP map to find AHB-AP to use
+* JLink Info: AP[0]: Core found
+* JLink Info: AP[0]: AHB-AP ROM base: 0xE00FF000
+* JLink Info: CPUID register: 0x412FC231. Implementer code: 0x41 (ARM)
+* JLink Info: Found Cortex-M3 r2p1, Little endian.
+* JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots
+* JLink Info: CoreSight components:
+* JLink Info: ROMTbl[0] @ E00FF000
+* JLink Info: ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB000 SCS
+* JLink Info: ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
+* JLink Info: ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
+* JLink Info: ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
+* JLink Info: ROMTbl[0][4]: E0040000, CID: B105900D, PID: 003BB923 TPIU-Lite
+* JLink Info: ROMTbl[0][5]: E0041000, CID: B105900D, PID: 003BB924 ETM-M3
+ROMTableAddr = 0xE00FF000
+* JLink Info: Reset: Halt core after reset via DEMCR.VC_CORERESET.
+* JLink Info: Reset: Reset device via AIRCR.SYSRESETREQ.
+
+Target info:
+------------
+Device: GD32F103VG
+VTarget = 3.282V
+State of Pins: TCK: 0, TDI: 0, TDO: 0, TMS: 1, TRES: 1, TRST: 0
+Hardware-Breakpoints: 6
+Software-Breakpoints: 8192
+Watchpoints:          4
+JTAG speed: 500 kHz
+
+Erase Done.Programming Done.Verify OK.* JLink Info: Reset: Halt core after reset via DEMCR.VC_CORERESET.
+* JLink Info: Reset: Reset device via AIRCR.SYSRESETREQ.
+Application running ...
+Flash Load finished at 10:30:53

+ 1 - 1
bootloader/USER/.vscode/uv4.log.lock

@@ -1 +1 @@
-2023/10/28 11:36:37
+2023/11/2 10:30:53

Datei-Diff unterdrückt, da er zu groß ist
+ 2245 - 2044
bootloader/USER/JLinkLog.txt


Datei-Diff unterdrückt, da er zu groß ist
+ 433 - 466
bootloader/USER/Listings/bootloader.map


Datei-Diff unterdrückt, da er zu groß ist
+ 29 - 56
bootloader/USER/bootloader.uvguix.IBM


+ 27 - 29
bootloader/USER/bootloader.uvoptx

@@ -153,49 +153,47 @@
           <Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_XD -FS08000000 -FL0100000 -FP0($$Device:GD32F103VG$Flash\GD32F10x_XD.FLM))</Name>
         </SetRegEntry>
       </TargetDriverDllRegistry>
-      <Breakpoint>
-        <Bp>
-          <Number>0</Number>
-          <Type>0</Type>
-          <LineNumber>71</LineNumber>
-          <EnabledFlag>1</EnabledFlag>
-          <Address>134224354</Address>
-          <ByteObject>0</ByteObject>
-          <HtxType>0</HtxType>
-          <ManyObjects>0</ManyObjects>
-          <SizeOfObject>0</SizeOfObject>
-          <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>1</BreakIfRCount>
-          <Filename>.\main.c</Filename>
-          <ExecCommand></ExecCommand>
-          <Expression>\\bootloader\main.c\71</Expression>
-        </Bp>
-      </Breakpoint>
+      <Breakpoint/>
       <WatchWindow1>
         <Ww>
           <count>0</count>
           <WinNumber>1</WinNumber>
-          <ItemText>dmabuffer</ItemText>
+          <ItemText>ota_data</ItemText>
         </Ww>
         <Ww>
           <count>1</count>
           <WinNumber>1</WinNumber>
-          <ItemText>dmaBuffer</ItemText>
+          <ItemText>UART0_RX_BUF</ItemText>
         </Ww>
         <Ww>
           <count>2</count>
           <WinNumber>1</WinNumber>
-          <ItemText>dmabuffer[100]</ItemText>
+          <ItemText>x</ItemText>
         </Ww>
         <Ww>
           <count>3</count>
           <WinNumber>1</WinNumber>
-          <ItemText>\\bootloader\../HW/Source/ota_message.c\load_ota_message_config_params\dmabuffer[10]</ItemText>
+          <ItemText>app_programmer</ItemText>
         </Ww>
         <Ww>
           <count>4</count>
           <WinNumber>1</WinNumber>
-          <ItemText>start</ItemText>
+          <ItemText>SEEK_otaDATA_FILE</ItemText>
+        </Ww>
+        <Ww>
+          <count>5</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>dmaBuffer</ItemText>
+        </Ww>
+        <Ww>
+          <count>6</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>dmabuffer</ItemText>
+        </Ww>
+        <Ww>
+          <count>7</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>app_programmer</ItemText>
         </Ww>
       </WatchWindow1>
       <WatchWindow2>
@@ -208,24 +206,24 @@
       <MemoryWindow1>
         <Mm>
           <WinNumber>1</WinNumber>
-          <SubType>0</SubType>
-          <ItemText>strs</ItemText>
+          <SubType>8</SubType>
+          <ItemText>\\bootloader\../HW/Source/usart.c\UART0_RX_BUF</ItemText>
           <AccSizeX>0</AccSizeX>
         </Mm>
       </MemoryWindow1>
       <MemoryWindow2>
         <Mm>
           <WinNumber>2</WinNumber>
-          <SubType>0</SubType>
-          <ItemText>dmabuffer</ItemText>
+          <SubType>8</SubType>
+          <ItemText>app_programmer</ItemText>
           <AccSizeX>0</AccSizeX>
         </Mm>
       </MemoryWindow2>
       <MemoryWindow3>
         <Mm>
           <WinNumber>3</WinNumber>
-          <SubType>0</SubType>
-          <ItemText>ota_message</ItemText>
+          <SubType>8</SubType>
+          <ItemText>0x8005000</ItemText>
           <AccSizeX>0</AccSizeX>
         </Mm>
       </MemoryWindow3>

+ 41 - 41
bootloader/USER/main.c

@@ -10,64 +10,64 @@
 void task_fwdgt_reload(void);
 OTA_STRUCT UpDataA;           //A区更新用到的结构体
 
-void my_test(void)	//往UFS写好文件
-{
-	static OTA_MESSAGE ota_message = {0};
-	char str[100];
-	char string[] = "{\"otaflag\":1,\"XmodemByte\":102400}"; 
-	uint32_t i = 0;
-	ota_message.otaflag = 0;
-	ota_message.XmodemByte = 200 * 1024;
-	memcpy(str,string,strlen(string)+1);
-	char OPEN_FILE[] = "AT+QFOPEN=\"otaMSG.txt\",0\r\n";
-	char OPEN_NEW_FILE[] = "AT+QFOPEN=\"otaMSG.txt\",1\r\n";
-	char WRITEFILE[] = "AT+QFWRITE=1,8\r\n";
-	char CLOSEFILE[] = "AT+QFCLOSE=1\r\n";
-	char LOADFILE[] = "AT+QFDWL=otaMSG.txt\r\n";
-	// GD32_EraseFlash(420,1);
-	// GD32_WriteFlash(0x08069000,(uint32_t *)&ota_message,sizeof(OTA_MESSAGE)); 
-	// i = *(uint32_t*)(0x08069000);
-	// i = *(uint32_t*)(0x08069004);
-	EC800MSendCmd(OPEN_NEW_FILE,strlen(OPEN_NEW_FILE));
-	memset(str,0,sizeof(str));
-	strcpy(str,(char *)&UART0_RX_BUF);
-	i = WaitResponse("QFOPEN:", 2000);
-
-	EC800MSendCmd(WRITEFILE,strlen(WRITEFILE));
-	memset(str,0,sizeof(str));
-	strcpy(str,(char *)&UART0_RX_BUF);
-	i = WaitResponse("CONNECT", 2000);
+#if 0
+ void my_test(void)	//往UFS写好文件
+ {
+ 	static OTA_MESSAGE ota_message = {0};
+ 	char str[100];
+ 	char string[] = "{\"otaflag\":1,\"XmodemByte\":102400}"; 
+ 	uint32_t i = 0;
+ 	ota_message.otaflag = 1;
+ 	ota_message.XmodemByte = 17152;
+ 	memcpy(str,string,strlen(string)+1);
+ 	char OPEN_FILE[] = "AT+QFOPEN=\"otaMSG.txt\",0\r\n";
+ 	char OPEN_NEW_FILE[] = "AT+QFOPEN=\"otaMSG.txt\",1\r\n";
+ 	char WRITEFILE[] = "AT+QFWRITE=1,8\r\n";
+ 	char CLOSEFILE[] = "AT+QFCLOSE=1\r\n";
+ 	char LOADFILE[] = "AT+QFDWL=otaMSG.txt\r\n";
+ 	// GD32_EraseFlash(420,1);
+ 	// GD32_WriteFlash(0x08069000,(uint32_t *)&ota_message,sizeof(OTA_MESSAGE)); 
+ 	// i = *(uint32_t*)(0x08069000);
+ 	// i = *(uint32_t*)(0x08069004);
+ 	EC800MSendCmd(OPEN_NEW_FILE,strlen(OPEN_NEW_FILE));
+ 	memset(str,0,sizeof(str));
+ 	strcpy(str,(char *)&UART0_RX_BUF);
+ 	i = WaitResponse("QFOPEN:", 2000);
 
-	EC800MSendCmd((uint8_t *)&ota_message,sizeof(OTA_MESSAGE));
-	memset(str,0,sizeof(str));
-	strcpy(str,(char *)&UART0_RX_BUF);
-	i = WaitResponse("QFWRITE", 2000);
+ 	EC800MSendCmd(WRITEFILE,strlen(WRITEFILE));
+ 	memset(str,0,sizeof(str));
+ 	strcpy(str,(char *)&UART0_RX_BUF);
+ 	i = WaitResponse("CONNECT", 2000);
 
-	EC800MSendCmd(CLOSEFILE,strlen(CLOSEFILE));
-	memset(str,0,sizeof(str));
-	strcpy(str,(char *)&UART0_RX_BUF);
-	i = WaitResponse("OK", 2000);
+ 	EC800MSendCmd((uint8_t *)&ota_message,8);
+ 	memset(str,0,sizeof(str));
+ 	strcpy(str,(char *)&UART0_RX_BUF);
+ 	i = WaitResponse("QFWRITE", 2000);
 
-	free(str);
-	Delay_Ms(10);
-}
+ 	EC800MSendCmd(CLOSEFILE,strlen(CLOSEFILE));
+ 	memset(str,0,sizeof(str));
+ 	strcpy(str,(char *)&UART0_RX_BUF);
+ 	i = WaitResponse("OK", 2000);
 
+ 	free(str);
+ 	Delay_Ms(10);
+ }
+#endif
 
 int main(void)
 {
 	Delay_Init();
 	/* 弃用w25q32改用EC800存储ota文件 */
 	// W25Q32_Init();
-	nvic_config();	
+	nvic_config();
 	gd_com_init(COM_EC800);
 	dma_config();
 	gd_EC800M_pin_init();
 	EC800MPwoerOn();
 	EC800MWaitReady();
-
+	// my_test();
 	OTA_MESSAGE *ota_data;
 	task_fwdgt_reload();
-	my_test();
 	if(load_ota_message_config_params()==0)
 	{
 		//ota事件产生了,进入Bootloader分支

+ 1 - 1
bootloader/USER/main.h

@@ -9,7 +9,7 @@
 #define  GD32_B_PAGE_NUM    20                                                     //B区扇区个数
 #define  GD32_A_PAGE_NUM    GD32_PAGE_NUM - GD32_B_PAGE_NUM                        //A区扇区个数
 #define  GD32_A_START_PAGE  GD32_B_PAGE_NUM                                        //A区起始扇区编号
-#define  GD32_A_SADDR       GD32_FLASH_SADDR + GD32_A_START_PAGE * GD32_PAGE_SIZE  //A区起始地址
+#define  GD32_A_SADDR       GD32_FLASH_SADDR + GD32_A_START_PAGE * GD32_PAGE_SIZE  //A区起始地址0x08005000
 
 
 #define OTA_INFOCB_SIZE sizeof(OTA_InfoCB)    //OTA相关的信息结构体占用的字节长度