Files
DCU_APP/GD32E508_DCU_APP/shared/ota_layout.h
T
cbb 5fd986299c feat(comm): 1.6.51 CAN 空通道自动静默 + PDO 诊断 + OTA 布局共用头
变更点:
1. CAN-FD(device/CANFD.cpp、sys/config.h)
   - 发送统一 FD+BRS(DLC≤8 不再回退经典 CAN);OTA 期仍按通道压制 BRS
   - 空通道自动识别:连续 5 个 1Hz 窗口无有效帧且有错误 → 静默上报;有帧即恢复
   - 三路 CAN 默认全开;RX parse budget 48→64
2. EtherCAT 桥 / PDO
   - 段1 增 txtxid/rx00ff;版本应答 0x00FF 粘滞发布,避免被 CONFIG 冲掉
   - STATUS 禁止写入 xrx 快照;processSeq 新鲜度救援
3. OTA / 配置
   - sys/config.h include 仓库内 shared/ota_layout.h(与 BOOT 共用,不再依赖仓外路径)
   - ota_boot_request 对齐配置页 word 布局
4. docs/audit_ecat_spi_wifi_ota_compatibility.md:ECAT/SPI/WiFi/OTA 兼容性审计
5. .gitignore:忽略 .trae/、docs/traework-import、评审过程稿
2026-09-20 22:58:09 +08:00

60 lines
3.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file ota_layout.h
* @brief APP/BOOT 共用 OTA Flash 布局(唯一真源)。
* @note 两侧 sys/config.h 都必须 include 本头,禁止再抄地址常量。
* 相对路径:BOOT/APP 的 sys/config.h → ../../../shared/ota_layout.h
*
* 约定:0x00000000=AVAL(有效),0xFFFFFFFF=NOT_AVAL(擦除态/无效)。
*/
#ifndef SHARED_OTA_LAYOUT_H
#define SHARED_OTA_LAYOUT_H
#include <stdint.h>
/* ---- 整片 Flash 区段(GD32E508VE 512KB) ---- */
#define OTA_LAYOUT_BOOT_START 0x08000000U
#define OTA_LAYOUT_BOOT_SIZE 0x00012000U /* 72KB */
#define OTA_LAYOUT_APP_BACK_START 0x08012000U /* 216KB 备份区 */
#define OTA_LAYOUT_APP_MAIN_START 0x08048000U /* 216KB 主应用区 = APP VTOR */
#define OTA_LAYOUT_APP_MAX_SIZE 0x00035FFCU /* 216KB-4B,末尾 CRC32 */
#define OTA_LAYOUT_CONFIG_PAGE 0x0807E000U /* OTA 状态配置页 2KB */
#define OTA_LAYOUT_SLEEP_PAGE 0x0807E800U /* 睡眠配置页 2KB */
#define OTA_LAYOUT_PAGE_SIZE 0x00000800U /* FMC 单页 2KB */
/* ---- OTA 配置页 word 布局(word N = PAGE + 4*N) ---- */
#define OTA_LAYOUT_WORD_LATEST_AVAL 0U
#define OTA_LAYOUT_WORD_BACKUP_AVAL 1U
#define OTA_LAYOUT_WORD_LATEST_EN 2U
#define OTA_LAYOUT_WORD_BACKUP_EN 3U
#define OTA_LAYOUT_WORD_LATEST_CHECK 4U
#define OTA_LAYOUT_WORD_BACKUP_CHECK 5U
#define OTA_LAYOUT_WORD_BOOT_VER0 6U /* major|minor */
#define OTA_LAYOUT_WORD_BOOT_VER1 7U /* patch|build */
#define OTA_LAYOUT_WORD_ECAT_ARM 8U /* 0xACA70001 才允许 ECAT SDO 刷 APP */
#define OTA_LAYOUT_WORD_CRASH_COUNT 9U /* 连续 FWDGT 崩溃次数;APP 起板成功清 0 */
#define OTA_LAYOUT_ADDR_LATEST_AVAL (OTA_LAYOUT_CONFIG_PAGE + 4U * OTA_LAYOUT_WORD_LATEST_AVAL)
#define OTA_LAYOUT_ADDR_BACKUP_AVAL (OTA_LAYOUT_CONFIG_PAGE + 4U * OTA_LAYOUT_WORD_BACKUP_AVAL)
#define OTA_LAYOUT_ADDR_LATEST_EN (OTA_LAYOUT_CONFIG_PAGE + 4U * OTA_LAYOUT_WORD_LATEST_EN)
#define OTA_LAYOUT_ADDR_BACKUP_EN (OTA_LAYOUT_CONFIG_PAGE + 4U * OTA_LAYOUT_WORD_BACKUP_EN)
#define OTA_LAYOUT_ADDR_LATEST_CHECK (OTA_LAYOUT_CONFIG_PAGE + 4U * OTA_LAYOUT_WORD_LATEST_CHECK)
#define OTA_LAYOUT_ADDR_BACKUP_CHECK (OTA_LAYOUT_CONFIG_PAGE + 4U * OTA_LAYOUT_WORD_BACKUP_CHECK)
#define OTA_LAYOUT_ADDR_BOOT_VER0 (OTA_LAYOUT_CONFIG_PAGE + 4U * OTA_LAYOUT_WORD_BOOT_VER0)
#define OTA_LAYOUT_ADDR_BOOT_VER1 (OTA_LAYOUT_CONFIG_PAGE + 4U * OTA_LAYOUT_WORD_BOOT_VER1)
#define OTA_LAYOUT_ADDR_ECAT_ARM (OTA_LAYOUT_CONFIG_PAGE + 4U * OTA_LAYOUT_WORD_ECAT_ARM)
#define OTA_LAYOUT_ADDR_CRASH_COUNT (OTA_LAYOUT_CONFIG_PAGE + 4U * OTA_LAYOUT_WORD_CRASH_COUNT)
/** 配置页有效 word 数(擦页回写必须覆盖到此);页 2KB,余量充足。 */
#define OTA_LAYOUT_WORD_COUNT 10U
/** ECAT 下载 arm 令牌。避开擦除态与 AVAL。 */
#define OTA_LAYOUT_ECAT_ARM_KEY 0xACA70001U
/** 连续 FWDGT 达到该次数后 BOOT 停止自动跳 APP,只接受外部灌写。 */
#define OTA_LAYOUT_CRASH_STAY_MAX 3U
#define OTA_LAYOUT_AVAL 0x00000000U
#define OTA_LAYOUT_NOT_AVAL 0xFFFFFFFFU
#endif /* SHARED_OTA_LAYOUT_H */