Files
ai-passport/docs/development/engineering/build-and-test.md
T
Shinku cbede2d2fa docs: reorganize reference area and unify directory READMEs
Reorganize the AI-agent documentation by function area:
- Move the plays/ application archive and experiences into docs/reference/, grouped by contributor <username>/ (flat experience entries + application subdirectories), with a single reference/README entry.
- Add a second level under docs/development/ (engineering/, ci/, release/); fold agent-guide into ai-guide; flatten the six project-completion sub-documents into one file.
- Unify each directory to a single README (drop every INDEX); fold assets/{fonts,images,music} README leaves into assets/README; remove the empty docs/software-design/.
- Add an upstream-PR rule: do not add or modify the repository-root README.
- Update all cross-references and bibliographic links (EN/ZH aligned); validate.sh --static passes. The repository-root README is left untouched.
2026-08-31 15:05:42 +08:00

3.1 KiB

简体中文 · English

Build and Test

Use ESP-IDF 5.5.3. On a clean machine or when the toolchain is missing, follow the environment bootstrap 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, prefer mini-program install or segmented idf.py flash. Treat idf.py build and idf.py flash as incremental development commands, not the default delivery path.

source <path-to-esp-idf-v5.5.3>/export.sh
idf.py --version             # must report ESP-IDF v5.5.3
./tools/validate.sh --firmware # preferred: build and verify merged 0x0 image
idf.py set-target esp32c3     # fresh checkout or changed target
idf.py build                  # optional incremental application build
idf.py flash monitor          # optional incremental application flash
idf.py fullclean              # remove stale generated build state only

idf.py fullclean does not fully synchronize an existing sdkconfig with changed defaults. Preserve intentional local settings, then run idf.py set-target esp32c3 when the target or tracked defaults must be 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 mini-program BLE compatibility contract: protected partition addresses, application size, partition-table MD5, absence of protected payload data, and the Recovery bootloader hook.

The baseline also has a hardware-independent logic test:

cc -std=c11 -Wall -Wextra -Werror -Imain \
  tests/test_ui_pixel_math.c main/ui_pixel_math.c \
  -o /tmp/test_ui_pixel_math
/tmp/test_ui_pixel_math

Use the unified validation entry point:

./tools/validate.sh --static    # repository checks, workflows, links, secrets, host tests
./tools/validate.sh --firmware  # build, merge-bin, offsets, and BLE compatibility
./tools/validate.sh             # complete gate; requires an activated ESP-IDF environment

CI calls the same script. Fix the shared script or environment if local and CI behavior differs; do not duplicate command sequences in workflows.

Hardware-affecting changes must also run the applicable on-device checklist in the hardware guide. Report compilation separately from physical-device validation.

Never upload the app-only build/FoloToy-AI-Passport.bin to the community. Only the validated build/FoloToy-AI-Passport-full.bin contains the structure the mini-program can inspect and transform safely.