feat(core): OTA可用版本,添加看门狗功能并优化系统初始化日志

- 添加watchdog组件用于系统监控
- 在system_gd32e50x.c中增加USART0诊断输出,在IRC8M和PLL配置后
  发送"APP"和"CLK"标识
- 优化AppSpiCommand类中的日志处理机制,使用临界区保护
- 添加对全0xFF数据包的过滤处理,避免无效命令处理
- 将OTA重启延时从滴答计数改为毫秒级延时,提高响应速度
- 移除温度传感器相关文件,添加看门狗相关文件到项目配置
- 更新FWDGT API调用方式,使用新的配置函数
- 增加详细的启动日志输出,便于调试和追踪初始化过程
This commit is contained in:
cbb
2026-05-30 20:03:31 +08:00
parent f63114f5fd
commit 771d34398f
11 changed files with 555 additions and 19 deletions
+10
View File
@@ -25,14 +25,24 @@
*/
void AppInitializer::init()
{
printf("[APP] init: SysTick...\r\n");
SysTickTimer::initMs();
printf("[APP] init: USART0...\r\n");
Usart0::configurePins();
Usart0::init();
printf("[APP] init: TempSensor...\r\n");
TempSensor::init();
printf("[APP] init: CANFD...\r\n");
CanFd::init();
printf("[APP] init: OtaBootRequest...\r\n");
OtaBootRequest::init();
printf("[APP] init: AppSpiCommand...\r\n");
AppSpiCommand::init();
printf("[APP] init: TaskManager...\r\n");
TaskManager::init();
printf("[APP] init: SchedulerTimer...\r\n");
SchedulerTimer::init();
printf("[APP] init: Watchdog...\r\n");
Watchdog::init();
printf("[APP] init: all done\r\n");
}
+7 -11
View File
@@ -18,7 +18,7 @@ constexpr uint32_t kAppLatestCheckAddr = kOtaConfigPageAddr + 0x10U;
constexpr uint32_t kOtaAval = 0x00000000U;
constexpr uint32_t kOtaNotAval = 0xFFFFFFFFU;
constexpr uint32_t kFmcPageSize = 0x00000800U;
constexpr uint32_t kRebootDelayTicks = 2U;
constexpr uint32_t kRebootDelayMs = 20U;
static bool writeWord(uint32_t addr, uint32_t value)
{
@@ -89,8 +89,6 @@ static bool requestMagicValid(const uint8_t *data, uint8_t length)
/** @brief 已写入 OTA 标志并等待软复位的挂起标志。 */
volatile bool OtaBootRequest::s_rebootPending = false;
/** @brief 复位前的调度延迟计数,给 SPI/CAN 应答留出发送时间。 */
uint32_t OtaBootRequest::s_rebootCountdown = 0U;
/**
* @brief 初始化进入 Bootloader 请求模块的运行态。
@@ -98,7 +96,6 @@ uint32_t OtaBootRequest::s_rebootCountdown = 0U;
void OtaBootRequest::init()
{
s_rebootPending = false;
s_rebootCountdown = 0U;
}
/**
@@ -115,7 +112,6 @@ bool OtaBootRequest::requestEnterBoot()
}
if(ok) {
s_rebootCountdown = kRebootDelayTicks;
s_rebootPending = true;
}
return ok;
@@ -142,8 +138,11 @@ bool OtaBootRequest::handleCanFrame(uint8_t channel, uint32_t id, const uint8_t
}
/**
* @brief 在主循环任务中执行延迟软复位。
* @brief 在主循环任务中执行短延迟软复位。
* @note 不在 SPI/CAN 中断里直接复位,避免应答还没发出就重启。
* 这里使用毫秒级短延时,而不是 1s 心跳计数;否则一次 SPI 请求
* 实际会拖到 2~3 秒后才复位,ESP32 第二次 OTA 时很容易在 APP 还没
* 真正重启进入 BOOT 之前就发出 HANDSHAKE_REQ。
*/
void OtaBootRequest::process()
{
@@ -151,11 +150,8 @@ void OtaBootRequest::process()
return;
}
if(s_rebootCountdown > 0U) {
--s_rebootCountdown;
return;
}
s_rebootPending = false;
SysTickTimer::delayMs(kRebootDelayMs);
__disable_irq();
NVIC_SystemReset();
while(1) {
-1
View File
@@ -36,7 +36,6 @@ public:
private:
static volatile bool s_rebootPending;
static uint32_t s_rebootCountdown;
};
#endif /* SYS_OTA_BOOT_REQUEST_H */