Files
ai-passport/docs/development/engineering/firmware-layout.md
T

2.3 KiB

简体中文 · English

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:

./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.