fix: harden demo lifecycle, BSP rollback, and flash layout
This commit is contained in:
1 parent
7b85c4a129
commit
0b6aed856a
42 files changed
+1079
-351
No files matched your search
@@ -7,10 +7,10 @@
|
||||
Use ESP-IDF 5.5.3. On a clean machine or when the toolchain is missing, follow
|
||||
the [environment bootstrap](environment-setup.md) first.
|
||||
|
||||
> Prefer `./tools/validate.sh --firmware` for firmware builds and flash its
|
||||
> verified `build/FoloToy-AI-Passport-full.bin` at offset `0x0` only when the
|
||||
> target is blank or the merged byte range ends before protected `cardid`.
|
||||
> On a provisioned device, use segmented `idf.py flash`. Treat
|
||||
> Prefer `./tools/validate.sh --firmware` for firmware builds. Flash its
|
||||
> verified `build/FoloToy-AI-Passport-full.bin` at offset `0x0` for a blank
|
||||
> device or an intentional complete refresh. The merged image may reset NVS;
|
||||
> use segmented `idf.py flash` when existing NVS state must be preserved. Treat
|
||||
> `idf.py build` and `idf.py flash` as incremental development commands, not the
|
||||
> default delivery path.
|
||||
|
||||
@@ -31,7 +31,7 @@ regenerated.
|
||||
|
||||
The tracked `dependencies.lock` pins Managed Component resolution. After changing an `idf_component.yml`, regenerate the lock with ESP-IDF 5.5.3, review version changes, and commit it with the manifest. An ordinary build must not leave an unexplained lock-file diff.
|
||||
|
||||
Firmware validation uses a fresh temporary build directory and an isolated `sdkconfig` generated from the tracked defaults. It does not consume or overwrite a developer's root `sdkconfig`, and it copies only the verified merged image to `build/FoloToy-AI-Passport-full.bin`. The gate also enforces the [protected Flash layout](protected-flash-layout.md): the protected `cardid` address, application size, partition-table MD5, and absence of device-specific identity data.
|
||||
Firmware validation uses a fresh temporary build directory and an isolated `sdkconfig` generated from the tracked defaults. It does not consume or overwrite a developer's root `sdkconfig`, and it copies only the verified merged image to `build/FoloToy-AI-Passport-full.bin`. The gate also validates the [configured firmware layout](firmware-layout.md): image offsets from `flash_args`, partition-table MD5, bounds and non-overlap, and an application that starts in and fits its configured app partition. User-defined partition layouts are allowed.
|
||||
|
||||
The baseline also has a hardware-independent logic test:
|
||||
|
||||
@@ -46,7 +46,7 @@ Use the unified validation entry point:
|
||||
|
||||
```bash
|
||||
./tools/validate.sh --static # repository checks, workflows, links, secrets, host tests
|
||||
./tools/validate.sh --firmware # build, merge-bin, offsets, and protected layout
|
||||
./tools/validate.sh --firmware # build, merge-bin, offsets, and configured layout
|
||||
./tools/validate.sh # complete gate; requires an activated ESP-IDF environment
|
||||
```
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
使用 ESP-IDF 5.5.3。全新机器或缺少工具链时,先按
|
||||
[环境引导](environment-setup.zh_CN.md)完成安装。
|
||||
|
||||
> 固件编译优先运行 `./tools/validate.sh --firmware`,烧录优先把验证通过的
|
||||
> `build/FoloToy-AI-Passport-full.bin` 写入空白设备;对已有身份的设备,只有合并文件
|
||||
> 在保护区 `cardid` 之前结束时才可从 `0x0` 直刷,其余情况使用分段
|
||||
> `idf.py flash`。`idf.py build` 和
|
||||
> 固件编译优先运行 `./tools/validate.sh --firmware`。空白设备初始化或有意完整
|
||||
> 刷新时,把验证通过的 `build/FoloToy-AI-Passport-full.bin` 从 `0x0` 写入;
|
||||
> 合并镜像可能重置 NVS,需要保留已有 NVS 状态时使用分段 `idf.py flash`。
|
||||
> `idf.py build` 和
|
||||
> `idf.py flash` 只作为增量开发命令,不作为默认交付方式。
|
||||
|
||||
```bash
|
||||
@@ -29,7 +29,7 @@ target 或已跟踪 defaults 时,先保留有意的本地设置,再运行
|
||||
|
||||
仓库提交 `dependencies.lock` 以固定 ESP-IDF Managed Components 的解析结果。修改 `idf_component.yml` 后必须使用 ESP-IDF 5.5.3 重新生成锁文件、review 版本变化并与 manifest 一起提交;普通构建不应产生未提交的锁文件差异。
|
||||
|
||||
固件门禁使用全新的临时构建目录,并从仓库 `sdkconfig.defaults` 生成隔离的 `sdkconfig`。它不会读取或覆盖开发者根目录的 `sdkconfig`,只把验证通过的合并镜像复制到 `build/FoloToy-AI-Passport-full.bin`。门禁同时强制检查[受保护的 Flash 布局](protected-flash-layout.zh_CN.md):受保护的 `cardid` 地址、应用大小、分区表 MD5 以及单机身份数据不入包。
|
||||
固件门禁使用全新的临时构建目录,并从仓库 `sdkconfig.defaults` 生成隔离的 `sdkconfig`。它不会读取或覆盖开发者根目录的 `sdkconfig`,只把验证通过的合并镜像复制到 `build/FoloToy-AI-Passport-full.bin`。门禁同时验证[当前配置的固件布局](firmware-layout.zh_CN.md):从 `flash_args` 读取镜像偏移,检查分区表 MD5、边界和不重叠,并确认应用从所配置的 app 分区起点开始且未超出分区。允许用户自定义分区布局。
|
||||
|
||||
当前基线含一个可独立运行的纯逻辑测试:
|
||||
|
||||
@@ -44,7 +44,7 @@ cc -std=c11 -Wall -Wextra -Werror -Imain \
|
||||
|
||||
```bash
|
||||
./tools/validate.sh --static # 仓库一致性、workflow、文档链接、敏感信息、host tests
|
||||
./tools/validate.sh --firmware # ESP-IDF build、merge-bin、偏移与保护布局校验
|
||||
./tools/validate.sh --firmware # ESP-IDF build、merge-bin、偏移与当前布局校验
|
||||
./tools/validate.sh # 完整验证
|
||||
```
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<p align="right">
|
||||
<a href="firmware-layout.zh_CN.md">简体中文</a> · <strong>English</strong>
|
||||
</p>
|
||||
|
||||
# Firmware Layout
|
||||
|
||||
This repository is a minimal base for user-defined firmware targeting an
|
||||
ESP32-C3 with 8 MB Flash. Its default does not reserve product-specific
|
||||
identity, OTA, or unused data partitions.
|
||||
|
||||
## Default layout
|
||||
|
||||
The default partition table contains exactly:
|
||||
|
||||
| Partition | Type/subtype | Offset | Size | Purpose |
|
||||
| --- | --- | ---: | ---: | --- |
|
||||
| `nvs` | data/NVS | `0x9000` | `0x6000` | ESP-IDF and application key-value storage |
|
||||
| `phy_init` | data/PHY | `0xF000` | `0x1000` | PHY initialization data |
|
||||
| `factory` | app/factory | `0x10000` | `0x7F0000` | The single application image; all remaining Flash |
|
||||
|
||||
The default has no OTA slots. This is a starting point, not a restriction on
|
||||
user firmware.
|
||||
|
||||
## Custom layouts
|
||||
|
||||
Users may edit `partitions.csv` to resize, move, add, or remove partitions for
|
||||
their application. A custom table may use OTA slots, filesystem/resource
|
||||
partitions, or other application-specific data. Keep the 8 MB device boundary,
|
||||
avoid overlaps, and make sure the application image is flashed at the start of
|
||||
an app partition large enough to contain it. When a derivative changes its
|
||||
layout, update that project's documentation and flashing instructions.
|
||||
|
||||
## Enforced validation
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
./tools/validate.sh --firmware
|
||||
```
|
||||
|
||||
The check builds in an isolated directory, creates the merged image, reads the
|
||||
configured image offsets from `flash_args`, validates the partition-table MD5,
|
||||
partition bounds, unique labels, and non-overlap, then ensures the application
|
||||
offset matches an app partition large enough to contain it. It intentionally
|
||||
does not require the default partition list. CI runs the same gate.
|
||||
|
||||
Upload only `build/FoloToy-AI-Passport-full.bin`; the similarly named app-only
|
||||
`build/FoloToy-AI-Passport.bin` does not contain the bootloader or partition
|
||||
table.
|
||||
|
||||
## Flashing and stored data
|
||||
|
||||
The verified merged image is written from `0x0`. Because the merged file pads
|
||||
the gaps between images, flashing it can reset the NVS and PHY data regions.
|
||||
Use the merged image for blank-device provisioning or an intentional complete
|
||||
refresh. During normal development, use segmented `idf.py flash` when existing
|
||||
NVS state should be preserved. `idf.py erase-flash` erases all user data.
|
||||
Loaded 3 of 42 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user