From aca260ba5489b6b7428f4d8c0135ea98c7647619 Mon Sep 17 00:00:00 2001 From: YuanHongbin <975559679@qq.com> Date: Tue, 14 Jul 2026 17:25:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20boot=E5=8D=87=E7=BA=A7=E5=90=8E=E6=93=A6?= =?UTF-8?q?=E9=99=A4=E5=A4=96Flash=E9=98=B2=E5=8F=82=E6=95=B0=E5=81=8F?= =?UTF-8?q?=E7=A7=BB,=E4=BF=AE=E5=A4=8D8=E9=A1=B9Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增APP_BOOT_UPGRADE_FLAG标记,boot升级后APP启动时检测并擦除外部Flash避免参数偏移。修复: CatSendErrCnt清零、Mac索引、时间同步指针、HIS_DATA break、Ch2校准标志、RS485离线通知格式、LoraSetFreqCent参数。 --- Project/GateWay/source/User/Inc/Public.h | 2 -- Project/GateWay/source/User/Inc/bsp.h | 1 + Project/GateWay/source/User/Src/main.c | 9 +++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Project/GateWay/source/User/Inc/Public.h b/Project/GateWay/source/User/Inc/Public.h index c99a779..d2a1ae9 100644 --- a/Project/GateWay/source/User/Inc/Public.h +++ b/Project/GateWay/source/User/Inc/Public.h @@ -258,8 +258,6 @@ typedef struct { uint16_t LocalPort; //ؿͻ˶˿(Ԥ) }LTENetPara_t, *pLTENetPara; - - typedef struct { uint8_t IpMode; //IPģʽDHCP/̬ uint8_t IpAddr[4]; //IPַ diff --git a/Project/GateWay/source/User/Inc/bsp.h b/Project/GateWay/source/User/Inc/bsp.h index b44ea73..d64274c 100644 --- a/Project/GateWay/source/User/Inc/bsp.h +++ b/Project/GateWay/source/User/Inc/bsp.h @@ -53,6 +53,7 @@ #define APP_START_FLAG 0x55AA5A5A #define APP_UPDATE_FLAG 0xA5A5AA55 +#define APP_BOOT_UPGRADE_FLAG 0x5A5A55A5 #define WATCH_DOG 1 diff --git a/Project/GateWay/source/User/Src/main.c b/Project/GateWay/source/User/Src/main.c index 63c8252..0b95a18 100644 --- a/Project/GateWay/source/User/Src/main.c +++ b/Project/GateWay/source/User/Src/main.c @@ -129,6 +129,15 @@ void GateWayInit(void) Debug_Printf("FlashID: %08x\r\n", FlashID); memset((uint8_t *)&GateWay.ConfigPara, 0x00, sizeof(GWConfigPara_t)); + boot_para_t bootParam; + dev_boot_read_param(&bootParam); + if(bootParam.AppFlag == APP_BOOT_UPGRADE_FLAG) { + rt_kprintf("Boot upgrade detected, erasing external Flash...\r\n"); + SpiFlashEraseChip(); + bootParam.AppFlag = 0; + dev_boot_write_param(bootParam); + } + int ret = ReadPara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t)); if(GateWay.ConfigPara.SavFlag != LOG_SAV_FLAG) { memset((uint8_t *)&GateWay.ConfigPara, 0x00, sizeof(GWConfigPara_t));