4 次代碼提交 78a687937f ... 522ce69018

作者 SHA1 備註 提交日期
  yang684665 522ce69018 测试结束,OTA升级正常 1 年之前
  yang684665 01753c467f 待测试bin下载到EM800中 1 年之前
  yang684665 bc5b60501f 实现字节读写和校验UFS文件 1 年之前
  yang684665 86a921addb 按json格式写读otaMSG.txt 1 年之前
共有 94 個文件被更改,包括 13158 次插入8079 次删除
  1. 20 0
      .vscode/c_cpp_properties.json
  2. 9 0
      .vscode/settings.json
  3. 6 1
      app/.vscode/settings.json
  4. 16 0
      app/App/ec800m.h
  5. 6 4
      app/App/main.c
  6. 287 28
      app/App/otaEvent.c
  7. 6 0
      app/Proj/.vscode/keil-assistant.log
  8. 48 5
      app/Proj/.vscode/uv4.log
  9. 1 1
      app/Proj/.vscode/uv4.log.lock
  10. 4074 455
      app/Proj/JLinkLog.txt
  11. 790 1113
      app/Proj/Listings/Ringzle.map
  12. 二進制
      app/Proj/Objects/Ringzle.axf
  13. 二進制
      app/Proj/Objects/Ringzle.bin
  14. 23 4
      app/Proj/Objects/Ringzle.build_log.htm
  15. 693 1801
      app/Proj/Objects/Ringzle.htm
  16. 43 39
      app/Proj/Objects/Ringzle_GD32F103C8T6.dep
  17. 二進制
      app/Proj/Objects/device_message.crf
  18. 二進制
      app/Proj/Objects/dlt645_port.crf
  19. 二進制
      app/Proj/Objects/ec800m.crf
  20. 二進制
      app/Proj/Objects/gd32f10x_it.crf
  21. 二進制
      app/Proj/Objects/key.crf
  22. 二進制
      app/Proj/Objects/log.crf
  23. 二進制
      app/Proj/Objects/main.crf
  24. 二進制
      app/Proj/Objects/mmodbus.crf
  25. 二進制
      app/Proj/Objects/mqttrecv.crf
  26. 二進制
      app/Proj/Objects/otaevent.crf
  27. 4 0
      app/Proj/Objects/otaevent.d
  28. 二進制
      app/Proj/Objects/parsedevicemessage.crf
  29. 二進制
      app/Proj/Objects/pc.crf
  30. 二進制
      app/Proj/Objects/systick.crf
  31. 二進制
      app/Proj/Objects/usart.crf
  32. 1797 29
      app/Proj/Ringzle.uvguix.IBM
  33. 65 23
      app/Proj/Ringzle.uvoptx
  34. 9 0
      app/Proj/Ringzle.uvprojx
  35. 2 2
      app/bsp/usart.c
  36. 5 1
      bootloader/.vscode/settings.json
  37. 1 1
      bootloader/CMSIS/Include/gd32f10x.h
  38. 71 0
      bootloader/HW/Include/ec800m.h
  39. 4 9
      bootloader/HW/Include/fmc.h
  40. 3 0
      bootloader/HW/Include/gd32f10x_it.h
  41. 85 0
      bootloader/HW/Include/usart.h
  42. 138 14
      bootloader/HW/Source/boot.c
  43. 80 0
      bootloader/HW/Source/ec800m.c
  44. 6 212
      bootloader/HW/Source/fmc.c
  45. 23 20
      bootloader/HW/Source/gd32f10x_it.c
  46. 150 11
      bootloader/HW/Source/ota_message.c
  47. 207 0
      bootloader/HW/Source/usart.c
  48. 二進制
      bootloader/OBJ/boot.crf
  49. 2 0
      bootloader/OBJ/boot.d
  50. 二進制
      bootloader/OBJ/bootloader.axf
  51. 12 14
      bootloader/OBJ/bootloader.build_log.htm
  52. 647 216
      bootloader/OBJ/bootloader.htm
  53. 5 0
      bootloader/OBJ/bootloader.lnp
  54. 205 28
      bootloader/OBJ/bootloader_bootloader.dep
  55. 2 2
      bootloader/OBJ/bootloader_sct.Bak
  56. 二進制
      bootloader/OBJ/delay.crf
  57. 二進制
      bootloader/OBJ/ec800m.crf
  58. 37 0
      bootloader/OBJ/ec800m.d
  59. 二進制
      bootloader/OBJ/fmc.crf
  60. 二進制
      bootloader/OBJ/gd32f10x_dma.crf
  61. 35 0
      bootloader/OBJ/gd32f10x_dma.d
  62. 二進制
      bootloader/OBJ/gd32f10x_exti.crf
  63. 35 0
      bootloader/OBJ/gd32f10x_exti.d
  64. 二進制
      bootloader/OBJ/gd32f10x_fmc.crf
  65. 二進制
      bootloader/OBJ/gd32f10x_fwdgt.crf
  66. 二進制
      bootloader/OBJ/gd32f10x_gpio.crf
  67. 二進制
      bootloader/OBJ/gd32f10x_it.crf
  68. 1 0
      bootloader/OBJ/gd32f10x_it.d
  69. 二進制
      bootloader/OBJ/gd32f10x_misc.crf
  70. 二進制
      bootloader/OBJ/gd32f10x_rcu.crf
  71. 二進制
      bootloader/OBJ/gd32f10x_spi.crf
  72. 二進制
      bootloader/OBJ/gd32f10x_usart.crf
  73. 35 0
      bootloader/OBJ/gd32f10x_usart.d
  74. 二進制
      bootloader/OBJ/gd32f10x_wwdgt.crf
  75. 二進制
      bootloader/OBJ/main.crf
  76. 2 0
      bootloader/OBJ/main.d
  77. 二進制
      bootloader/OBJ/ota_message.crf
  78. 3 0
      bootloader/OBJ/ota_message.d
  79. 二進制
      bootloader/OBJ/spi.crf
  80. 二進制
      bootloader/OBJ/system_gd32f10x.crf
  81. 二進制
      bootloader/OBJ/usart.crf
  82. 35 0
      bootloader/OBJ/usart.d
  83. 二進制
      bootloader/OBJ/w25q32.crf
  84. 94 0
      bootloader/USER/.vscode/c_cpp_properties.json
  85. 6 0
      bootloader/USER/.vscode/keil-assistant.log
  86. 48 0
      bootloader/USER/.vscode/uv4.log
  87. 1 0
      bootloader/USER/.vscode/uv4.log.lock
  88. 2245 3540
      bootloader/USER/JLinkLog.txt
  89. 734 282
      bootloader/USER/Listings/bootloader.map
  90. 91 100
      bootloader/USER/bootloader.uvguix.IBM
  91. 124 80
      bootloader/USER/bootloader.uvoptx
  92. 25 0
      bootloader/USER/bootloader.uvprojx
  93. 55 27
      bootloader/USER/main.c
  94. 7 17
      bootloader/USER/main.h

+ 20 - 0
.vscode/c_cpp_properties.json

@@ -0,0 +1,20 @@
+{
+    "configurations": [
+        {
+            "name": "Win32",
+            "includePath": [
+                "${workspaceFolder}/**"
+            ],
+            "defines": [
+                "_DEBUG",
+                "UNICODE",
+                "_UNICODE"
+            ],
+            "compilerPath": "C:/MinGW/bin/gcc.exe",
+            "cStandard": "c17",
+            "cppStandard": "c++17",
+            "intelliSenseMode": "windows-gcc-arm"
+        }
+    ],
+    "version": 4
+}

+ 9 - 0
.vscode/settings.json

@@ -0,0 +1,9 @@
+{
+    "files.associations": {
+        "fmc.h": "c",
+        "gd32f10x.h": "c",
+        "gd32f10x_libopt.h": "c",
+        "gd32f10x_enet.h": "c",
+        "main.h": "c"
+    }
+}

+ 6 - 1
app/.vscode/settings.json

@@ -6,6 +6,11 @@
         "gd32f10x_enet.h": "c",
         "systick.h": "c",
         "stdio.h": "c",
-        "main.h": "c"
+        "main.h": "c",
+        "device_message.h": "c",
+        "gd32f10x_gpio.h": "c",
+        "gd32f10x_exti.h": "c",
+        "type_traits": "c",
+        "cstdio": "c"
     }
 }

+ 16 - 0
app/App/ec800m.h

@@ -19,6 +19,22 @@
 #define CMD_GET_TO_FILE "AT+QHTTPREADFILE=\"UFS:http.txt\",80\r\n"
 #define CMD_HTTP_GET "QHTTPGET:"
 #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,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\",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"

+ 6 - 4
app/App/main.c

@@ -54,7 +54,7 @@ OF SUCH DAMAGE.
 #define UNIQUE_ID 0x1FFFF7E8
 
 
-#define VERSION "V1.0.2" // 版本号写死、通过人工手动控制
+#define VERSION "V1.0.1" // 版本号写死、通过人工手动控制
 
 #define GATEWAYNAME "DTU"
 #define GATEWAYMODE "4G" // 后续此mode可以切换4g
@@ -75,7 +75,7 @@ int main(void)
 	systick_config();
 	nvic_config();
 	/* initilize the LEDs, USART */
-//	W25Q32_Init(); 	//弃用w25q32,改用片内flash存储
+//	W25Q32_Init(); 	//弃用w25q32,改用EC800存储ota文件
 	gd_eval_led_init(LED1);
 	gd_com_init(COM_232);
 	gd_com_init(COM_EC800);
@@ -124,12 +124,14 @@ int main(void)
 	mmodbus_init(1);
 	dlt645_init(1);
 
+	usart_data_transmit(COM_232, 'P');
 	//开启看门狗
 //	fwdgt_init();
 	while (1)
 	{
 		check_ota_event();                              //检测是否有ota事件产生
-		MQTT_Alarm_clock(gateway->inboundTime, gateway);
+		// MQTT_Alarm_clock(gateway->inboundTime, gateway);
+		delay_1ms(5000);
 	}
 }
 /*
@@ -210,7 +212,7 @@ void readID(char *strId)
  */
 void http_load_config(uint8_t *httpURL)
 {
-	uint32_t BufferSize=46*1024;//最大获取的数据空间
+	uint32_t BufferSize=46*1024;//最大获取的数据空间4KB
 	char *dmabuffer=malloc(BufferSize);
 	__LOAD_CONFIG:
 	if (EC800MGetUrl(httpURL,dmabuffer,BufferSize) == true) // 从http获取信息,获取成功则保存到本地

+ 287 - 28
app/App/otaEvent.c

@@ -3,6 +3,9 @@
 #include "systick.h"
 #include "w25q32.h"
 #include "main.h"
+#include "ec800m.h"
+#include <stdio.h>
+#include "string.h"
 
 #define APPBLOCKNB 2      	//下载的程序位于block的第3块中
 #define OTA_EVENT_BLOCKNB 1 //OTA事件完成标志存储的位置位于第2块中
@@ -13,9 +16,123 @@
 #define EOT 0x04 // 结束标志
 int8_t xmodem(uint16_t timeout);
 OTA_T ota_data;
-uint8_t w25q32_data[256];  //存放w25q32数据
-
 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()
  *  输入参数:无
@@ -29,14 +146,16 @@ int8_t check_ota_event()
 	// 当标志位为1时证明ota事件产生,将进入ota升级路线
 	if (ota_data.ota_flag == 1)
 	{
-		W25Q32_Erase64K(APPBLOCKNB);                    //程序文件在第三block以后
-		int8_t recvSta = xmodem(1000);
+		// W25Q32_Erase64K(APPBLOCKNB);                    //程序文件在第三block以后
+		// 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();
 		}
 	}
@@ -44,6 +163,38 @@ int8_t check_ota_event()
 		return 0;
 }
 
