From ec8d487264ac58ebaa00cf99675528e85c6113d0 Mon Sep 17 00:00:00 2001
From: WXK <287788329@qq.com>
Date: 星期三, 13 八月 2025 09:56:46 +0800
Subject: [PATCH] boot开发完成

---
 dualboots_Gai_youhua/keil/customboot/include/drivers/menu.c |   58 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/dualboots_Gai_youhua/keil/customboot/include/drivers/menu.c b/dualboots_Gai_youhua/keil/customboot/include/drivers/menu.c
index 56080d1..dfce966 100644
--- a/dualboots_Gai_youhua/keil/customboot/include/drivers/menu.c
+++ b/dualboots_Gai_youhua/keil/customboot/include/drivers/menu.c
@@ -8,7 +8,7 @@
 #include "HIDO_TypeDef.h"
 #include "mk_trace.h"
 //#include "stm32f4xx_hal.h"
-
+#include "mk_wdt.h"
 
 pFunction Jump_To_Application;
 uint32_t JumpAddress;
@@ -57,9 +57,11 @@
 
 	return 0;
 }
-
+extern volatile unsigned long  time_100ms;
+extern volatile unsigned long start_timer;
 uint8_t FileName[FILE_NAME_LENGTH];
-	
+uint8_t gongkaflag,shouhuanflag;
+extern int32_t Receive_Byte (uint8_t *c, uint32_t timeout);
 /**
   * @brief  Download a file via serial port
   * @param  None
@@ -67,9 +69,37 @@
   */
 unsigned char SerialDownload(void)
 {
-  uint8_t Number[10] = {0};
-  int32_t Size = 0;
-	Send_Byte(0x33);
+    uint8_t Number[10] = {0};
+    int32_t Size = 0;
+    uint8_t c;
+//    wdt_ping(WDT_ID0);//喂狗
+//    uart1_xuanze(0);
+    Send_Byte(0x33);
+//    start_timer=time_100ms;
+//    while(time_100ms<start_timer+5)
+//    {
+//         if (Receive_Byte(&c, 0x100000) == 0)//返回0成功收取数据,-1为没收到数据
+//          { 
+//              gongkaflag=1;
+//              break;
+//          }
+//    }
+//    if(gongkaflag==0)
+//    {
+//    wdt_ping(WDT_ID0);//喂狗
+//    uart1_xuanze(1);
+//    Send_Byte(0x33);
+//    start_timer=time_100ms;
+//    while(time_100ms<start_timer+5)
+//    {
+//         if (Receive_Byte(&c, 0x100000) == 0)//返回0成功收取数据,-1为没收到数据
+//          { 
+//              shouhuanflag=1;
+//              break;
+//          }
+//    }
+//    }
+//  NVIC_SystemReset();
   Size = Ymodem_Receive(&tab_1024[0]);//开始接收文件,成功会返回文件的大小
   if (Size > 0)  //返回成功
   {
@@ -173,17 +203,19 @@
 				flash_write_nbytes(FLASH_ID0,APP_CONFIG_IAPFLAG_MAP,(uint8_t*)&tmp,2);
 //            SPIFlash_Erase(SPI_FLASH_ID_0, APP_CONFIG_IAPFLAG_MAP,2, SPI_FLASH_SECTOR_ERASE_MODE_4K);  MK8000修改
 //            SPIFlash_Write(SPI_FLASH_ID_0, APP_CONFIG_IAPFLAG_MAP, (HIDO_UINT8*)&tmp, sizeof(tmp)); 
-    
+                        delay_ms(100);
+										//LOG_INFO(TRACE_MODULE_APP,"升级失败重启\r\n\n");
+										NVIC_SystemReset();
 //			  if (((*(__IO uint32_t*)APP_CONFIG_APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)先注释掉即一成功就跳转
 //				{ 
 					/* Jump to user application */
 					//Serial0PutString("跳转APP\r\n");
-					memcpy((void *)SRAM_BASE, (void *)APP_CONFIG_APPLICATION_ADDRESS, APP_CONFIG_APPLICATION_SIZE);
-				 // setup new msp
-					__set_MSP(*(uint32_t *)SRAM_BASE);
-					//Serial0PutString("跳转APP后\r\n");
-					typedef void (*p_entry_t)(void);
-					((p_entry_t) (*(uint32_t *)(SRAM_BASE + 4) + SRAM_BASE))();
+//					memcpy((void *)SRAM_BASE, (void *)APP_CONFIG_APPLICATION_ADDRESS, APP_CONFIG_APPLICATION_SIZE);
+//				 // setup new msp
+//					__set_MSP(*(uint32_t *)SRAM_BASE);
+//					//Serial0PutString("跳转APP后\r\n");
+//					typedef void (*p_entry_t)(void);
+//					((p_entry_t) (*(uint32_t *)(SRAM_BASE + 4) + SRAM_BASE))();
 					
 				//JumpAddress = *(__IO uint32_t*) (SRAM_BASE + 4);
 				

--
Gitblit v1.9.3