feat(Puya-PY32F040): add OTA dual-project codegen template

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-18 18:56:19 +08:00
co-authored by Cursor
commit 62eb0199ed
498 changed files with 329164 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
#ifndef __FLASH_H
#define __FLASH_H
#include "boot_main.h"
#include "ota_config.h"
/* ════════════════════════════════════════════════════════════════
* Flash 布局与 OTA 状态机 — 统一由 ota_config.h 配置(唯一入口)
* (布局宏 OTA_RUN_ADDR_BASE / OTA_BAK_ADDR_BASE / OTA_SLOT_MAX_SIZE
* 及状态结构 ota_param_t / OTA_STATE_* 均在 ota_config.h 中定义)
* ════════════════════════════════════════════════════════════════ */
#define SYS_BOOTLOADER_ADDR_BASE 0x08000000UL /* Bootloader17KB */
#define FLASH_END_ADDR 0x08020000UL /* 128KB 边界 */
#define RAM_BASE_ADDR 0x20000000UL
#define RAM_END_ADDR 0x20004000UL /* 16KB RAM */
/* ════════════════════════════════════════════════════════════════
* Flash 操作 API
* ════════════════════════════════════════════════════════════════ */
void APP_FlashWrite(uint32_t PageAddress, uint8_t *Data, uint32_t DataSize);
void APP_FlashRead(uint32_t PageAddress, uint8_t *Data, uint32_t DataSize);
void APP_FlashEraseWithCheck(uint32_t PageAddress, uint32_t DataSize);
/* OTA 状态区读写(AB:4 页轮换磨损均衡;SINGLE:固定页 0 直写) */
void ota_param_load(ota_param_t *p);
void ota_param_store(const ota_param_t *p);
#endif