+uint8_t WaitResponse_value(int timeout)
+{
+	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, ": ") + 2;
+			if (p)
+			{
+				uint8_t ret = 0;
+				ret = strtol(p, &p, 10);
+				Clear_DMA_Buffer();
+				return ret;
+			}
+		}
+		timeout -= 50;
+		if (timeoutFlag == true && timeout <= 0)
+		{
+			Clear_DMA_Buffer();
+			return 0;
+		}
+	};
+}
+
 int8_t xmodem(uint16_t timeout)
 {
 	int startTime = gettick();
@@ -54,10 +205,19 @@ int8_t xmodem(uint16_t timeout)
 	while(1)
 	{
 		task_fwdgt_reload();                                 //喂狗
-		if(gettick()-startTime>timeout*1000)return 0;
-		usart_data_transmit(COM_232, 'C');
+		if(gettick()-startTime>timeout*1000)return 0;		//如果一直得不到上位机的xmode数据相应,超时则跳出本函数
+		usart_data_transmit(COM_232, 'C');					//向上位机发送'C',表明请求xmodem数据
 		delay_1ms(1000);
-		if(ota_data.done==1)break;
+		if(ota_data.done==1)
+		{
+			//打开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;
+			break;							//如果上位机响应请求则跳出循环等待
+		}
 	}
 	// 判断数据帧头是否符合标准
 	while (gettick() - startTime < timeout * 1000)
@@ -65,23 +225,44 @@ int8_t xmodem(uint16_t timeout)
 		if (ota_data.done == 1)
 		{
 			task_fwdgt_reload();                                       //喂狗
-			if (ota_data.data[0] == SOH && ota_data.data_cnt == 133)
+			if (ota_data.data[0] == SOH && ota_data.data_cnt == 133)	//如果xmodem数据包是满的128个字节
 			{
-				uint16_t XCRC = Xmodem_CRC16(ota_data.data + 3, 128);
+				uint16_t XCRC = Xmodem_CRC16(ota_data.data + 3, 128);	
 				if (XCRC == ota_data.data[131] * 256 + ota_data.data[132]) // 经过校验的数据一致时将进行数据处理
 				{
-					data_flag.xmodemNB++;
-					//因为W25Q32只支持按页写入数据、所以将128字节数据找了一个暂存空间,两次应答才进行一次数据写入,最后在结束语句判断是否为奇数在进行
-					//数据尾部的处理
-					if(ota_data.data[1]%2==0)                                      
+					data_flag.xmodemNB++;	//xmodem数据包计数
+					// W25Q32_PageWrite(w25q32_data,APPBLOCKNB*256+(data_flag.xmodemNB-1)/2);
+					uint8_t sed_flg = 0;
+					while(sed_flg < 2)
 					{
-						memcpy(w25q32_data+128,ota_data.data + 3,128);
-						W25Q32_PageWrite(w25q32_data,APPBLOCKNB*256+(data_flag.xmodemNB-1)/2);
-						memset(w25q32_data,0,256);
+						EC800MSendCmd(WRITE_otaDATA_FILE,strlen(WRITE_otaDATA_FILE));
+						if(WaitResponse("CONNECT", 2000) == 0)
+						{
+							sed_flg++;
+						}
+						else
+						{
+							sed_flg = 0;
+							break;
+						}	
 					}
-					else
+					while(sed_flg < 2)
 					{
-						memcpy(w25q32_data,ota_data.data + 3,128);
+						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\r\n",x);
+							EC800MSendCmd(QFSEEK_CMD,strlen(QFSEEK_CMD));	//出错的话文件指针向左偏移x个字节
+						}
+						else
+						{
+							sed_flg = 0;
+							break;
+						}
 					}
 					
 					ota_data.data_cnt = 0;
@@ -101,22 +282,100 @@ int8_t xmodem(uint16_t timeout)
 			//进入结束的包处理
 			else if (ota_data.data[0] == EOT && ota_data.data_cnt == 1)
 			{
-				if(data_flag.xmodemNB%2!=0)                                            //将可能为奇数的数据写入进去
+				// if(data_flag.xmodemNB%2!=0)                                            //将可能为奇数的数据写入进去
+				// {
+					// W25Q32_PageWrite(w25q32_data,APPBLOCKNB*256+(data_flag.xmodemNB-1)/2);
+				// }
+				// 保存UFS文件
+				uint8_t sed_flg = 0;
+				while(sed_flg < 2)
 				{
-					W25Q32_PageWrite(w25q32_data,APPBLOCKNB*256+(data_flag.xmodemNB-1)/2);
+					EC800MSendCmd(CLOSE_otaDATA_FILE,strlen(CLOSE_otaDATA_FILE));
+					if(WaitResponse("OK", 2000) == 0)
+					{
+						sed_flg++;
+					}
+					else
+					{
+						sed_flg = 0;
+						break;
+					}	
 				}
-				
-				
-				
+
 				usart_data_transmit(COM_232, ACK);
 				//完成xmodem协议的交互将完成的标志存储到内存中
-				OTA_MESSAGE ota_message;
 				ota_message.Completion_flag=1U;
 				ota_message.XmodemByte=data_flag.xmodemNB*128;//后续补齐的0x1A还需要进一步考虑
 
-				W25Q32_Erase64K(OTA_EVENT_BLOCKNB);//擦除原先的数据
-				W25Q32_PageWrite((uint8_t *)&ota_message,OTA_EVENT_BLOCKNB*256);
-			
+				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)
+					{
+						sed_flg++;
+					}
+					else
+					{
+						sed_flg = 0;
+						break;
+					}
+				}
+				
+
+				while(sed_flg < 2)
+				{
+					EC800MSendCmd(WRITE_otaMSG_FILE,strlen(WRITE_otaMSG_FILE));
+					if(WaitResponse("CONNECT", 2000) == 0)
+					{
+						sed_flg++;
+					}
+					else
+					{
+						sed_flg = 0;
+						break;
+					}
+				}
+
+				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))
+					{
+						sed_flg++;
+						char* QFSEEK_CMD;
+						sprintf(QFSEEK_CMD,"AT+QFSEEK=1,%d,2",x);
+						EC800MSendCmd(QFSEEK_CMD,strlen(QFSEEK_CMD));	//出错的话文件指针向左偏移x个字节
+					}
+					else
+					{
+						sed_flg = 0;
+						break;
+					}
+				}
+
+				while(sed_flg < 2)
+				{
+					EC800MSendCmd(CLOSE_otaMSG_FILE,strlen(CLOSE_otaMSG_FILE));
+					if(WaitResponse("OK", 2000))
+					{
+						sed_flg++;
+					}
+					else
+					{
+						sed_flg = 0;
+						break;
+					}
+				}
+
+				// 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;

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

@@ -10,3 +10,9 @@
 
 [info] Log at : 2023/10/27|08:38:12|GMT+0800
 
+[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 - 5
app/Proj/.vscode/uv4.log

@@ -1,5 +1,48 @@
-*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\software\MDK5\ARM\ARMCC\Bin'
-Build target 'GD32F103C8T6'
-After Build - User command #1: fromelf --bin --output ./Objects/Ringzle.bin ./Objects/Ringzle.axf
-".\Objects\Ringzle.axf" - 0 Error(s), 0 Warning(s).
-Build Time Elapsed:  00:00:01
+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/25 17:58:17
+2023/11/2 10:29:55

File diff suppressed because it is too large
+ 4074 - 455
app/Proj/JLinkLog.txt


File diff suppressed because it is too large
+ 790 - 1113
app/Proj/Listings/Ringzle.map


二進制
app/Proj/Objects/Ringzle.axf


二進制
app/Proj/Objects/Ringzle.bin


+ 23 - 4
app/Proj/Objects/Ringzle.build_log.htm

@@ -21,14 +21,33 @@ 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/25/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 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(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=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), 0 Warning(s).
+".\Objects\Ringzle.axf" - 0 Error(s), 7 Warning(s).
 
 <h2>Software Packages used:</h2>
 
@@ -41,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:01
+Build Time Elapsed:  00:00:03
 </pre>
 </body>
 </html>

File diff suppressed because it is too large
+ 693 - 1801
app/Proj/Objects/Ringzle.htm


File diff suppressed because it is too large
+ 43 - 39
app/Proj/Objects/Ringzle_GD32F103C8T6.dep


二進制
app/Proj/Objects/device_message.crf


二進制
app/Proj/Objects/dlt645_port.crf


二進制
app/Proj/Objects/ec800m.crf


二進制
app/Proj/Objects/gd32f10x_it.crf


二進制
app/Proj/Objects/key.crf


二進制
app/Proj/Objects/log.crf


二進制
app/Proj/Objects/main.crf


二進制
app/Proj/Objects/mmodbus.crf


二進制
app/Proj/Objects/mqttrecv.crf


二進制
app/Proj/Objects/otaevent.crf


+ 4 - 0
app/Proj/Objects/otaevent.d

@@ -36,3 +36,7 @@
 .\objects\otaevent.o: ..\App\systick.h
 .\objects\otaevent.o: ..\bsp\w25q32.h
 .\objects\otaevent.o: ..\App\main.h
+.\objects\otaevent.o: ..\App\ec800m.h
+.\objects\otaevent.o: ..\App\device_message.h
+.\objects\otaevent.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdio.h
+.\objects\otaevent.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\string.h

二進制
app/Proj/Objects/parsedevicemessage.crf


二進制
app/Proj/Objects/pc.crf


二進制
app/Proj/Objects/systick.crf


二進制
app/Proj/Objects/usart.crf


File diff suppressed because it is too large
+ 1797 - 29
app/Proj/Ringzle.uvguix.IBM


+ 65 - 23
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,76 +157,118 @@
         <Bp>
           <Number>0</Number>
           <Type>0</Type>
-          <LineNumber>374</LineNumber>
+          <LineNumber>84</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>134261490</Address>
+          <Address>134253286</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
           <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\App\parseDeviceMessage.c</Filename>
+          <Filename>..\App\otaEvent.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression>\\Ringzle\../App/parseDeviceMessage.c\374</Expression>
+          <Expression>\\Ringzle\../App/otaEvent.c\84</Expression>
         </Bp>
         <Bp>
           <Number>1</Number>
           <Type>0</Type>
-          <LineNumber>94</LineNumber>
+          <LineNumber>127</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>0</Address>
+          <Address>134253502</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>0</BreakIfRCount>
-          <Filename>..\App\main.c</Filename>
+          <BreakIfRCount>1</BreakIfRCount>
+          <Filename>..\App\otaEvent.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression></Expression>
+          <Expression>\\Ringzle\../App/otaEvent.c\127</Expression>
         </Bp>
         <Bp>
           <Number>2</Number>
           <Type>0</Type>
-          <LineNumber>110</LineNumber>
+          <LineNumber>109</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>0</Address>
+          <Address>134253410</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>0</BreakIfRCount>
-          <Filename>..\App\main.c</Filename>
+          <BreakIfRCount>1</BreakIfRCount>
+          <Filename>..\App\otaEvent.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression></Expression>
+          <Expression>\\Ringzle\../App/otaEvent.c\109</Expression>
         </Bp>
         <Bp>
           <Number>3</Number>
           <Type>0</Type>
-          <LineNumber>149</LineNumber>
+          <LineNumber>159</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>0</Address>
+          <Address>134248376</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>0</BreakIfRCount>
-          <Filename>..\App\main.c</Filename>
+          <BreakIfRCount>1</BreakIfRCount>
+          <Filename>..\App\otaEvent.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression></Expression>
+          <Expression>\\Ringzle\../App/otaEvent.c\159</Expression>
         </Bp>
       </Breakpoint>
+      <WatchWindow1>
+        <Ww>
+          <count>0</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>Serial_RxData</ItemText>
+        </Ww>
+        <Ww>
+          <count>1</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>RxPacket.data[1]</ItemText>
+        </Ww>
+        <Ww>
+          <count>2</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>RxPacket</ItemText>
+        </Ww>
+        <Ww>
+          <count>3</count>
+          <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>dmaBuffer</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>
@@ -294,7 +336,7 @@
 
   <Group>
     <GroupName>Startup</GroupName>
-    <tvExp>0</tvExp>
+    <tvExp>1</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -582,7 +624,7 @@
       <GroupNumber>4</GroupNumber>
       <FileNumber>24</FileNumber>
       <FileType>1</FileType>
-      <tvExp>1</tvExp>
+      <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
       <PathWithFileName>..\Firmware\Source\gd32f10x_fmc.c</PathWithFileName>

+ 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>

+ 2 - 2
app/bsp/usart.c

@@ -120,8 +120,8 @@ void gd_com_init(uint32_t com)
     usart_transmit_config(com, USART_TRANSMIT_ENABLE);
     usart_enable(com);
 	// usart_interrupt_enable(com, USART_INT_TBE);
-	  usart_interrupt_enable(com, USART_INT_RBNE);
-   	usart_interrupt_enable(com, USART_INT_IDLE);
+	  usart_interrupt_enable(com, USART_INT_RBNE);  //开启接受终端
+   	usart_interrupt_enable(com, USART_INT_IDLE);    //开启空闲终端,也叫帧终端
     
 }
 

+ 5 - 1
bootloader/.vscode/settings.json

@@ -8,6 +8,10 @@
         "delay.h": "c",
         "boot.h": "c",
         "stdint.h": "c",
-        "string.h": "c"
+        "string.h": "c",
+        "usart.h": "c",
+        "ota_message.h": "c",
+        "ec800m.h": "c",
+        "gd32f10x_it.h": "c"
     }
 }

+ 1 - 1
bootloader/CMSIS/Include/gd32f10x.h

@@ -41,7 +41,7 @@ OF SUCH DAMAGE.
 #ifdef cplusplus
  extern "C" {
 #endif 
-
+#define GD32F10X_XD
 /* define GD32F10x */
 #if !defined (GD32F10X_MD) && !defined (GD32F10X_HD) && !defined (GD32F10X_XD) && !defined (GD32F10X_CL)
   /* #define GD32F10X_MD */     /*!< GD32F10X_MD: GD32 Medium density devices */

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

@@ -0,0 +1,71 @@
+#ifndef _EC800M_H
+#define _EC800M_H
+#include "gd32f10x.h"
+
+
+#define AT(cmd) "AT+"##cmd
+#define RSP_READY "RDY"
+#define RSP_OK "OK"
+#define RSP_CONNECT "CONNECT"
+
+#define CLIENTID "device_test"
+#define CMD_SET_PDP "AT+QICSGP=1,1,\"CTNET\",\"\",\"\",1\r\n" // UNINET?? CMNET?? CTNET??
+#define CMD_SET_ACTIVE "AT+QIACT=1\r\n"
+#define CMD_SET_URL "AT+QHTTPURL=%d\r\n"
+#define CMD_GET "AT+QHTTPGET=100\r\n"
+#define CMD_GET_TO_FILE "AT+QHTTPREADFILE=\"UFS:http.txt\",80\r\n"
+#define CMD_HTTP_GET "QHTTPGET:"
+#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 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"
+// ??MQTT??3.1.1 ??????--4(mqtt 3.1.1 )3(mqtt 3.1)
+#define CMD_MQTT_VERSION "AT+QMTCFG=\"version\",0,4\r\n"
+#define CMD_MQTT_KEEPALIVE "AT+QMTCFG=\"qmtping\",0,30\r\n" // 30????
+#define CMD_MQTT_OPENET "AT+QMTOPEN=0,\"36.134.23.11\",1883\r\n"
+// #define	CMD_MQTT_CONNECT  "AT+QMTCONN=0,\"%s\",\"%s\",\"%s\"\r\n"//  ?????clientid,username,password
+#define CMD_MQTT_CONNECT "AT+QMTCONN=0,\"device_test\",\"\",\"\"\r\n"
+#define CMD_MQTT_RECEIVE "AT+QMTCFG=\"recv/mode\",0,0,1\r\n"
+#define CMD_MQTT_SEND "AT+QMTCFG=\"send/mode\",0,0,1\r\n"
+// ???? ???????--??????--
+#define CMD_MQTT_SUBSCRIBE "AT+QMTSUB=0,1,\"%s\",0\r\n" // ????????
+#define CMD_SERVICE_Operatortyp						"AT+COPS?\r\n"
+#define CMD_SERVICE_Networktyp						"AT+CREG?\r\n"//7
+#define CMD_SERVICE_Networkstatu					"AT+COPS?\r\n"
+#define CMD_SERVICE_SIMcardstatus					"AT+CLCK=\"SC\",2\r\n"
+#define CMD_SERVICE_SIMcardICCID					"AT+QCCID\r\n"
+#define CMD_SERVICE_IMEInumber						"AT+GSN\r\n"
+#define CMD_SERVICE_Signalstrength				"AT+CSQ\r\n"
+
+
+#define AT_CMD_HEAD 	"AT"
+#define AT_CMD_CFG 		"+QMTCFG="
+#define AT_CMD_TEST 	"?"
+#define AT_CMD_VER		"version"
+
+//#define AT_CMD_T 		"AT+QMTCFG=?\r\n"
+
+#define AT_CMD_T 		"ATI\r\n"
+
+
+#define true 1
+#define false 0
+
+void EC800MPwoerOn(void);
+void EC800MSendCmd(char *buf, uint16_t len);
+
+void EC800MWaitReady(void);
+
+bool WaitResponse(char * expectStr, int timeout);
+
+#endif

+ 4 - 9
bootloader/HW/Include/fmc.h

@@ -12,8 +12,8 @@ void GD32_WriteFlash(uint32_t saddr, uint32_t *wdata, uint32_t wnum);   //
 
 /// 移植修改区 ///
 
-/* FLASH大小:512K */
-#define GD32FLASH_SIZE  0X00080000UL
+/* FLASH大小:3MB */
+#define GD32FLASH_SIZE  0X00300000UL
 
 /* FLASH起始地址 */
 #define GD32FLASH_BASE  FLASH_BASE
@@ -21,19 +21,14 @@ void GD32_WriteFlash(uint32_t saddr, uint32_t *wdata, uint32_t wnum);   //
 /* FLASH结束地址 */
 #define GD32FLASH_END   (GD32FLASH_BASE | GD32FLASH_SIZE)
 
-/* FLASH页大小:2K */
-#define GD32FLASH_PAGE_SIZE (2048U)
+/* FALSH页大小 */
+#define GD32FLASH_PAGE_SIZE 1024
 
 /* FLASH总页数 */
 #define GD32FLASH_PAGE_NUM  (GD32FLASH_SIZE / GD32FLASH_PAGE_SIZE)
 
 /// 导出函数声明 
-void FLASH_Init(void);
 uint32_t FLASH_Read(uint32_t Address, void *Buffer, uint32_t Size);
-uint32_t FLASH_Write(uint32_t Address, const uint16_t *Buffer, uint32_t NumToWrite);
-int FLASH_ErasePage(uint32_t PageAddress, uint32_t NbPages);
-uint32_t FLASH_WriteNotErase(uint32_t Address, const uint16_t *Buffer, uint32_t NumToWrite);
-
 
 #endif
 

+ 3 - 0
bootloader/HW/Include/gd32f10x_it.h

@@ -60,4 +60,7 @@ void PendSV_Handler(void);
 /* this function handles SysTick exception */
 void SysTick_Handler(void);
 
+void USART0_IRQHandler(void);
+void DMA0_Channel4_IRQHandler(void);
+
 #endif /* GD32F10X_IT_H */

+ 85 - 0
bootloader/HW/Include/usart.h

@@ -0,0 +1,85 @@
+#ifndef USART_H
+#define USART_H
+
+#include "gd32f10x.h"
+
+typedef struct usart_data_buf_s
+{
+	uint8_t data[256];
+	uint16_t data_cnt;
+} usart_data_buf_t;
+
+#define DE485_PIN                        GPIO_PIN_8
+#define DE485_GPIO_PORT                  GPIOA
+#define DE485_GPIO_CLK                   RCU_GPIOB
+
+#define EC800M_PER_PIN                   GPIO_PIN_1
+#define EC800M_PER_GPIO_PORT             GPIOC
+#define EC800M_PER_GPIO_CLK              RCU_GPIOC
+
+#define EC800M_RST_PIN                   GPIO_PIN_8
+#define EC800M_RST_GPIO_PORT             GPIOB
+#define EC800M_RST_GPIO_CLK              RCU_GPIOB
+
+#define COMn                             3U
+
+#define COM_EC800                        USART0 //USART1 EC800
+#define COM_EC800_CLK                    RCU_USART0
+#define COM_EC800_TX_PIN                 GPIO_PIN_9
+#define COM_EC800_RX_PIN                 GPIO_PIN_10
+#define COM_EC800_GPIO_PORT              GPIOA
+#define COM_EC800_GPIO_CLK               RCU_GPIOA
+#define COM_EC800_IT_HANDLER             USART0_IRQn
+#define COM_EC800_BAUDRATE							 115200
+
+#define COM_485	                       USART1 //UART2 J2 RS485
+#define COM_485_CLK                    RCU_USART1
+#define COM_485_TX_PIN                 GPIO_PIN_2
+#define COM_485_RX_PIN                 GPIO_PIN_3
+#define COM_485_GPIO_PORT              GPIOA
+#define COM_485_GPIO_CLK               RCU_GPIOA
+#define COM_485_IT_HANDLER             USART1_IRQn
+#define COM_485_BAUDRATE				 				2400
+
+#define COM_232                        USART2 //UART3 J3
+#define COM_232_CLK                    RCU_USART2
+#define COM_232_TX_PIN                 GPIO_PIN_8
+#define COM_232_RX_PIN                 GPIO_PIN_9
+#define COM_232_GPIO_PORT              GPIOD
+#define COM_232_GPIO_CLK               RCU_GPIOD
+#define COM_232_IT_HANDLER             USART2_IRQn
+#define COM_232_BAUDRATE							 115200
+
+//extern usart_data_buf_t usart0_rx_buf;
+//extern usart_data_buf_t usart0_tx_buf;
+
+//extern usart_data_buf_t usart1_rx_buf;
+//extern usart_data_buf_t usart1_tx_buf;
+
+/* configure COM port */
+void gd_com_init(uint32_t com);
+
+void gd_EC800M_pin_init(void);
+
+void gd_pull_EC800M_pwr_up(void);
+
+void gd_pull_EC800M_pwr_down(void);
+
+void gd_pull_EC800M_rst_up(void);
+
+void gd_pull_EC800M_rst_down(void);
+
+void dma_config(void);
+void Clear_DMA_Buffer(void);
+#define UART0_RX_LEN		1024 * 4	
+extern uint8_t UART0_RX_BUF[UART0_RX_LEN];
+extern uint8_t UART0_RX_STAT ;					
+extern uint32_t UART0_RX_NUM ;	
+extern uint8_t UART0_RX_MQTT_SUB_STAT;
+
+	
+void gd_com_sendByte( uint8_t com, uint8_t ch);
+void gd_com_send( uint32_t com, uint8_t *Buf,uint16_t size);
+void nvic_config(void);
+void dma_config_change(char *dmaBuffer,uint32_t bufferSize);
+#endif   

+ 138 - 14
bootloader/HW/Source/boot.c

@@ -6,32 +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 download_byte)
+void BootLoader_Brance(uint32_t app_byte)
 {
 	GD32_EraseFlash(GD32_A_START_PAGE,GD32_A_PAGE_NUM);//擦除A区原有程序
-	for(uint8_t i=0;i<download_byte/GD32_PAGE_SIZE;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[GD32_PAGE_SIZE];
-		memset(app_programmer,0,GD32_PAGE_SIZE);
-		FLASH_Read(GD32_D_SADDR,app_programmer,GD32_PAGE_SIZE);              
-		FLASH_Write(GD32_A_SADDR+i*GD32_PAGE_SIZE,(uint16_t *)&app_programmer,GD32_PAGE_SIZE/2);	//将读出的数据按页写入数据
+		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);
+		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(download_byte%GD32_PAGE_SIZE!=0)
+	if(app_byte % 1024 != 0)
+	{
+		uint32_t startAddress=(app_byte/1024)*1024;
+		uint8_t app_programmer[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)
+		{
+			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)
 	{
-		uint32_t startAddress=(download_byte/GD32_PAGE_SIZE)*GD32_PAGE_SIZE;
-		uint8_t app_programmer[GD32_PAGE_SIZE];
-		uint32_t addr=GD32_D_SADDR+startAddress;   														//其在w25q32中的地址
-		memset(app_programmer,0,GD32_PAGE_SIZE);
-		FLASH_Read(addr,app_programmer,GD32_PAGE_SIZE);              
-		FLASH_Write(GD32_A_SADDR+startAddress,(uint16_t *)&app_programmer,GD32_PAGE_SIZE/2);	//将读出的数据按页写入数据
+		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);
 }

+ 80 - 0
bootloader/HW/Source/ec800m.c

@@ -0,0 +1,80 @@
+#include "ec800m.h"
+#include "usart.h"
+#include "string.h"
+#include "delay.h"
+
+
+void EC800MPwoerOn(void)
+{
+	rcu_periph_clock_enable(RCU_GPIOD);
+	gpio_init(GPIOD, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_2);
+	gpio_bit_set(GPIOD,GPIO_PIN_2);
+	Delay_Ms(5000);
+	gd_pull_EC800M_pwr_up();
+	gd_pull_EC800M_rst_down();
+	Delay_Ms(50);
+	gd_pull_EC800M_pwr_down();
+	Delay_Ms(320);
+	gd_pull_EC800M_rst_up();
+	Delay_Ms(800);
+	gd_pull_EC800M_pwr_up();
+}
+
+void EC800MSendCmd(char *buf, uint16_t len)
+{
+	uint16_t i;
+	uint16_t data;
+	for (i = 0; i < len; i++)
+	{
+		data = buf[i];
+		usart_data_transmit(COM_EC800, data);
+		while (RESET == usart_flag_get(COM_EC800, USART_FLAG_TBE))
+			;
+	}
+}
+
+void EC800MWaitReady()
+{
+	WaitResponse(RSP_READY, 5000);
+}
+
+/*
+ *  函数名:bool WaitResponse(char *expectStr, int timeout)
+ *  输入参数:expectStr 需要匹配的关键�? timeout超时时间
+ *  输出参数:true flase
+ *  返回值:�?
+ *  函数作用:从UART0_RX_BUF缓冲区中匹配有无对应关键字有关键字则返回true无返回false
+ */
+bool WaitResponse(char *expectStr, int timeout)
+{
+	bool timeoutFlag = false;
+	if (timeout >= 0)
+	{
+		timeoutFlag = true;
+	}
+	// gd_485_send((char *)&UART0_RX_BUF, strlen(UART0_RX_BUF)); 不清楚�?��?�调�?485意义
+
+	while (1)
+	{
+		Delay_Ms(50);
+		if (UART0_RX_STAT > 0)
+		{
+			UART0_RX_STAT = 0;
+			char *p = strstr((char *)&UART0_RX_BUF, expectStr);
+			if (p)
+			{
+				Clear_DMA_Buffer();
+				return true;
+			}
+		}
+		timeout -= 50;
+		if (timeoutFlag == true && timeout <= 0)
+		{
+			Clear_DMA_Buffer();
+			return false;
+		}
+	};
+}
+
+
+

+ 6 - 212
bootloader/HW/Source/fmc.c

@@ -2,61 +2,19 @@
 #include "fmc.h"
 
 
-/*--------------------------------------------------*/
-/*函数名:按页擦除FLASH     							 */
-/*参  数:start:擦除起始页   num:擦几个页    		   */
-/*返回值:无                                         */
-/*
-flash结构:
-0x08000000~0x0807FFFF   bank0(2KB一页,0~255页,共256页)共512KB
-0x08080000~0x082FFFFF   bank1(4KB一页,256~895页,共640页)共2.5MB	这个分区连续读内存需要有延时
-*/
+/*-------------------------------------------------*/
+/*函数名:擦除FLASH                                */
+/*参  数:start:擦除起始扇区   num:擦几个扇区    */
+/*返回值:无                                       */
 /*-------------------------------------------------*/
 void GD32_EraseFlash(uint16_t start, uint16_t num)
 {
 	uint16_t i;        //用于for循环
-	uint16_t j = 0;        
-
-	if ((start <= 896) && (start + num) > 896)
-	{
-		num = 896 - start;
-	}
-	else if (start > 896)
-	{
-		return;
-	}
 
 	fmc_unlock();                                                       //解锁
-	if ((start < 256) && ((start + num) < 256))
-	{
-		for(i = 0; i < num; i++)										//循环num次,一个页一个页的擦除
-		{
-			fmc_page_erase((0x08000000 + start * 2048) + (2048 * i));   //擦除bank0一个页2KB
-		}
+	for(i=0;i<num;i++){                                                 //循环num次,一个扇区一个扇区的擦除
+		fmc_page_erase((0x08000000 + start * 1024) + (1024 * i));       //擦除一个扇区
 	}
-	else if ((start < 256) && ((start + num) > 256))
-	{
-		for(i = 0; i < num; i++)										//循环num次,一个页一个页的擦除
-		{
-			if((start + i) < 256)
-			{
-				fmc_page_erase((0x08000000 + start * 2 * 1024) + (2 * 1024 * i));       //擦除bank0一个页2KB
-			}
-			else
-			{
-				fmc_page_erase(0x08080000 + (4 * 1024 * j));       //擦除bank1一个页4KB
-				j++;
-			}
-		}
-	}
-	else if (start > 256)
-	{
-		for(i = 0; i < num; i++)										//循环num次,一个页一个页的擦除
-		{
-			fmc_page_erase((0x08080000 + (start - 256) * 4 * 1024) + (4 * 1024 * i));   //擦除bank1一个页4KB
-		}
-	}
-	
 	fmc_lock();                                                         //上锁
 } 
 /*---------------------------------------------------------------------*/
@@ -77,30 +35,6 @@ void GD32_WriteFlash(uint32_t saddr, uint32_t *wdata, uint32_t wnum)
 }
 
 
-// /**
-//  * @brief 读取flash数据
-//  * 
-//  * @param rbuff 接收缓冲区
-//  * @param addr 起始地址,32位地址
-//  * @param datalen 数据长度,多少个字节
-//  */
-// void GD32_ReadFlash(uint8_t *rbuff, uint32_t addr, uint32_t datalen)
-// {
-// 	memcpy(rbuff,addr,datalen);
-// }
-
-
-__align(4) static uint16_t FlashBuffer[GD32FLASH_PAGE_SIZE >> 1];
-
-/// 初始化FLASH
-void FLASH_Init(void)
-{
-    fmc_unlock();
-    fmc_flag_clear(FMC_FLAG_BANK0_END);
-    fmc_flag_clear(FMC_FLAG_BANK0_WPERR);
-    fmc_flag_clear(FMC_FLAG_BANK0_PGERR);
-    fmc_lock();
-}
 
 /**
  * 读FLASH
@@ -135,143 +69,3 @@ uint32_t FLASH_Read(uint32_t Address, void *Buffer, uint32_t Size)
     return Size - nread;
 }
 
-/**
- * 写FLASH
- * @param  Address    写入起始地址,!!!要求2字节对齐!!!
- * @param  Buffer     待写入的数据,!!!要求2字节对齐!!!
- * @param  NumToWrite 要写入的数据量,单位:半字,!!!要求2字节对齐!!!
- * @return            实际写入的数据量,单位:字节
- */
-uint32_t FLASH_Write(uint32_t Address, const uint16_t *Buffer, uint32_t NumToWrite)
-{
-    uint32_t i = 0;
-    uint32_t pagepos = 0;         // 页位置
-    uint32_t pageoff = 0;         // 页内偏移地址
-    uint32_t pagefre = 0;         // 页内空余空间
-    uint32_t offset = 0;          // Address在FLASH中的偏移
-    uint32_t nwrite = NumToWrite; // 记录剩余要写入的数据量
-    const uint16_t *pBuffer = (const uint16_t *)Buffer;
-
-    /* 非法地址 */
-    if (Address < GD32FLASH_BASE || Address > (GD32FLASH_END - 2) || NumToWrite == 0 || pBuffer == NULL)
-        return 0;
-
-    /* 解锁FLASH */
-    fmc_unlock();
-
-    /* 计算偏移地址 */
-    offset = Address - GD32FLASH_BASE;
-
-    /* 计算当前页位置 */
-    pagepos = offset / GD32FLASH_PAGE_SIZE;
-
-    /* 计算要写数据的起始地址在当前页内的偏移地址 */
-    pageoff = ((offset % GD32FLASH_PAGE_SIZE) >> 1);
-
-    /* 计算当前页内空余空间 */
-    pagefre = ((GD32FLASH_PAGE_SIZE >> 1) - pageoff);
-
-    /* 要写入的数据量低于当前页空余量 */
-    if (nwrite <= pagefre)
-        pagefre = nwrite;
-
-    while (nwrite != 0)
-    {
-        /* 检查是否超页 */
-        if (pagepos >= GD32FLASH_PAGE_NUM)
-            break;
-
-        /* 读取一页 */
-        FLASH_Read(GD32FLASH_BASE + pagepos * GD32FLASH_PAGE_SIZE, FlashBuffer, GD32FLASH_PAGE_SIZE);
-
-        /* 检查是否需要擦除 */
-        for (i = 0; i < pagefre; i++)
-        {
-            if (*(FlashBuffer + pageoff + i) != 0xFFFF) /* FLASH擦出后默认内容全为0xFF */
-                break;
-        }
-
-        if (i < pagefre)
-        {
-            uint32_t count = 0;
-            uint32_t index = 0;
-
-            if(FLASH_ErasePage(GD32FLASH_BASE + pagepos * GD32FLASH_PAGE_SIZE, 1) < 0)
-                break;
-
-            /* 复制到缓存 */
-            for (index = 0; index < pagefre; index++)
-            {
-                *(FlashBuffer + pageoff + index) = *(pBuffer + index);
-            }
-
-            /* 写回FLASH */
-            count = FLASH_WriteNotErase(GD32FLASH_BASE + pagepos * GD32FLASH_PAGE_SIZE, FlashBuffer, GD32FLASH_PAGE_SIZE >> 1);
-            if (count != (GD32FLASH_PAGE_SIZE >> 1))
-            {
-                nwrite -= count;
-                break;
-            }
-        }
-        else
-        {
-            /* 无需擦除,直接写 */
-            uint32_t count = FLASH_WriteNotErase(Address, pBuffer, pagefre);
-            if (count != pagefre)
-            {
-                nwrite -= count;
-                break;
-            }
-        }
-
-        pBuffer += pagefre;         /* 读取地址递增         */
-        Address += (pagefre << 1);  /* 写入地址递增         */
-        nwrite -= pagefre;          /* 更新剩余未写入数据量 */
-
-        pagepos++;     /* 下一页           */
-        pageoff = 0;   /* 页内偏移地址置零  */
-
-        /* 根据剩余量计算下次写入数据量 */
-        pagefre = nwrite >= (GD32FLASH_PAGE_SIZE >> 1) ? (GD32FLASH_PAGE_SIZE >> 1) : nwrite;
-    }
-
-    /* 加锁FLASH */
-    fmc_lock();
-
-    return ((NumToWrite - nwrite) << 1);
-}
-
-uint32_t FLASH_WriteNotErase(uint32_t Address, const uint16_t *Buffer, uint32_t NumToWrite)
-{
-    uint32_t nwrite = NumToWrite;
-    uint32_t addrmax = GD32FLASH_END - 2;
-
-    while (nwrite)
-    {
-        if (Address > addrmax)
-            break;
-
-        fmc_halfword_program(Address, *Buffer);
-        
-        if ((*(__IO uint16_t*) Address) != *Buffer)
-            break;
-
-        nwrite--;
-        Buffer++;
-        Address += 2;
-    }
-    return (NumToWrite - nwrite);
-}
-
-int FLASH_ErasePage(uint32_t PageAddress, uint32_t NbPages)
-{
-    while(NbPages--)
-    {
-        if(fmc_page_erase(PageAddress) != FMC_READY)
-        {
-            return -1;
-        }
-        PageAddress += GD32FLASH_PAGE_SIZE;
-    }
-    return 0;
-}

+ 23 - 20
bootloader/HW/Source/gd32f10x_it.c

@@ -35,26 +35,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
 OF SUCH DAMAGE.
 */
 #include "gd32f10x_it.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+#include "usart.h"
 
 /*!
     \brief      this function handles NMI exception
@@ -158,3 +139,25 @@ void SysTick_Handler(void)
 {
 
 }
+
+// 4G模块
+void USART0_IRQHandler(void)
+{
+    if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_IDLE)) // 空闲中断
+    {
+        usart_interrupt_flag_clear(USART0, USART_INT_FLAG_IDLE); /* 清除空闲中断标志位 */
+        usart_data_receive(USART0);                              /* 清除接收完成标志位 */
+        dma_channel_disable(DMA0, DMA_CH4);                      /* 关闭DMA传输 */
+//        UART0_RX_NUM = sizeof(UART0_RX_BUF) - dma_transfer_number_get(DMA0, DMA_CH4);
+//        UART0_RX_BUF[UART0_RX_NUM] = '\0'; /* 添加字符串结束符 */
+        UART0_RX_STAT = 0x01;              /* 接受状态 0x01:已接收到数据 */
+//        dma_memory_address_config(DMA0, DMA_CH4, (uint32_t)UART0_RX_BUF);
+//        dma_transfer_number_config(DMA0, DMA_CH4, sizeof(UART0_RX_BUF));
+			  dma_channel_enable(DMA0, DMA_CH4);			  
+    }
+}
+
+void DMA0_Channel4_IRQHandler(void)
+{
+	dma_interrupt_flag_clear(DMA0, DMA_CH4, DMA_INT_FLAG_G);
+}

+ 150 - 11
bootloader/HW/Source/ota_message.c

@@ -1,7 +1,11 @@
 #include "ota_message.h"
 #include "gd32f10x.h"
 #include "w25q32.h"
+#include "ec800m.h"
+#include "usart.h"
+#include "delay.h"
 #include <stdio.h>
+
 static OTA_MESSAGE ota_message = {0};
 void clear_ota_message_config_block(void);
 void write_ota_message_to_flash(uint32_t *data, int size){
@@ -27,7 +31,98 @@ int save_ota_message_config_params(OTA_MESSAGE *params)
 		return 0;
 }
 
+// 模块下载download校验值
+static uint16_t checksum(const char *str, uint16_t len)
+{
+  uint16_t sum = 0;
+  uint8_t odd = 0;
+
+  // 如果字符串长度为奇数,则将最后一个字符设置为高8位,低8位设置为0
+  if (len % 2 == 1)
+  {
+    odd = 1;
+    len--;
+  }
+
+  // 将每两个字符作为一个16位的数值进行异或操作
+  for (uint16_t i = 0; i < len; i += 2)
+  {
+    sum ^= ((uint16_t)str[i] << 8) | (uint16_t)str[i + 1];
+  }
+
+  // 如果字符串长度为奇数,则还需要将最后一个字符与0xFF00异或
+  if (odd)
+  {
+    sum ^= (uint16_t)str[len] << 8;
+  }
+  // 返回校验和
+  return sum;
+}
+
+//返回str在数组中的索引
+static char* find_string(char *strs, char *str, int len)
+{
+    int i = 0;
+	char *start = NULL;
+    while(i < len){
+		start = strstr(strs, str);
+        if(start != NULL){
+            break;
+        }
+        i++;
+        strs++;
+    }
+    if(i == len + 1){
+        return NULL;
+    }
+    return start;
+}
+
+
+/*
+ *  函数名:static void extract_data_from_buffer(const char* buffer, uint32_t *len_ptr, uint16_t *checkCode_ptr)
+ *  输入参数:buffer字符串
+ *  输出参数:json有效字符串长度len_ptr,checkCode_ptr校验码指针
+ *  返回值:无
+ *  函数作用:eg.   QFDWL: 621,3e23  从json信息最后端取出这段json的有效长度和校验码
+ */
+static void extract_data_from_buffer(char* buffer, uint32_t *len_ptr, uint16_t *checkCode_ptr)
+{
+  char *start = find_string(buffer, "+QFDWL:",128);
+  if (start != NULL)
+  {
+    start += 8; // 跳过"+QFDWL:"
+    uint32_t len = 0;
+    sscanf(start, "%u,", &len);     // 读取长度
+    start = strchr(start, ',') + 1; // 跳过逗号
+    uint16_t checkCode = 0;
+    sscanf(start, "%hx", &checkCode); // 读取16进制数据
+    // 将提取的数据存入形参
+    *len_ptr = len;
+    *checkCode_ptr = checkCode;
+  }
+}
 
+bool WaitForUpData(char* dmaBuffer)
+{
+	if (UART0_RX_STAT > 0)
+  	{
+		UART0_RX_STAT = 0;
+		uint32_t len;
+		uint16_t checkCode;
+			char *temp;
+		extract_data_from_buffer(dmaBuffer, &len, &checkCode);
+		uint16_t jsonCheck = checksum(dmaBuffer, len);
+		if (checkCode == jsonCheck)
+		{
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+	}
+}
 
 /*
  *  函数名:load_config_params(CONFIG_PARAMS *params)
@@ -38,15 +133,32 @@ int save_ota_message_config_params(OTA_MESSAGE *params)
  */
 int load_ota_message_config_params()
 {
-		memset(&ota_message, 0, sizeof(OTA_MESSAGE));//清空原先数据
-		// W25Q32_Read((uint8_t *)&ota_message, OTA_EVENT_BLOCK*64*1024, sizeof(OTA_MESSAGE)); //从W25Q32中读取结构体数据
-		FLASH_Read(OTA_EVENT_START_ADDR,&ota_message,sizeof(OTA_MESSAGE));
-		uint32_t *ptr=(uint32_t *)&ota_message;           
-		if(*ptr == 1U)
-		{
-			return 0;
-		}
-		else return -1;
+	//检查校验码
+	uint8_t BufferSize = 128;		//最大获取的数据空间
+	char dmabuffer[BufferSize];
+	__LOAD_CONFIG:
+	// get data from UFS
+	memset(dmabuffer,0,BufferSize);
+	dma_config_change(dmabuffer,BufferSize);
+	Delay_Ms(1000);
+	EC800MSendCmd(LOAD_otaMSG_FILE, strlen(LOAD_otaMSG_FILE)); //"AT+QFDWL=otaMSG.txt\r\n"
+	Delay_Ms(1000);
+	dma_config();
+	if(WaitForUpData(dmabuffer) == false) goto __LOAD_CONFIG;
+	// W25Q32_Read((uint8_t *)&ota_message, OTA_EVENT_BLOCK*64*1024, sizeof(OTA_MESSAGE)); //从W25Q32中读取结构体数据
+	// FLASH_Read(OTA_EVENT_START_ADDR,&ota_message,sizeof(OTA_MESSAGE));
+	memset(&ota_message,0,sizeof(OTA_MESSAGE));
+	memcpy((uint8_t*)&ota_message,dmabuffer,sizeof(OTA_MESSAGE));
+	free(dmabuffer);
+	if(ota_message.otaflag == 1U)
+	{
+		
+		return 0;
+	}
+	else 
+	{
+		return -1;
+	}
 }
 OTA_MESSAGE *get_config_params()
 {
@@ -57,9 +169,36 @@ OTA_MESSAGE *get_config_params()
  *  输入参数:无
  *  输出参数:无
  *  返回值:无
- *  函数作用:清除block内包含的ota事件信息
+ *  函数作用:清除ota事件信息
  */
 void clear_ota_message_config_block(void)
 {
-	GD32_EraseFlash(210,1);//擦除一块区域的大小
+	static OTA_MESSAGE ota_message = {0};
+	
+	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);	//删除文件
 }

+ 207 - 0
bootloader/HW/Source/usart.c

@@ -0,0 +1,207 @@
+#include "usart.h"
+
+
+    /*  \arg        COM_EC800:   EC800
+        \arg        COM_485: 485
+	    \arg        COM_232: 232
+    */
+static rcu_periph_enum COM_CLK[COMn] = {COM_EC800_CLK, COM_485_CLK, COM_232_CLK};
+static uint32_t COM_TX_PIN[COMn] = {COM_EC800_TX_PIN, COM_485_TX_PIN, COM_232_TX_PIN};
+static uint32_t COM_RX_PIN[COMn] = {COM_EC800_RX_PIN, COM_485_RX_PIN, COM_232_RX_PIN};
+static uint32_t COM_GPIO_PORT[COMn] = {COM_EC800_GPIO_PORT, COM_485_GPIO_PORT, COM_232_GPIO_PORT};
+static rcu_periph_enum COM_GPIO_CLK[COMn] = {COM_EC800_GPIO_CLK, COM_485_GPIO_CLK, COM_232_GPIO_CLK};	  
+static uint32_t COM_IT_HANDLER[COMn] = {COM_EC800_IT_HANDLER, COM_485_IT_HANDLER, COM_232_IT_HANDLER};
+static uint32_t COM_BAUDTATE[COMn]={COM_EC800_BAUDRATE,COM_485_BAUDRATE,COM_232_BAUDRATE};
+
+		
+uint8_t UART0_RX_BUF[UART0_RX_LEN];
+uint8_t UART0_RX_STAT = 0;
+uint8_t UART0_RX_MQTT_SUB_STAT=0;            //mqttt订阅信息标志位
+uint32_t UART0_RX_NUM = 0;	
+
+usart_data_buf_t usart1_rx_buf;
+//清除dma buffer内数据
+void Clear_DMA_Buffer(void)
+{
+   UART0_RX_NUM=0;
+   memset(UART0_RX_BUF,0,UART0_RX_LEN);
+}
+
+
+/*!
+    \brief      configure COM port
+    \param[in]  com: COM on the board
+        \arg        COM_EC800:   EC800
+        \arg        COM_485: 485
+	    \arg        COM_232: 232
+    \param[out] none
+    \retval     none
+*/
+void gd_com_init(uint32_t com)
+{
+    uint32_t com_id = 0U;
+    if(COM_EC800 == com)
+	{
+        com_id = 0U;
+    }
+	else if(COM_485 == com)
+	{
+		com_id=1U;
+	}
+	else if(COM_232 == com)
+	{
+        com_id = 2U;
+		//重映射usart2端口
+				rcu_periph_clock_enable(RCU_AF);
+				gpio_pin_remap_config(GPIO_USART2_FULL_REMAP, ENABLE);
+    }
+
+	//nvic_irq_enable(COM_IT_HANDLER[com_id], 0, 0);
+    
+    /* enable GPIO clock */
+				
+    rcu_periph_clock_enable(COM_GPIO_CLK[com_id]);
+
+    /* enable USART clock */
+    rcu_periph_clock_enable(COM_CLK[com_id]);
+		
+		
+    /* connect port to USARTx_Tx */
+    gpio_init(COM_GPIO_PORT[com_id], GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, COM_TX_PIN[com_id]);
+
+    /* connect port to USARTx_Rx */
+    gpio_init(COM_GPIO_PORT[com_id], GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, COM_RX_PIN[com_id]);
+		
+		
+    /* USART configure */
+    usart_deinit(com);
+    usart_baudrate_set(com, COM_BAUDTATE[com_id]);
+    usart_word_length_set(com, USART_WL_8BIT);
+    usart_stop_bit_set(com, USART_STB_1BIT);
+    usart_parity_config(com, USART_PM_NONE);
+    usart_hardware_flow_rts_config(com, USART_RTS_DISABLE);
+    usart_hardware_flow_cts_config(com, USART_CTS_DISABLE);
+    usart_receive_config(com, USART_RECEIVE_ENABLE);
+    usart_transmit_config(com, USART_TRANSMIT_ENABLE);
+    usart_enable(com);
+	// usart_interrupt_enable(com, USART_INT_TBE);
+	  usart_interrupt_enable(com, USART_INT_RBNE);
+   	usart_interrupt_enable(com, USART_INT_IDLE);
+    
+}
+
+/*!
+    \brief      configure EC800M pin
+    \param[out] none 
+    \retval     none
+*/
+void gd_EC800M_pin_init(void)
+{
+    /* enable the EC800M power pin clock */
+    rcu_periph_clock_enable(EC800M_PER_GPIO_CLK);
+    /* configure EC800M GPIO port */ 
+    gpio_init(EC800M_PER_GPIO_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, EC800M_PER_PIN);
+
+    GPIO_BC(EC800M_PER_GPIO_PORT) = EC800M_PER_PIN;
+
+    /* enable the EC800M reset pin clock */
+    rcu_periph_clock_enable(EC800M_RST_GPIO_CLK);
+    /* configure EC800M GPIO port */ 
+    gpio_init(EC800M_RST_GPIO_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, EC800M_RST_PIN);
+
+    GPIO_BC(EC800M_RST_GPIO_PORT) = EC800M_RST_PIN;
+    
+}
+
+void gd_pull_EC800M_pwr_up(void)
+{
+	GPIO_BOP(EC800M_PER_GPIO_PORT) = EC800M_PER_PIN;
+}
+
+void gd_pull_EC800M_pwr_down(void)
+{
+	GPIO_BC(EC800M_PER_GPIO_PORT) = EC800M_PER_PIN;
+}
+
+void gd_pull_EC800M_rst_up(void)
+{
+	GPIO_BOP(EC800M_RST_GPIO_PORT) = EC800M_RST_PIN;
+}
+
+void gd_pull_EC800M_rst_down(void)
+{
+	GPIO_BC(EC800M_RST_GPIO_PORT) = EC800M_RST_PIN;
+}
+
+////////////////////////////////////////////////////////////////////
+//默认的dma配置
+void dma_config(void)
+{
+    dma_parameter_struct dma_init_struct;
+
+    rcu_periph_clock_enable(RCU_DMA0);
+
+    dma_deinit(DMA0, DMA_CH4);
+    dma_init_struct.direction = DMA_PERIPHERAL_TO_MEMORY;		
+    dma_init_struct.memory_addr = (uint32_t)UART0_RX_BUF;		
+    dma_init_struct.memory_inc = DMA_MEMORY_INCREASE_ENABLE;	
+    dma_init_struct.memory_width = DMA_MEMORY_WIDTH_8BIT;		
+    dma_init_struct.number = UART0_RX_LEN;						
+    dma_init_struct.periph_addr = (uint32_t)(&USART_DATA(USART0));// ((uint32_t)0x40013804);		
+    dma_init_struct.periph_inc = DMA_PERIPH_INCREASE_DISABLE;	
+    dma_init_struct.periph_width = DMA_PERIPHERAL_WIDTH_8BIT;	
+    dma_init_struct.priority = DMA_PRIORITY_ULTRA_HIGH;			
+    dma_init(DMA0, DMA_CH4, &dma_init_struct);
+    
+    dma_circulation_disable(DMA0, DMA_CH4);
+    dma_memory_to_memory_disable(DMA0, DMA_CH4);
+
+    usart_dma_transmit_config(USART0, USART_DENT_ENABLE|USART_DENR_ENABLE);
+		//nvic_irq_enable(DMA0_Channel4_IRQn, 2, 2);
+	
+    dma_interrupt_enable(DMA0, DMA_CH4, DMA_INT_FTF|DMA_INT_HTF|DMA_INT_ERR);
+    dma_channel_enable(DMA0, DMA_CH4);
+	 
+
+}
+//手动控制dma搬运的数据地址和大小,在使用完成后需要恢复到默认的dma配置
+void dma_config_change(char *dmaBuffer,uint32_t bufferSize)
+{
+	  dma_parameter_struct dma_init_struct;
+
+    rcu_periph_clock_enable(RCU_DMA0);
+
+    dma_deinit(DMA0, DMA_CH4);
+    dma_init_struct.direction = DMA_PERIPHERAL_TO_MEMORY;		
+    dma_init_struct.memory_addr = (uint32_t)dmaBuffer;		
+    dma_init_struct.memory_inc = DMA_MEMORY_INCREASE_ENABLE;	
+    dma_init_struct.memory_width = DMA_MEMORY_WIDTH_8BIT;		
+    dma_init_struct.number = bufferSize;						
+    dma_init_struct.periph_addr = (uint32_t)(&USART_DATA(USART0));// ((uint32_t)0x40013804);		
+    dma_init_struct.periph_inc = DMA_PERIPH_INCREASE_DISABLE;	
+    dma_init_struct.periph_width = DMA_PERIPHERAL_WIDTH_8BIT;	
+    dma_init_struct.priority = DMA_PRIORITY_ULTRA_HIGH;			
+    dma_init(DMA0, DMA_CH4, &dma_init_struct);
+    
+    dma_circulation_disable(DMA0, DMA_CH4);
+    dma_memory_to_memory_disable(DMA0, DMA_CH4);
+
+    usart_dma_transmit_config(USART0, USART_DENT_ENABLE|USART_DENR_ENABLE);
+		//nvic_irq_enable(DMA0_Channel4_IRQn, 2, 2);
+	
+    dma_interrupt_enable(DMA0, DMA_CH4, DMA_INT_FTF|DMA_INT_ERR);
+    dma_channel_enable(DMA0, DMA_CH4);
+}
+
+
+void nvic_config(void)
+{
+    nvic_priority_group_set(NVIC_PRIGROUP_PRE2_SUB2);  // 设置抢占优先级和子优先级的位数为 2
+		nvic_irq_enable(USART0_IRQn, 0, 0);
+		// nvic_irq_enable(USART1_IRQn, 1, 0);
+		// nvic_irq_enable(USART2_IRQn, 2, 0);
+		nvic_irq_enable(DMA0_Channel4_IRQn, 2, 1);
+	
+}
+
+

二進制
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

二進制
bootloader/OBJ/bootloader.axf


+ 12 - 14
bootloader/OBJ/bootloader.build_log.htm

@@ -21,32 +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/27/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 main.c...
-main.h(35): warning:  #1295-D: Deprecated declaration task_fwdgt_reload - give arg types
+..\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();
-main.c(28): warning:  #167-D: argument of type "OTA_MESSAGE *" is incompatible with parameter of type "const uint16_t *"
-  	FLASH_Write(0x08069000,&ota_message,sizeof(OTA_MESSAGE)/2);
-main.c(15): warning:  #550-D: variable "i"  was set but never used
-  	uint32_t i = 0;
-main.c(20): warning:  #177-D: variable "state"  was declared but never referenced
-  	fmc_state_enum state;
-main.c(69): warning:  #1-D: last line of file ends without a newline
+..\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)
+main.c(97): warning:  #1-D: last line of file ends without a newline
   }
-main.c: 7 warnings, 0 errors
+main.c: 6 warnings, 0 errors
 linking...
-Program Size: Code=3416 RO-data=336 RW-data=28 ZI-data=6148  
+Program Size: Code=8092 RO-data=400 RW-data=112 ZI-data=73992  
 FromELF: creating hex file...
-"..\OBJ\bootloader.axf" - 0 Error(s), 7 Warning(s).
+"..\OBJ\bootloader.axf" - 0 Error(s), 6 Warning(s).
 
 <h2>Software Packages used:</h2>
 
@@ -59,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>

File diff suppressed because it is too large
+ 647 - 216
bootloader/OBJ/bootloader.htm


+ 5 - 0
bootloader/OBJ/bootloader.lnp

@@ -8,6 +8,8 @@
 "..\obj\spi.o"
 "..\obj\w25q32.o"
 "..\obj\ota_message.o"
+"..\obj\ec800m.o"
+"..\obj\usart.o"
 "..\obj\gd32f10x_wwdgt.o"
 "..\obj\gd32f10x_misc.o"
 "..\obj\gd32f10x_rcu.o"
@@ -15,6 +17,9 @@
 "..\obj\gd32f10x_fmc.o"
 "..\obj\gd32f10x_spi.o"
 "..\obj\gd32f10x_fwdgt.o"
+"..\obj\gd32f10x_dma.o"
+"..\obj\gd32f10x_exti.o"
+"..\obj\gd32f10x_usart.o"
 "..\obj\main.o"
 --library_type=microlib --strict --scatter "..\OBJ\bootloader.sct"
 --summary_stderr --info summarysizes --map --load_addr_map_info --xref --callgraph --symbols

+ 205 - 28
bootloader/OBJ/bootloader_bootloader.dep

@@ -1,7 +1,7 @@
 Dependencies for Project 'bootloader', Target 'bootloader': (DO NOT MODIFY !)
 CompilerVersion: 5060960::V5.06 update 7 (build 960)::.\ARMCC
 F (..\CMSIS\Source\system_gd32f10x.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\system_gd32f10x.o --omf_browse ..\obj\system_gd32f10x.crf --depend ..\obj\system_gd32f10x.d)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -34,8 +34,8 @@ 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)(0x653BA9E6)(--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)(0x653B6271)
+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)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -68,14 +68,16 @@ 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)(0x653BA110)
+I (..\USER\main.h)(0x6540C37B)
 I (..\HW\Include\delay.h)(0x6538DC55)
-I (..\HW\Include\fmc.h)(0x653B8771)
+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)(0x653B6271)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -108,8 +110,8 @@ 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\delay.h)(0x6538DC55)
-F (..\HW\Source\fmc.c)(0x653BA172)(--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\fmc.o --omf_browse ..\obj\fmc.crf --depend ..\obj\fmc.d)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+F (..\HW\Source\fmc.c)(0x653C6608)(--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\fmc.o --omf_browse ..\obj\fmc.crf --depend ..\obj\fmc.d)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -141,10 +143,10 @@ 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 (..\HW\Include\fmc.h)(0x653B8771)
-F (..\HW\Source\gd32f10x_it.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\gd32f10x_it.o --omf_browse ..\obj\gd32f10x_it.crf --depend ..\obj\gd32f10x_it.d)
-I (..\HW\Include\gd32f10x_it.h)(0x6538DC55)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\HW\Include\fmc.h)(0x653C6670)
+F (..\HW\Source\gd32f10x_it.c)(0x653C81BF)(--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\gd32f10x_it.o --omf_browse ..\obj\gd32f10x_it.crf --depend ..\obj\gd32f10x_it.d)
+I (..\HW\Include\gd32f10x_it.h)(0x653C7FE5)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -176,8 +178,9 @@ 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 (..\HW\Include\usart.h)(0x653C8151)
 F (..\HW\Source\spi.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\spi.o --omf_browse ..\obj\spi.crf --depend ..\obj\spi.d)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -211,7 +214,7 @@ I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
 I (..\HW\Include\spi.h)(0x6538DC55)
 F (..\HW\Source\w25q32.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\w25q32.o --omf_browse ..\obj\w25q32.crf --depend ..\obj\w25q32.d)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -245,11 +248,11 @@ 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)(0x653BA795)(--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)(0x653B8771)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\HW\Include\fmc.h)(0x653C6670)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
 I (..\CMSIS\Include\core_cmFunc.h)(0x6538DC55)
@@ -281,10 +284,83 @@ 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)(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)(0x65409CA8)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
+I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
+I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
+I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
+I (..\CMSIS\Include\core_cmFunc.h)(0x6538DC55)
+I (..\CMSIS\Include\system_gd32f10x.h)(0x6538DC55)
+I (D:\software\MDK5\ARM\ARMCC\include\string.h)(0x6025237E)
+I (..\CMSIS\Include\gd32f10x_libopt.h)(0x653B4F49)
+I (..\LIB\Include\gd32f10x_fmc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_pmu.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_bkp.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_rcu.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_exti.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_gpio.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_crc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dma.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dbg.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_adc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dac.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_fwdgt.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_wwdgt.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_rtc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_timer.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_usart.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_i2c.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_spi.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_sdio.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_exmc.h)(0x6538DC55)
+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 (..\HW\Include\usart.h)(0x653C8151)
+I (..\HW\Include\delay.h)(0x6538DC55)
+F (..\HW\Source\usart.c)(0x653C7D4D)(--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\usart.o --omf_browse ..\obj\usart.crf --depend ..\obj\usart.d)
+I (..\HW\Include\usart.h)(0x653C8151)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
+I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
+I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
+I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
+I (..\CMSIS\Include\core_cmFunc.h)(0x6538DC55)
+I (..\CMSIS\Include\system_gd32f10x.h)(0x6538DC55)
+I (D:\software\MDK5\ARM\ARMCC\include\string.h)(0x6025237E)
+I (..\CMSIS\Include\gd32f10x_libopt.h)(0x653B4F49)
+I (..\LIB\Include\gd32f10x_fmc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_pmu.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_bkp.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_rcu.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_exti.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_gpio.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_crc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dma.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dbg.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_adc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dac.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_fwdgt.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_wwdgt.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_rtc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_timer.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_usart.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_i2c.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_spi.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_sdio.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_exmc.h)(0x6538DC55)
+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 (..\LIB\Source\gd32f10x_wwdgt.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\gd32f10x_wwdgt.o --omf_browse ..\obj\gd32f10x_wwdgt.crf --depend ..\obj\gd32f10x_wwdgt.d)
 I (..\LIB\Include\gd32f10x_wwdgt.h)(0x6538DC55)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -317,7 +393,7 @@ I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
 F (..\LIB\Source\gd32f10x_misc.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\gd32f10x_misc.o --omf_browse ..\obj\gd32f10x_misc.crf --depend ..\obj\gd32f10x_misc.d)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -350,7 +426,7 @@ I (..\LIB\Include\gd32f10x_enet.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 F (..\LIB\Source\gd32f10x_rcu.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\gd32f10x_rcu.o --omf_browse ..\obj\gd32f10x_rcu.crf --depend ..\obj\gd32f10x_rcu.d)
 I (..\LIB\Include\gd32f10x_rcu.h)(0x6538DC55)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -383,7 +459,7 @@ I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
 F (..\LIB\Source\gd32f10x_gpio.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\gd32f10x_gpio.o --omf_browse ..\obj\gd32f10x_gpio.crf --depend ..\obj\gd32f10x_gpio.d)
 I (..\LIB\Include\gd32f10x_gpio.h)(0x6538DC55)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -416,7 +492,7 @@ I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
 F (..\LIB\Source\gd32f10x_fmc.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\gd32f10x_fmc.o --omf_browse ..\obj\gd32f10x_fmc.crf --depend ..\obj\gd32f10x_fmc.d)
 I (..\LIB\Include\gd32f10x_fmc.h)(0x6538DC55)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -449,7 +525,7 @@ I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
 F (..\LIB\Source\gd32f10x_spi.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\gd32f10x_spi.o --omf_browse ..\obj\gd32f10x_spi.crf --depend ..\obj\gd32f10x_spi.d)
 I (..\LIB\Include\gd32f10x_spi.h)(0x6538DC55)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -482,7 +558,7 @@ I (D:\software\MDK5\ARM\ARMCC\include\stdlib.h)(0x60252374)
 I (..\LIB\Include\gd32f10x_misc.h)(0x6538DC55)
 F (..\LIB\Source\gd32f10x_fwdgt.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\gd32f10x_fwdgt.o --omf_browse ..\obj\gd32f10x_fwdgt.crf --depend ..\obj\gd32f10x_fwdgt.d)
 I (..\LIB\Include\gd32f10x_fwdgt.h)(0x6538DC55)
-I (..\CMSIS\Include\gd32f10x.h)(0x653B6271)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
 I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
 I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -513,8 +589,107 @@ 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)(0x653BABD1)(--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)(0x653B6271)
+F (..\LIB\Source\gd32f10x_dma.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\gd32f10x_dma.o --omf_browse ..\obj\gd32f10x_dma.crf --depend ..\obj\gd32f10x_dma.d)
+I (..\LIB\Include\gd32f10x_dma.h)(0x6538DC55)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
+I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
+I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
+I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
+I (..\CMSIS\Include\core_cmFunc.h)(0x6538DC55)
+I (..\CMSIS\Include\system_gd32f10x.h)(0x6538DC55)
+I (D:\software\MDK5\ARM\ARMCC\include\string.h)(0x6025237E)
+I (..\CMSIS\Include\gd32f10x_libopt.h)(0x653B4F49)
+I (..\LIB\Include\gd32f10x_fmc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_pmu.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_bkp.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_rcu.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_exti.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_gpio.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_crc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dbg.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_adc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dac.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_fwdgt.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_wwdgt.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_rtc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_timer.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_usart.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_i2c.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_spi.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_sdio.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_exmc.h)(0x6538DC55)
+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 (..\LIB\Source\gd32f10x_exti.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\gd32f10x_exti.o --omf_browse ..\obj\gd32f10x_exti.crf --depend ..\obj\gd32f10x_exti.d)
+I (..\LIB\Include\gd32f10x_exti.h)(0x6538DC55)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
+I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
+I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
+I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
+I (..\CMSIS\Include\core_cmFunc.h)(0x6538DC55)
+I (..\CMSIS\Include\system_gd32f10x.h)(0x6538DC55)
+I (D:\software\MDK5\ARM\ARMCC\include\string.h)(0x6025237E)
+I (..\CMSIS\Include\gd32f10x_libopt.h)(0x653B4F49)
+I (..\LIB\Include\gd32f10x_fmc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_pmu.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_bkp.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_rcu.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_gpio.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_crc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dma.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dbg.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_adc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dac.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_fwdgt.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_wwdgt.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_rtc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_timer.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_usart.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_i2c.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_spi.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_sdio.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_exmc.h)(0x6538DC55)
+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 (..\LIB\Source\gd32f10x_usart.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\gd32f10x_usart.o --omf_browse ..\obj\gd32f10x_usart.crf --depend ..\obj\gd32f10x_usart.d)
+I (..\LIB\Include\gd32f10x_usart.h)(0x6538DC55)
+I (..\CMSIS\Include\gd32f10x.h)(0x653C6D66)
+I (..\CMSIS\Include\core_cm3.h)(0x6538DC55)
+I (D:\software\MDK5\ARM\ARMCC\include\stdint.h)(0x6025237E)
+I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
+I (..\CMSIS\Include\core_cmFunc.h)(0x6538DC55)
+I (..\CMSIS\Include\system_gd32f10x.h)(0x6538DC55)
+I (D:\software\MDK5\ARM\ARMCC\include\string.h)(0x6025237E)
+I (..\CMSIS\Include\gd32f10x_libopt.h)(0x653B4F49)
+I (..\LIB\Include\gd32f10x_fmc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_pmu.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_bkp.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_rcu.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_exti.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_gpio.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_crc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dma.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dbg.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_adc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_dac.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_fwdgt.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_wwdgt.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_rtc.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_timer.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_i2c.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_spi.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_sdio.h)(0x6538DC55)
+I (..\LIB\Include\gd32f10x_exmc.h)(0x6538DC55)
+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)(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)
 I (..\CMSIS\Include\core_cmInstr.h)(0x6538DC55)
@@ -546,9 +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)(0x653BA110)
+I (main.h)(0x6540C37B)
 I (..\HW\Include\delay.h)(0x6538DC55)
-I (..\HW\Include\fmc.h)(0x653B8771)
+I (..\HW\Include\fmc.h)(0x653C6670)
 I (..\HW\Include\ota_message.h)(0x653B9E15)
+I (..\HW\Include\usart.h)(0x653C8151)
+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)

二進制
bootloader/OBJ/delay.crf


二進制
bootloader/OBJ/ec800m.crf


+ 37 - 0
bootloader/OBJ/ec800m.d

@@ -0,0 +1,37 @@
+..\obj\ec800m.o: ..\HW\Source\ec800m.c
+..\obj\ec800m.o: ..\HW\Include\ec800m.h
+..\obj\ec800m.o: ..\CMSIS\Include\gd32f10x.h
+..\obj\ec800m.o: ..\CMSIS\Include\core_cm3.h
+..\obj\ec800m.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdint.h
+..\obj\ec800m.o: ..\CMSIS\Include\core_cmInstr.h
+..\obj\ec800m.o: ..\CMSIS\Include\core_cmFunc.h
+..\obj\ec800m.o: ..\CMSIS\Include\system_gd32f10x.h
+..\obj\ec800m.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\string.h
+..\obj\ec800m.o: ..\CMSIS\Include\gd32f10x_libopt.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_fmc.h
+..\obj\ec800m.o: ..\CMSIS\Include\gd32f10x.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_pmu.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_bkp.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_rcu.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_exti.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_gpio.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_crc.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_dma.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_dbg.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_adc.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_dac.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_fwdgt.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_wwdgt.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_rtc.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_timer.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_usart.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_i2c.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_spi.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_sdio.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_exmc.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_can.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_enet.h
+..\obj\ec800m.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdlib.h
+..\obj\ec800m.o: ..\LIB\Include\gd32f10x_misc.h
+..\obj\ec800m.o: ..\HW\Include\usart.h
+..\obj\ec800m.o: ..\HW\Include\delay.h

二進制
bootloader/OBJ/fmc.crf


二進制
bootloader/OBJ/gd32f10x_dma.crf


+ 35 - 0
bootloader/OBJ/gd32f10x_dma.d

@@ -0,0 +1,35 @@
+..\obj\gd32f10x_dma.o: ..\LIB\Source\gd32f10x_dma.c
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_dma.h
+..\obj\gd32f10x_dma.o: ..\CMSIS\Include\gd32f10x.h
+..\obj\gd32f10x_dma.o: ..\CMSIS\Include\core_cm3.h
+..\obj\gd32f10x_dma.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdint.h
+..\obj\gd32f10x_dma.o: ..\CMSIS\Include\core_cmInstr.h
+..\obj\gd32f10x_dma.o: ..\CMSIS\Include\core_cmFunc.h
+..\obj\gd32f10x_dma.o: ..\CMSIS\Include\system_gd32f10x.h
+..\obj\gd32f10x_dma.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\string.h
+..\obj\gd32f10x_dma.o: ..\CMSIS\Include\gd32f10x_libopt.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_fmc.h
+..\obj\gd32f10x_dma.o: ..\CMSIS\Include\gd32f10x.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_pmu.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_bkp.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_rcu.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_exti.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_gpio.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_crc.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_dma.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_dbg.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_adc.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_dac.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_fwdgt.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_wwdgt.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_rtc.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_timer.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_usart.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_i2c.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_spi.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_sdio.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_exmc.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_can.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_enet.h
+..\obj\gd32f10x_dma.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdlib.h
+..\obj\gd32f10x_dma.o: ..\LIB\Include\gd32f10x_misc.h

二進制
bootloader/OBJ/gd32f10x_exti.crf


+ 35 - 0
bootloader/OBJ/gd32f10x_exti.d

@@ -0,0 +1,35 @@
+..\obj\gd32f10x_exti.o: ..\LIB\Source\gd32f10x_exti.c
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_exti.h
+..\obj\gd32f10x_exti.o: ..\CMSIS\Include\gd32f10x.h
+..\obj\gd32f10x_exti.o: ..\CMSIS\Include\core_cm3.h
+..\obj\gd32f10x_exti.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdint.h
+..\obj\gd32f10x_exti.o: ..\CMSIS\Include\core_cmInstr.h
+..\obj\gd32f10x_exti.o: ..\CMSIS\Include\core_cmFunc.h
+..\obj\gd32f10x_exti.o: ..\CMSIS\Include\system_gd32f10x.h
+..\obj\gd32f10x_exti.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\string.h
+..\obj\gd32f10x_exti.o: ..\CMSIS\Include\gd32f10x_libopt.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_fmc.h
+..\obj\gd32f10x_exti.o: ..\CMSIS\Include\gd32f10x.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_pmu.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_bkp.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_rcu.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_exti.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_gpio.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_crc.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_dma.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_dbg.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_adc.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_dac.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_fwdgt.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_wwdgt.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_rtc.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_timer.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_usart.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_i2c.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_spi.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_sdio.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_exmc.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_can.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_enet.h
+..\obj\gd32f10x_exti.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdlib.h
+..\obj\gd32f10x_exti.o: ..\LIB\Include\gd32f10x_misc.h

二進制
bootloader/OBJ/gd32f10x_fmc.crf


二進制
bootloader/OBJ/gd32f10x_fwdgt.crf


二進制
bootloader/OBJ/gd32f10x_gpio.crf


二進制
bootloader/OBJ/gd32f10x_it.crf


+ 1 - 0
bootloader/OBJ/gd32f10x_it.d

@@ -33,3 +33,4 @@
 ..\obj\gd32f10x_it.o: ..\LIB\Include\gd32f10x_enet.h
 ..\obj\gd32f10x_it.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdlib.h
 ..\obj\gd32f10x_it.o: ..\LIB\Include\gd32f10x_misc.h
+..\obj\gd32f10x_it.o: ..\HW\Include\usart.h

二進制
bootloader/OBJ/gd32f10x_misc.crf


二進制
bootloader/OBJ/gd32f10x_rcu.crf


二進制
bootloader/OBJ/gd32f10x_spi.crf


二進制
bootloader/OBJ/gd32f10x_usart.crf


+ 35 - 0
bootloader/OBJ/gd32f10x_usart.d

@@ -0,0 +1,35 @@
+..\obj\gd32f10x_usart.o: ..\LIB\Source\gd32f10x_usart.c
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_usart.h
+..\obj\gd32f10x_usart.o: ..\CMSIS\Include\gd32f10x.h
+..\obj\gd32f10x_usart.o: ..\CMSIS\Include\core_cm3.h
+..\obj\gd32f10x_usart.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdint.h
+..\obj\gd32f10x_usart.o: ..\CMSIS\Include\core_cmInstr.h
+..\obj\gd32f10x_usart.o: ..\CMSIS\Include\core_cmFunc.h
+..\obj\gd32f10x_usart.o: ..\CMSIS\Include\system_gd32f10x.h
+..\obj\gd32f10x_usart.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\string.h
+..\obj\gd32f10x_usart.o: ..\CMSIS\Include\gd32f10x_libopt.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_fmc.h
+..\obj\gd32f10x_usart.o: ..\CMSIS\Include\gd32f10x.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_pmu.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_bkp.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_rcu.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_exti.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_gpio.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_crc.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_dma.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_dbg.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_adc.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_dac.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_fwdgt.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_wwdgt.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_rtc.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_timer.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_usart.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_i2c.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_spi.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_sdio.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_exmc.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_can.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_enet.h
+..\obj\gd32f10x_usart.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdlib.h
+..\obj\gd32f10x_usart.o: ..\LIB\Include\gd32f10x_misc.h

二進制
bootloader/OBJ/gd32f10x_wwdgt.crf


二進制
bootloader/OBJ/main.crf


+ 2 - 0
bootloader/OBJ/main.d

@@ -36,5 +36,7 @@
 ..\obj\main.o: ..\HW\Include\delay.h
 ..\obj\main.o: ..\HW\Include\fmc.h
 ..\obj\main.o: ..\HW\Include\ota_message.h
+..\obj\main.o: ..\HW\Include\usart.h
+..\obj\main.o: ..\HW\Include\ec800m.h
 ..\obj\main.o: ..\HW\Include\boot.h
 ..\obj\main.o: ..\HW\Include\w25q32.h

二進制
bootloader/OBJ/ota_message.crf


+ 3 - 0
bootloader/OBJ/ota_message.d

@@ -35,4 +35,7 @@
 ..\obj\ota_message.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdlib.h
 ..\obj\ota_message.o: ..\LIB\Include\gd32f10x_misc.h
 ..\obj\ota_message.o: ..\HW\Include\w25q32.h
+..\obj\ota_message.o: ..\HW\Include\ec800m.h
+..\obj\ota_message.o: ..\HW\Include\usart.h
+..\obj\ota_message.o: ..\HW\Include\delay.h
 ..\obj\ota_message.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdio.h

二進制
bootloader/OBJ/spi.crf


二進制
bootloader/OBJ/system_gd32f10x.crf


二進制
bootloader/OBJ/usart.crf


+ 35 - 0
bootloader/OBJ/usart.d

@@ -0,0 +1,35 @@
+..\obj\usart.o: ..\HW\Source\usart.c
+..\obj\usart.o: ..\HW\Include\usart.h
+..\obj\usart.o: ..\CMSIS\Include\gd32f10x.h
+..\obj\usart.o: ..\CMSIS\Include\core_cm3.h
+..\obj\usart.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdint.h
+..\obj\usart.o: ..\CMSIS\Include\core_cmInstr.h
+..\obj\usart.o: ..\CMSIS\Include\core_cmFunc.h
+..\obj\usart.o: ..\CMSIS\Include\system_gd32f10x.h
+..\obj\usart.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\string.h
+..\obj\usart.o: ..\CMSIS\Include\gd32f10x_libopt.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_fmc.h
+..\obj\usart.o: ..\CMSIS\Include\gd32f10x.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_pmu.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_bkp.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_rcu.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_exti.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_gpio.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_crc.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_dma.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_dbg.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_adc.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_dac.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_fwdgt.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_wwdgt.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_rtc.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_timer.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_usart.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_i2c.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_spi.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_sdio.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_exmc.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_can.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_enet.h
+..\obj\usart.o: D:\software\MDK5\ARM\ARMCC\Bin\..\include\stdlib.h
+..\obj\usart.o: ..\LIB\Include\gd32f10x_misc.h

二進制
bootloader/OBJ/w25q32.crf


+ 94 - 0
bootloader/USER/.vscode/c_cpp_properties.json

@@ -0,0 +1,94 @@
+{
+    "configurations": [
+        {
+            "name": "bootloader",
+            "includePath": [
+                "d:\\project\\dtu_gateway\\bootloader\\USER",
+                "d:\\project\\dtu_gateway\\bootloader\\CMSIS\\Include",
+                "d:\\project\\dtu_gateway\\bootloader\\HW\\Include",
+                "d:\\project\\dtu_gateway\\bootloader\\LIB\\Include",
+                "D:\\software\\MDK5\\ARM\\ARMCC\\include",
+                "D:\\software\\MDK5\\ARM\\ARMCC\\include\\rw",
+                "d:\\project\\dtu_gateway\\bootloader\\CMSIS\\Source",
+                "d:\\project\\dtu_gateway\\bootloader\\HW\\Source",
+                "d:\\project\\dtu_gateway\\bootloader\\LIB\\Source"
+            ],
+            "defines": [
+                "__CC_ARM",
+                "__arm__",
+                "__align(x)=",
+                "__ALIGNOF__(x)=",
+                "__alignof__(x)=",
+                "__asm(x)=",
+                "__forceinline=",
+                "__restrict=",
+                "__global_reg(n)=",
+                "__inline=",
+                "__int64=long long",
+                "__INTADDR__(expr)=0",
+                "__irq=",
+                "__packed=",
+                "__pure=",
+                "__smc(n)=",
+                "__svc(n)=",
+                "__svc_indirect(n)=",
+                "__svc_indirect_r7(n)=",
+                "__value_in_regs=",
+                "__weak=",
+                "__writeonly=",
+                "__declspec(x)=",
+                "__attribute__(x)=",
+                "__nonnull__(x)=",
+                "__register=",
+                "__breakpoint(x)=",
+                "__cdp(x,y,z)=",
+                "__clrex()=",
+                "__clz(x)=0U",
+                "__current_pc()=0U",
+                "__current_sp()=0U",
+                "__disable_fiq()=",
+                "__disable_irq()=",
+                "__dmb(x)=",
+                "__dsb(x)=",
+                "__enable_fiq()=",
+                "__enable_irq()=",
+                "__fabs(x)=0.0",
+                "__fabsf(x)=0.0f",
+                "__force_loads()=",
+                "__force_stores()=",
+                "__isb(x)=",
+                "__ldrex(x)=0U",
+                "__ldrexd(x)=0U",
+                "__ldrt(x)=0U",
+                "__memory_changed()=",
+                "__nop()=",
+                "__pld(...)=",
+                "__pli(...)=",
+                "__qadd(x,y)=0",
+                "__qdbl(x)=0",
+                "__qsub(x,y)=0",
+                "__rbit(x)=0U",
+                "__rev(x)=0U",
+                "__return_address()=0U",
+                "__ror(x,y)=0U",
+                "__schedule_barrier()=",
+                "__semihost(x,y)=0",
+                "__sev()=",
+                "__sqrt(x)=0.0",
+                "__sqrtf(x)=0.0f",
+                "__ssat(x,y)=0",
+                "__strex(x,y)=0U",
+                "__strexd(x,y)=0",
+                "__strt(x,y)=",
+                "__swp(x,y)=0U",
+                "__usat(x,y)=0U",
+                "__wfe()=",
+                "__wfi()=",
+                "__yield()=",
+                "__vfp_status(x,y)=0"
+            ],
+            "intelliSenseMode": "${default}"
+        }
+    ],
+    "version": 4
+}

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

@@ -0,0 +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 - 0
bootloader/USER/.vscode/uv4.log

@@ -0,0 +1,48 @@
+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 - 0
bootloader/USER/.vscode/uv4.log.lock

@@ -0,0 +1 @@
+2023/11/2 10:30:53

File diff suppressed because it is too large
+ 2245 - 3540
bootloader/USER/JLinkLog.txt


File diff suppressed because it is too large
+ 734 - 282
bootloader/USER/Listings/bootloader.map


File diff suppressed because it is too large
+ 91 - 100
bootloader/USER/bootloader.uvguix.IBM


+ 124 - 80
bootloader/USER/bootloader.uvoptx

@@ -153,93 +153,77 @@
           <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>16</LineNumber>
-          <EnabledFlag>1</EnabledFlag>
-          <Address>134220868</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\16</Expression>
-        </Bp>
-        <Bp>
-          <Number>1</Number>
-          <Type>0</Type>
-          <LineNumber>42</LineNumber>
-          <EnabledFlag>1</EnabledFlag>
-          <Address>134220824</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\42</Expression>
-        </Bp>
-        <Bp>
-          <Number>2</Number>
-          <Type>0</Type>
-          <LineNumber>41</LineNumber>
-          <EnabledFlag>1</EnabledFlag>
-          <Address>134220766</Address>
-          <ByteObject>0</ByteObject>
-          <HtxType>0</HtxType>
-          <ManyObjects>0</ManyObjects>
-          <SizeOfObject>0</SizeOfObject>
-          <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\HW\Source\ota_message.c</Filename>
-          <ExecCommand></ExecCommand>
-          <Expression>\\bootloader\../HW/Source/ota_message.c\41</Expression>
-        </Bp>
-        <Bp>
-          <Number>3</Number>
-          <Type>0</Type>
-          <LineNumber>37</LineNumber>
-          <EnabledFlag>1</EnabledFlag>
-          <Address>134219054</Address>
-          <ByteObject>0</ByteObject>
-          <HtxType>0</HtxType>
-          <ManyObjects>0</ManyObjects>
-          <SizeOfObject>0</SizeOfObject>
-          <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\HW\Source\fmc.c</Filename>
-          <ExecCommand></ExecCommand>
-          <Expression>\\bootloader\../HW/Source/fmc.c\37</Expression>
-        </Bp>
-      </Breakpoint>
+      <Breakpoint/>
+      <WatchWindow1>
+        <Ww>
+          <count>0</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>ota_data</ItemText>
+        </Ww>
+        <Ww>
+          <count>1</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>UART0_RX_BUF</ItemText>
+        </Ww>
+        <Ww>
+          <count>2</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>x</ItemText>
+        </Ww>
+        <Ww>
+          <count>3</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>app_programmer</ItemText>
+        </Ww>
+        <Ww>
+          <count>4</count>
+          <WinNumber>1</WinNumber>
+          <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>
+        <Ww>
+          <count>0</count>
+          <WinNumber>2</WinNumber>
+          <ItemText>ota_message</ItemText>
+        </Ww>
+      </WatchWindow2>
       <MemoryWindow1>
         <Mm>
           <WinNumber>1</WinNumber>
-          <SubType>0</SubType>
-          <ItemText>0x08069000</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>0x08005000</ItemText>
+          <SubType>8</SubType>
+          <ItemText>app_programmer</ItemText>
           <AccSizeX>0</AccSizeX>
         </Mm>
       </MemoryWindow2>
       <MemoryWindow3>
         <Mm>
           <WinNumber>3</WinNumber>
-          <SubType>0</SubType>
-          <ItemText>0x8037000</ItemText>
+          <SubType>8</SubType>
+          <ItemText>0x8005000</ItemText>
           <AccSizeX>0</AccSizeX>
         </Mm>
       </MemoryWindow3>
@@ -410,6 +394,30 @@
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
+    <File>
+      <GroupNumber>2</GroupNumber>
+      <FileNumber>10</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\HW\Source\ec800m.c</PathWithFileName>
+      <FilenameWithoutPath>ec800m.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>2</GroupNumber>
+      <FileNumber>11</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\HW\Source\usart.c</PathWithFileName>
+      <FilenameWithoutPath>usart.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
   </Group>
 
   <Group>
@@ -420,7 +428,7 @@
     <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>10</FileNumber>
+      <FileNumber>12</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -432,7 +440,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>11</FileNumber>
+      <FileNumber>13</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -444,7 +452,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>12</FileNumber>
+      <FileNumber>14</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -456,7 +464,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>13</FileNumber>
+      <FileNumber>15</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -468,7 +476,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>14</FileNumber>
+      <FileNumber>16</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -480,7 +488,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>15</FileNumber>
+      <FileNumber>17</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -492,7 +500,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>16</FileNumber>
+      <FileNumber>18</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -502,6 +510,42 @@
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
+    <File>
+      <GroupNumber>3</GroupNumber>
+      <FileNumber>19</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\LIB\Source\gd32f10x_dma.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f10x_dma.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>3</GroupNumber>
+      <FileNumber>20</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\LIB\Source\gd32f10x_exti.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f10x_exti.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>3</GroupNumber>
+      <FileNumber>21</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\LIB\Source\gd32f10x_usart.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f10x_usart.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
   </Group>
 
   <Group>
@@ -512,7 +556,7 @@
     <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>4</GroupNumber>
-      <FileNumber>17</FileNumber>
+      <FileNumber>22</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>

+ 25 - 0
bootloader/USER/bootloader.uvprojx

@@ -433,6 +433,16 @@
               <FileType>1</FileType>
               <FilePath>..\HW\Source\ota_message.c</FilePath>
             </File>
+            <File>
+              <FileName>ec800m.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\HW\Source\ec800m.c</FilePath>
+            </File>
+            <File>
+              <FileName>usart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\HW\Source\usart.c</FilePath>
+            </File>
           </Files>
         </Group>
         <Group>
@@ -473,6 +483,21 @@
               <FileType>1</FileType>
               <FilePath>..\LIB\Source\gd32f10x_fwdgt.c</FilePath>
             </File>
+            <File>
+              <FileName>gd32f10x_dma.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\LIB\Source\gd32f10x_dma.c</FilePath>
+            </File>
+            <File>
+              <FileName>gd32f10x_exti.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\LIB\Source\gd32f10x_exti.c</FilePath>
+            </File>
+            <File>
+              <FileName>gd32f10x_usart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\LIB\Source\gd32f10x_usart.c</FilePath>
+            </File>
           </Files>
         </Group>
         <Group>

+ 55 - 27
bootloader/USER/main.c

@@ -3,43 +3,71 @@
 #include "delay.h"
 #include "fmc.h"
 #include "ota_message.h"
-
+#include "usart.h"
+#include "ec800m.h"
 #include "boot.h"
 #include "w25q32.h"
 void task_fwdgt_reload(void);
 OTA_STRUCT UpDataA;           //A区更新用到的结构体
 
-void my_test(void)
-{
-	static OTA_MESSAGE ota_message = {0};
-	uint32_t i = 0;
-	ota_message.otaflag = 1;
-	ota_message.XmodemByte = 200 * 1024;
-	//往地址0x08070000写OTA_MESSAGE结构体
-	// GD32_WriteFlash(OTA_EVENT_START_ADDR,&ota_message,sizeof(OTA_MESSAGE));
-	fmc_state_enum state;
-	// state = fmc_word_program((uint32_t)0x08070000,(uint32_t)(1));
-	// fmc_flag_clear(FMC_FLAG_BANK0_END | FMC_FLAG_BANK0_WPERR | FMC_FLAG_BANK0_PGERR);
-	// state = fmc_word_program((uint32_t)0x08070004,(uint32_t)(100 * 1024));
-	// fmc_flag_clear(FMC_FLAG_BANK0_END | FMC_FLAG_BANK0_WPERR | FMC_FLAG_BANK0_PGERR);
-	// FLASH_WriteNotErase(0x08070000,&ota_message,sizeof(OTA_MESSAGE)/2);
-	// FLASH_ErasePage(0x08069000,1);
-	GD32_EraseFlash(210,1);
-	FLASH_Write(0x08069000,&ota_message,sizeof(OTA_MESSAGE)/2);
-	i = *(uint32_t*)(0x08069000);
-	i = *(uint32_t*)(0x08069004);
-	// FLASH_Write(0x08069008,&ota_message,sizeof(OTA_MESSAGE)/2);
-	
-	Delay_Ms(100);
-}
+#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(WRITEFILE,strlen(WRITEFILE));
+ 	memset(str,0,sizeof(str));
+ 	strcpy(str,(char *)&UART0_RX_BUF);
+ 	i = WaitResponse("CONNECT", 2000);
+
+ 	EC800MSendCmd((uint8_t *)&ota_message,8);
+ 	memset(str,0,sizeof(str));
+ 	strcpy(str,(char *)&UART0_RX_BUF);
+ 	i = WaitResponse("QFWRITE", 2000);
+
+ 	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_Init();	//弃用w25q32改用fmc存储
+	Delay_Init();
+	/* 弃用w25q32改用EC800存储ota文件 */
+	// W25Q32_Init();
+	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分支

+ 7 - 17
bootloader/USER/main.h

@@ -2,24 +2,14 @@
 #define MAIN_H
 
 #include "stdint.h"
-/*
-flash分区设计:
-0x08000000~0x08004FFF   bootleader;20KB=10页
-0x08005000~0x08036FFF   app;200KB=100页
-0x08037000~0x08068FFF	download;200KB=100页
-0x08069000~0x080707FF	OTA_EVENT_BLOCK;2KB=1页
-0x08070800~0x0807FFFF	剩余内存;62KB=31页
-0x08080000~0x082FFFFF   剩余内存;2.5MB=640页
-*/
+
 #define  GD32_FLASH_SADDR   0x08000000                                             //FLASH起始地址
-#define  GD32_PAGE_SIZE     2048                                                   //FLASH扇区大小
-#define  GD32_PAGE_NUM      256                                                   //FLASH总扇区个数
-#define  GD32_B_PAGE_NUM    10                                                     //B区扇区个数
-#define  GD32_A_PAGE_NUM    100                        							   //A区扇区个数
-#define  GD32_D_PAGE_NUM    100                        							   //D区扇区个数
-#define  GD32_A_START_PAGE  GD32_B_PAGE_NUM                                        //APP区起始扇区编号
-#define  GD32_A_SADDR       GD32_FLASH_SADDR + GD32_A_START_PAGE * GD32_PAGE_SIZE  //A区起始地址
-#define  GD32_D_SADDR       GD32_FLASH_SADDR + (GD32_A_START_PAGE + GD32_A_PAGE_NUM) * GD32_PAGE_SIZE  //D区起始地址
+#define  GD32_PAGE_SIZE     1024                                                   //FLASH扇区大小
+#define  GD32_PAGE_NUM      1024                                                     //FLASH总扇区个数
+#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区起始地址0x08005000
 
 
 #define OTA_INFOCB_SIZE sizeof(OTA_InfoCB)    //OTA相关的信息结构体占用的字节长度