From 151fa6d2c68ce262f89149781ba14d26c2f6fc75 Mon Sep 17 00:00:00 2001 From: Shinku <17696928+Shinku-Chen@users.noreply.github.com> Date: Tue, 25 Aug 2026 19:21:31 +0800 Subject: [PATCH] docs: restructure repository documentation and add CI workflows Restructure project documentation for AI-assisted development, add community issue forms and governance guidance, introduce hardened build/release and fork-sync workflows, and produce a validated 0x0 firmware image for the fixed 8 MB target. --- .github/ISSUE_TEMPLATE/feature_request.yml | 59 +++++ .github/ISSUE_TEMPLATE/usage_question.yml | 65 ++++++ .github/workflows/build-firmware.yml | 74 +++++++ .github/workflows/sync-main.yml | 39 ++++ .gitignore | 1 + AGENTS.md | 48 ++-- CHANGELOG.md | 34 +++ CLAUDE.md | 5 + CODE_OF_CONDUCT.md | 136 ++++++++++++ CODE_OF_CONDUCT.zh_CN.md | 101 +++++++++ CONTRIBUTING.md | 82 +++++++ CONTRIBUTING.zh_CN.md | 66 ++++++ README.md | 208 ------------------ README.zh_CN.md | 207 ----------------- SECURITY.md | 54 +++++ SECURITY.zh_CN.md | 43 ++++ SUPPORT.md | 28 +++ SUPPORT.zh_CN.md | 20 ++ assets/README.md | 16 ++ assets/fonts/README.md | 13 ++ assets/images/README.md | 13 ++ assets/music/README.md | 13 ++ docs/INDEX.md | 32 +++ docs/README.md | 119 ++++++++++ docs/README.zh_CN.md | 118 ++++++++++ docs/assets/.gitkeep | 0 docs/brand-and-product.md | 85 +++++++ docs/contribution/README.md | 16 ++ docs/contribution/commit-and-pr.md | 19 ++ docs/contribution/doc-conventions.md | 22 ++ docs/development/CI-build-and-release.md | 39 ++++ docs/development/CI-sync-main.md | 29 +++ docs/development/README.md | 20 ++ docs/development/agent-guide.md | 88 ++++++++ docs/development/build-and-test.md | 24 ++ docs/development/coding-conventions.md | 14 ++ docs/fork-guide.md | 58 +++++ .../AI_HARDWARE_DEVELOPMENT_GUIDE.md | 4 +- docs/hardware-design/README.md | 22 ++ docs/hardware-design/specifications.md | 23 ++ docs/software-design/README.md | 21 ++ sdkconfig.defaults | 4 +- skills/README.md | 21 ++ 43 files changed, 1654 insertions(+), 449 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/ISSUE_TEMPLATE/usage_question.yml create mode 100644 .github/workflows/build-firmware.yml create mode 100644 .github/workflows/sync-main.yml create mode 100644 CHANGELOG.md create mode 100644 CLAUDE.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CODE_OF_CONDUCT.zh_CN.md create mode 100644 CONTRIBUTING.md create mode 100644 CONTRIBUTING.zh_CN.md delete mode 100644 README.md delete mode 100644 README.zh_CN.md create mode 100644 SECURITY.md create mode 100644 SECURITY.zh_CN.md create mode 100644 SUPPORT.md create mode 100644 SUPPORT.zh_CN.md create mode 100644 assets/README.md create mode 100644 assets/fonts/README.md create mode 100644 assets/images/README.md create mode 100644 assets/music/README.md create mode 100644 docs/INDEX.md create mode 100644 docs/README.md create mode 100644 docs/README.zh_CN.md create mode 100644 docs/assets/.gitkeep create mode 100644 docs/brand-and-product.md create mode 100644 docs/contribution/README.md create mode 100644 docs/contribution/commit-and-pr.md create mode 100644 docs/contribution/doc-conventions.md create mode 100644 docs/development/CI-build-and-release.md create mode 100644 docs/development/CI-sync-main.md create mode 100644 docs/development/README.md create mode 100644 docs/development/agent-guide.md create mode 100644 docs/development/build-and-test.md create mode 100644 docs/development/coding-conventions.md create mode 100644 docs/fork-guide.md rename docs/{ => hardware-design}/AI_HARDWARE_DEVELOPMENT_GUIDE.md (98%) create mode 100644 docs/hardware-design/README.md create mode 100644 docs/hardware-design/specifications.md create mode 100644 docs/software-design/README.md create mode 100644 skills/README.md diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..70ccda6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,59 @@ +name: Feature request / 功能建议 +description: Suggest an improvement to the firmware, BSP, hardware, or documentation. +title: "[Feature] " +body: + - type: markdown + attributes: + value: | + Thanks for suggesting an improvement. Do not include credentials, private device links, or personal data. + 感谢你的建议。请勿提交凭证、私密设备链接或个人数据。 + + - type: textarea + id: problem + attributes: + label: Problem or use case / 问题或使用场景 + description: What problem should this feature solve, and who benefits from it? + placeholder: Describe the current limitation and the intended use case. + validations: + required: true + + - type: textarea + id: proposal + attributes: + label: Proposed behavior / 期望行为 + description: Describe the expected user-visible behavior and acceptance criteria. + validations: + required: true + + - type: dropdown + id: area + attributes: + label: Affected area / 涉及范围 + options: + - Firmware or demo / 固件或示例 + - BSP or hardware interface / BSP 或硬件接口 + - Documentation or tooling / 文档或工具 + - Hardware revision / 硬件版本 + - Not sure / 不确定 + validations: + required: true + + - type: textarea + id: alternatives + attributes: + label: Alternatives considered / 已考虑的替代方案 + description: List any workarounds or alternative designs you considered. + + - type: textarea + id: context + attributes: + label: Additional context / 补充信息 + description: Add sanitized logs, diagrams, or links if useful. + + - type: checkboxes + id: checks + attributes: + label: Safety check / 安全确认 + options: + - label: I removed credentials, private device links, and personal data. / 我已移除凭证、私密设备链接和个人数据。 + required: true diff --git a/.github/ISSUE_TEMPLATE/usage_question.yml b/.github/ISSUE_TEMPLATE/usage_question.yml new file mode 100644 index 0000000..0a7d5d2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/usage_question.yml @@ -0,0 +1,65 @@ +name: Usage question / 使用问题 +description: Ask for help building, flashing, configuring, or using AI Passport. +title: "[Question] " +body: + - type: markdown + attributes: + value: | + Please search existing issues first. Security vulnerabilities must be reported through SECURITY.md, not here. + 请先搜索已有 issue。安全漏洞必须按 SECURITY.md 私密报告,不要填写在这里。 + + - type: textarea + id: question + attributes: + label: Question / 问题 + description: What are you trying to do, and where are you blocked? + validations: + required: true + + - type: input + id: board + attributes: + label: Board revision / 板卡版本 + placeholder: For example, production board or PCB revision; write Unknown if unsure. + validations: + required: true + + - type: input + id: firmware + attributes: + label: Firmware version / 固件版本 + description: Provide a release version, branch name, or commit SHA. + placeholder: For example, v1.0.0 or ea9c823 + validations: + required: true + + - type: input + id: idf + attributes: + label: ESP-IDF version / ESP-IDF 版本 + placeholder: For example, v5.5.3 + + - type: textarea + id: attempts + attributes: + label: Steps tried and observed result / 已尝试步骤与结果 + description: Include commands, expected behavior, and actual behavior. + validations: + required: true + + - type: textarea + id: logs + attributes: + label: Sanitized logs / 已脱敏日志 + description: Paste relevant logs after removing Wi-Fi credentials, tokens, device secrets, and personal data. + render: shell + + - type: checkboxes + id: checks + attributes: + label: Checklist / 确认项 + options: + - label: I searched existing issues and documentation. / 我已搜索已有 issue 和文档。 + required: true + - label: I removed credentials, private device links, and personal data. / 我已移除凭证、私密设备链接和个人数据。 + required: true diff --git a/.github/workflows/build-firmware.yml b/.github/workflows/build-firmware.yml new file mode 100644 index 0000000..49b6351 --- /dev/null +++ b/.github/workflows/build-firmware.yml @@ -0,0 +1,74 @@ +name: Build firmware + +on: + push: + tags: + - "**" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + outputs: + artifact_name: ${{ steps.artifact_name.outputs.name }} + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + + - name: Restore ccache + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5 + with: + path: .ccache + key: ccache-${{ github.ref_type }}-${{ github.ref_name }}-${{ github.sha }} + restore-keys: | + ccache-${{ github.ref_type }}-${{ github.ref_name }}- + ccache- + + - name: Build firmware (ESP-IDF 5.5.3 / esp32c3) + uses: espressif/esp-idf-ci-action@9d38657f3d789ca759b2b37aaf5ceffbc42c4f0d # v1 + with: + esp_idf_version: v5.5.3 + target: esp32c3 + extra_docker_args: >- + -e CCACHE_DIR=/app/${{ github.repository }}/.ccache + -e IDF_CCACHE_ENABLE=1 + command: >- + idf.py -D SDKCONFIG_DEFAULTS=sdkconfig.defaults build && + idf.py merge-bin -o "$PWD/build/FoloToy-AI-Passport-full.bin" + + - name: Set artifact name + id: artifact_name + run: echo "name=passport-${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT" + + - name: Upload firmware artifact + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: ${{ steps.artifact_name.outputs.name }} + path: build/FoloToy-AI-Passport-full.bin + if-no-files-found: error + + release: + if: github.ref_type == 'tag' + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download firmware artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 + with: + name: ${{ needs.build.outputs.artifact_name }} + path: release + + - name: Create release (tag push) + uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2 + with: + name: "${{ github.ref_name }}" + files: release/FoloToy-AI-Passport-full.bin + if-no-files-found: error diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml new file mode 100644 index 0000000..221ab9b --- /dev/null +++ b/.github/workflows/sync-main.yml @@ -0,0 +1,39 @@ +name: Upstream Sync + +permissions: + contents: write + +on: + schedule: + - cron: "0 0 * * *" # every day + workflow_dispatch: + +jobs: + sync_latest_from_upstream: + name: Sync latest commits from upstream repo + runs-on: ubuntu-latest + if: ${{ github.event.repository.fork }} + + steps: + # Step 1: run a standard checkout action + - name: Checkout target repo + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + persist-credentials: false + + # Step 2: run the sync action + - name: Sync upstream changes + id: sync + uses: aormsby/fork-sync-with-upstream-action@83d78e8c4bf524e79b091cf257deba4dee9e60df # v3.4.3 + with: + upstream_sync_repo: FoloToy/ai-passport + upstream_sync_branch: main + target_sync_branch: main + target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set + + - name: Sync check + if: failure() + run: | + echo "[Error] 由于上游仓库的 workflow 文件变更,GitHub 可能暂停本次自动更新。请手动 Sync Fork,详见 docs/development/CI-sync-main.md。" + echo "[Error] An upstream workflow change may have paused automatic synchronization. Sync the fork manually; see docs/development/CI-sync-main.md." + exit 1 diff --git a/.gitignore b/.gitignore index 8b1b4d6..7e631e5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ sdkconfig.old managed_components/ dependencies.lock .vscode/ +.idea/ diff --git a/AGENTS.md b/AGENTS.md index e9c1cea..83078f3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,39 +1,27 @@ -# Repository Guidelines +# AGENTS.md -## Project Structure & Module Organization +给 AI agent(Claude Code / Codex / Cursor / Cline 等)读的仓库说明。Claude Code 另见 `CLAUDE.md`(薄引用本文件)。 -This repository is an ESP-IDF BSP and hardware demonstration for the ESP32-C3-based FoloToy AI Passport. +本文件是仓库权威 AI 规范的**入口与索引**,具体规则已按主题拆分到 `docs/` 下公共文档。规则有更新时改对应 `docs/` 文件,不要在本文件另起一套,以免两份文档 drift。 -- `components/bsp/include/`: public BSP APIs and the hardware pin/configuration source of truth (`bsp_pins.h`). -- `components/bsp/src/`: display, button, audio, battery, and shared-I2C implementations. -- `main/`: the LVGL menu and independent `demo_*.c` hardware validation pages. New demos should implement the `enter`, `exit`, and `key` interface declared in `demo.h`. -- `sdkconfig.defaults`: reproducible target, console, LVGL, and memory defaults. -- `README.md`: wiring, known hardware traps, and the required on-device acceptance checklist. +## 项目概述 -Keep reusable hardware logic in `components/bsp`; keep board demonstration and UI behavior in `main`. +本仓库是 **FoloToy AI Passport** 的开源硬件开发基线。它是一个面向 AI agent 的开放式可穿戴 AI 硬件:`main` 是最小但完整的可运行基线,集中存放**已确认的硬件事实、稳定接口、资源边界、参考实现与验收方法**,AI agent 可据此识别能力与限制、实现并构建应用。本仓库常被 fork 后二次开发,fork 用户的使用约定见 [docs/fork-guide.md](docs/fork-guide.md)。 -## Build, Test, and Development Commands +- **平台**:ESP32-C3(32 位 RISC-V,无 PSRAM,8MB Flash),ESP-IDF 5.5.x(已知开发环境 5.5.3)。 +- **屏**:ST7789P3,240×320 竖屏 RGB565,SPI2 40MHz,LVGL。 +- **交互**:`UP`/`DOWN`/`OK` 三键(GPIO0 ADC 电阻梯);音频 ES8311(I2S0 全双工);电池 CW2017;I2C0 共享总线。 +- **协议**:MIT LICENCE,仓库根许可证文件为准。 -Use ESP-IDF 5.5.x: +## 规则索引(按触发场景阅读) -```bash -get_idf553 # Enter the repository's ESP-IDF 5.5.3 environment -idf.py set-target esp32c3 # Configure a fresh checkout -idf.py build # Compile firmware and validate dependencies -idf.py flash monitor # Flash the connected board and open logs -idf.py fullclean # Remove generated build state when configuration is stale -``` +开始任何工作前,先读 `docs/contribution/doc-conventions.md`(文档生成规范与分类)。此后按触发场景读取对应规则: -There is no host-side automated test suite currently. Treat a clean `idf.py build` as the minimum check, then run every applicable item in the README acceptance checklist on real hardware. +- **首次接触本仓库 / 需要定位功能或新增代码前**,先读 [docs/fork-guide.md](docs/fork-guide.md)(目录结构、`main` 保持干净、fork 约定、`docs/assets` 使用)。 +- **AI 开始开发前(建立上下文、需求拆解、BSP 边界、验收交付格式)**,先读 [docs/development/agent-guide.md](docs/development/agent-guide.md)。 +- **构建、烧录或验证改动前**,先读 [docs/development/build-and-test.md](docs/development/build-and-test.md)(ESP-IDF 命令、逻辑测试、编译与真机验证分开)。 +- **编写代码前**,先读 [docs/development/coding-conventions.md](docs/development/coding-conventions.md)(语言风格、复用、注释、测试同步、资源约束)。 +- **提交或创建 PR 前**,先读 [docs/contribution/commit-and-pr.md](docs/contribution/commit-and-pr.md)(commit 格式、push、PR 说明要求)。 +- **参与社区或贡献代码前**,见根目录 [CONTRIBUTING.md](CONTRIBUTING.md)(贡献指南)、[CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)(行为准则)、[SECURITY.md](SECURITY.md)(安全报告)、[SUPPORT.md](SUPPORT.md)(支持渠道)。 -## Coding Style & Naming Conventions - -Write C using four-space indentation and K&R-style braces, following nearby files. Use `snake_case` for functions and locals, `BSP_*` for public hardware constants, and `s_` for file-local state. Keep BSP APIs prefixed with `bsp_`; name demo entry points `demo__`. Prefer `static` for internal symbols. UI text stays English; explanatory comments may be Chinese. Preserve comments documenting hardware-specific register values and memory constraints. - -## Testing Guidelines - -Before submitting, build from the repository root and inspect warnings. On hardware, verify menu navigation and the affected Display, Button, Audio, or Battery page. For pin, display-rotation, codec-clock, ADC, or DMA changes, explicitly record the observed hardware result in the PR. Do not increase LVGL buffers or audio allocations without checking ESP32-C3 internal RAM usage; the board has no PSRAM. - -## Commit & Pull Request Guidelines - -History follows Conventional Commit-style subjects such as `feat(bsp): ...`, `feat(demo): ...`, `fix(bsp): ...`, and `docs: ...`. Keep commits focused by subsystem. Pull requests should explain the hardware/revision tested, summarize behavior changes, list build and on-device results, and include photos or screenshots for display changes. Link related issues and call out wiring, pin-map, or compatibility impacts. +完整文档导航见 [docs/INDEX.md](docs/INDEX.md)。 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d094ad6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,34 @@ +# Changelog + +## Unreleased + +- PR 审查修复:GitHub Actions 固定到完整 commit SHA,构建与发布 job 按最小权限拆分,同步 checkout 关闭凭证持久化;补充 Feature Request / Usage Question issue 表单;启用并修正私密安全报告兜底说明;清理 README 路径、CI 触发条件与历史分支描述漂移。 +- 语言规范变更:commit 标题、PR 标题与 body 由"默认中文"改为**使用英文**(`docs/contribution/commit-and-pr.md` 更新);中文写作规范(全角标点)适用范围剔除 PR/MR 描述(`doc-conventions.md` 更新)。 +- CI 构建改造:`build-firmware.yml` 显式传入 `SDKCONFIG_DEFAULTS=sdkconfig.defaults` 再 `idf.py build`,由 defaults 启用自定义分区表(`CONFIG_PARTITION_TABLE_CUSTOM=y`,文件名为 `partitions.csv`);`CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE` 改为 `n`,再用 `idf.py merge-bin -o build/FoloToy-AI-Passport-full.bin` 合并可直刷完整固件;产物精简为仅 full.bin;`actions/cache` 升级到 v5 以消除 GitHub Actions Node.js 20 弃用警告;CI 文档同步更新。 +- 合并上游 PR #6(wireless-low-power-demos)以解决 PR #4 冲突:引入无线/低功耗 demo(`main/demo_wifi.c`、`demo_ble.c`、`demo_radio.c`、`demo_low_power.c`)、`partitions.csv`(NVS/PHY/3 MB factory-app 分区)、`main/CMakeLists.txt`/`main.c`/`demo.h`/`sdkconfig.defaults` 更新;同步硬件指南的 Wi-Fi/BLE/低功耗章节;README 能力契约表补充 Wi-Fi/Bluetooth LE/Low power 三项(中英双语)。 +- 提交规范补充:`docs/contribution/commit-and-pr.md` 明确 PR 标题与 commit 标题使用相同的 Conventional Commit 格式和英文祈使句,不用名词短语当标题。 +- CI 与文档清理:`sync-main.yml` 移除 `test_mode` 残留模板注释;`docs/development/coding-conventions.md` 将「Redis TTL」条目泛化为「缓存组件」条目(当前固件无 TTL 约束需求,消除从模板带入的无关约定)。 +- 补充通用规范(借鉴 Shinku):`docs/contribution/doc-conventions.md` 新增中文全角标点规范(正文 `,`;`(`)`,代码/命令/路径保留英文原样)、凭证不入仓规范(token/密钥/私钥绝不入仓,提交前 git diff 扫描敏感前缀)、文件删除安全规范(删除走系统回收站,不用 rm -rf/git clean -fd)。 +- 代码注释规范强化:`docs/development/coding-conventions.md` 补充完善注释要求——函数说明(用途/参数/返回值/副作用/线程上下文/内存所有权/初始化顺序)、变量说明(语义/取值范围/生命周期/同步要求)、逻辑注释(状态机/时序/寄存器/魔数依据),覆盖范围宁多勿少,中文注释保留英文技术术语。 +- 文档去 AI 化:`docs/README.md` / `docs/README.zh_CN.md` 移除 AI 专属章节(Entry point、Source-of-truth、提需求格式、BSP 边界、Runtime invariants、验收交付格式、构建命令),README 只保留给人看的项目介绍、硬件能力契约、demo 案例与项目结构;构建命令章节删除(与 `docs/development/build-and-test.md` 重复)。 +- 新增 `docs/development/agent-guide.md`:集中承载"AI 如何在本仓库工作"(上下文建立顺序、事实来源优先级、提需求格式、BSP 边界、运行时规则、交付格式),并链接 build-and-test 与硬件指南,不重复构建命令与验收矩阵。 +- 同步更新索引:`AGENTS.md` 规则索引新增 agent-guide 条目;`docs/INDEX.md` 与 `docs/development/README.md` 新增 agent-guide 索引行。 +- 文档补充:`docs/fork-guide.md` 说明「为什么根目录不放置 README」——根目录 README 预留给 fork 开发者自行放置(上游留空),fork 后可将自己的内容写入根目录 `README.md` 介绍 fork 后的项目;GitHub 显示优先级(根 README > docs/README.md)契合该预留意图。 +- 分支合并:创建 `main-update` 分支(基于与上游一致的 main),将 `feature/repo-structure`、`ci/build-firmware`、`ci/sync-main` 三个分支合并进来,统一 docs 结构(CI 文档归入 `docs/development/`,workflow 文件随 ci 分支引入 `.github/workflows/`);解决 development/software-design README 的 add/add 冲突。 +- 合并后审查修复:`docs/INDEX.md` 补充 CI 文档索引;`docs/fork-guide.md` 修正 workflow 引用为 `.github/workflows/sync-main.yml`;`docs/README` 双语项目结构块补充 `.github/workflows/` 与 CI 文档说明。 +- ci 分支 CI 文档路径调整:`ci/build-firmware` 的 `docs/software-design/CI-build-and-release.md` 与 `ci/sync-main` 的 `docs/software-design/CI-sync-main.md` 均移入各分支的 `docs/development/`(CI 属工程规范);`docs/software-design/README.md` 保留为软件设计索引;feature 分支的 software-design 索引同步更新引用。 +- fork 补充文档目录迁移:`assets/docs/` 移至 `docs/assets/`(文档素材归入 docs/ 更合理),新增 `docs/assets/.gitkeep` 空目录占位;同步更新 AGENTS.md / INDEX / doc-conventions / fork-guide 的路径引用。 +- 文档结构调整:根目录不再放 README——上游英文 README 移入 `docs/README.md`、中文移入 `docs/README.zh_CN.md`(GitHub 从 docs/ 识别主 README);原 `docs/README.md` 根总索引更名为 `docs/INDEX.md`;同步更新 AGENTS.md / CONTRIBUTING / SUPPORT / fork-guide / doc-conventions 的路径引用。 +- 初始化项目文档:新增 `AGENTS.md`、`CLAUDE.md` 和 `CHANGELOG.md`。 +- 仓库结构规整:上游英文 `README.md` 更名为 `README.en_US.md`,保留 `README.zh_CN.md`。 +- 新增目录骨架:`docs/`(software-design / hardware-design)、`assets/`(fonts / images / music,各含 `README.md`)、`skills/`。 +- 将上游硬件开发指南归位到 `docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md`。 +- 文档规范:子目录 readme 统一为大写 `README.md`;补充 fork 用户约定(main 只动根 README)。 +- 扩展 fork 用户约定:`main` 分支允许修改根目录 `README.md` 和 `assets/docs/`(README 不足以说明项目时存放补充文档与素材)。 +- 新增 `assets/docs/` 目录约定:上游 main 只保留空目录 `.gitkeep`,内容文件仅存在于 fork;使用方法规范写入 AGENTS.md「给 fork 用户」约定。 +- CI 文档迁移:`docs/software-design/CI.md` 从本分支移除,迁至 `ci/build-firmware` 分支并改名为 `docs/software-design/CI-build-and-release.md`。 +- 补充 `main` 分支策略说明:解释 `main` 保持干净的两大原因(与上游同步无冲突 + 多小项目按分支整理);例外——执意 main 开发需停用 CI 自动同步;提醒 fork 用户默认 action 关闭需手动启用(此条为整个 CI 的通用要求,统一写入 AGENTS.md)。 +- 文档拆分:将 `AGENTS.md` 按主题拆为公共文档——新增 `docs/contribution/`(doc-conventions.md、commit-and-pr.md)与 `docs/development/`(build-and-test.md、coding-conventions.md),新增 `docs/fork-guide.md`;`AGENTS.md` 精简为简介 + 项目概述 + 必读文档索引。 +- 同步更新索引:`docs/software-design/README.md`、`README.en_US.md` / `README.zh_CN.md` 的 `docs/` 目录说明。 +- 参考 cindy 仓库文档组织完善索引:新增 `docs/README.md` 根总索引;AGENTS.md 规则索引按触发场景改写(附触发条件);`docs/contribution/` 与 `docs/development/` 的 README 补充收录标准。 +- 引入社区治理文档(参照 cindy 改写,放仓库根目录):新增 `CONTRIBUTING.md` / `.zh_CN.md`(贡献指南,针对 ESP-IDF/AI agent/fork 场景改写)、`CODE_OF_CONDUCT.md` / `.zh_CN.md`(贡献者公约)、`SECURITY.md` / `.zh_CN.md`(安全报告流程)、`SUPPORT.md` / `.zh_CN.md`(支持渠道);AGENTS.md 与 docs/README.md 同步引用。 diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..bba01d4 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +# CLAUDE.md + +本仓库的 AI 说明以 [`AGENTS.md`](./AGENTS.md) 为唯一权威源(single source of truth),Claude Code 请直接按 `AGENTS.md` 执行:项目结构、构建 / 验证命令、代码约定、提交规范等均在其中。 + +规则有更新时改 `AGENTS.md`,不要在本文件另起一套,以免两份文档 drift。 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..14a1c86 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,136 @@ +

+ 简体中文 · English +

+ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical address or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +**the FoloToy project maintainers** (see the repository for contact details). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +Security vulnerabilities are not a Code of Conduct issue — please report them +privately via [`SECURITY.md`](SECURITY.md). + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +. + +The Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +. Translations are available at +. + +[homepage]: https://www.contributor-covenant.org +[Mozilla CoC]: https://github.com/mozilla/diversity diff --git a/CODE_OF_CONDUCT.zh_CN.md b/CODE_OF_CONDUCT.zh_CN.md new file mode 100644 index 0000000..1fdcb95 --- /dev/null +++ b/CODE_OF_CONDUCT.zh_CN.md @@ -0,0 +1,101 @@ +

+ 简体中文 · English +

+ +# 贡献者公约行为准则 + +## 我们的承诺 + +作为成员、贡献者和维护者,我们承诺让每个人参与社区时免受骚扰,无论其年龄、体型、 +可见或不可见的残障、民族、性征、性别认同与表达、经验水平、教育程度、社会经济地位、 +国籍、外貌、种族、种姓、肤色、宗教或性取向如何。 + +我们承诺以有助于建设开放、友善、多元、包容、健康社区的方式行动和交流。 + +## 我们的准则 + +有助于营造积极环境的行为示例包括: + +* 对他人展现同理心和善意; +* 尊重不同的意见、观点和经历; +* 给予并大方接受建设性反馈; +* 为自己的错误承担责任,向受影响的人道歉,并从中学习; +* 关注对整个社区最有利的事情,而不仅仅是对个人有利的事情。 + +不可接受的行为示例包括: + +* 使用带有性暗示的语言或图像,以及任何形式的性关注或性挑逗; +* 挑衅、侮辱或贬损性评论,人身攻击或政治攻击; +* 公开或私下的骚扰; +* 未经明确许可发布他人的私人信息(例如住址或电子邮箱); +* 其他在专业场合中可以被合理认定为不当的行为。 + +## 执行责任 + +社区维护者有责任澄清并执行可接受行为的标准,并将针对任何他们认为不当、威胁、 +冒犯或有害的行为采取适当且公平的纠正措施。 + +社区维护者有权利和责任删除、编辑或拒绝与本行为准则不符的评论、提交、代码、 +wiki 编辑、issue 及其他贡献,并在适当时说明处理原因。 + +## 适用范围 + +本行为准则适用于所有社区空间,也适用于个人在公开场合正式代表社区的情形, +例如使用官方电子邮箱、通过官方社交媒体账号发布内容,或作为指定代表参加 +线上或线下活动。 + +## 执行 + +辱骂、骚扰或其他不可接受的行为可向负责执行的社区维护者报告:**FoloToy 项目维护者** +(联系方式见仓库)。所有投诉都会得到及时、公正的审查和调查。 + +所有社区维护者都有义务保护事件报告者的隐私与安全。 + +安全漏洞不属于行为准则问题——请按 [`SECURITY.md`](SECURITY.md) 私下报告。 + +## 执行指引 + +社区维护者将按以下「社区影响指引」判定违反本行为准则的行为的后果: + +### 1. 纠正 + +**社区影响**:使用不当语言,或有其他在社区中被认为不专业、不受欢迎的行为。 + +**后果**:由社区维护者发出私下的书面警告,说明违规性质并解释行为为何不当。 +可能会要求公开道歉。 + +### 2. 警告 + +**社区影响**:单次事件或一系列行为构成违规。 + +**后果**:警告,并说明持续违规的后果。在指定期限内不得与相关人员互动,包括 +不得主动与执行行为准则的人员互动;这同时适用于社区空间和社交媒体等外部渠道。 +违反这些条件可能导致临时或永久封禁。 + +### 3. 临时封禁 + +**社区影响**:严重违反社区准则,包括持续的不当行为。 + +**后果**:在指定期限内禁止与社区进行任何形式的互动或公开交流。期间不得与相关 +人员进行公开或私下互动,包括不得主动与执行行为准则的人员互动。违反这些条件将 +导致永久封禁。 + +### 4. 永久封禁 + +**社区影响**:表现出违反社区准则的行为模式,包括持续的不当行为、骚扰个人, +或对某类群体的攻击或贬低。 + +**后果**:永久禁止在社区内进行任何形式的公开互动。 + +## 来源声明 + +本行为准则改编自 [Contributor Covenant][homepage] 2.1 版,原文见 +。 + +社区影响指引的灵感来自 [Mozilla 的行为准则执行阶梯][Mozilla CoC]。 + +常见问题见 ;其他语言译本见 +。 + +[homepage]: https://www.contributor-covenant.org +[Mozilla CoC]: https://github.com/mozilla/diversity diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3b2a891 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,82 @@ +

+ 简体中文 · English +

+ +# Contributing + +Thank you for contributing to FoloToy AI Passport — code, documentation, +firmware, and feedback. This repository is the development baseline for +open-source wearable AI hardware designed for AI agents. It is often forked for +second development; the fork conventions are in +[`docs/fork-guide.md`](docs/fork-guide.md). + +## Before you start + +- Read [`AGENTS.md`](AGENTS.md): it is the authoritative entry and index for the + rules an AI agent should follow. It is not a replacement for this guide. +- Read [`README.md`](docs/README.md) for the hardware capability contract, + and the [AI Hardware Development Guide](docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md) + for the complete hardware context. +- Follow [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md) when participating in the + community. For ordinary usage questions, see [`SUPPORT.md`](SUPPORT.md). +- Do not commit credentials, tokens, authorization files, or personal data. +- The repository's `main` branch stays in sync with the upstream baseline; fork + users develop feature work in `feature/*` branches (see `docs/fork-guide.md`). + +## Development and verification + +Use ESP-IDF 5.5.x (known development environment 5.5.3): + +```bash +get_idf553 # Enter the repository's ESP-IDF 5.5.3 environment +idf.py set-target esp32c3 # Configure the target chip (fresh checkout / after target change) +idf.py build # Compile firmware and validate dependencies +idf.py flash monitor # Flash and open logs +idf.py fullclean # Clear stale build state (never for user source changes) +``` + +The current baseline includes a pure-logic test that runs without hardware: + +```bash +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 +``` + +Follow the verification requirements in +[`docs/development/build-and-test.md`](docs/development/build-and-test.md): +a clean `idf.py build` is the minimum automated check, not hardware validation. +Record build results and on-device results separately; never present a successful +build as successful hardware validation. + +## Opening a pull request + +1. Create a short-lived `feature/*` branch from `main` and keep each pull request + focused on one clear problem. +2. Use `(): ` for the pull request title, for + example `feat(bsp): ...`, `docs: ...`. Available types are defined in + [`docs/contribution/commit-and-pr.md`](docs/contribution/commit-and-pr.md). +3. Review the complete diff and confirm that it contains no credentials, + unrelated generated files, or unintended changes. +4. Follow the PR requirements in `docs/contribution/commit-and-pr.md`: state the + hardware/revision tested, summarize behavior changes, list build and on-device + results, link related issues, and record observed on-device results for pin, + display-rotation, codec-clock, ADC, or DMA changes. +5. Wait for CI and review; do not push directly to `main` unless you are a + maintainer handling an explicit exception. + +Small documentation fixes are welcome as pull requests. For larger changes to +hardware, architecture, or user data, please open an issue first to discuss +scope and compatibility. + +## Licensing of contributions + +This repository is licensed under [MIT](LICENSE). By contributing, you agree that +your contribution is submitted under the MIT license terms of the repository. + +## Security issues + +Do not disclose vulnerabilities, credentials, or exploitable details in public +issues, pull requests, or discussions. Follow the private reporting process in +[`SECURITY.md`](SECURITY.md). diff --git a/CONTRIBUTING.zh_CN.md b/CONTRIBUTING.zh_CN.md new file mode 100644 index 0000000..9ce3831 --- /dev/null +++ b/CONTRIBUTING.zh_CN.md @@ -0,0 +1,66 @@ +

+ 简体中文 · English +

+ +# 贡献指南 + +感谢你为 FoloToy AI Passport 贡献代码、文档、固件和反馈。本仓库是面向 AI agent 的 +开源可穿戴 AI 硬件的开发基线。它常被 fork 后二次开发,fork 用户约定见 +[`docs/fork-guide.md`](docs/fork-guide.md)。 + +## 开始之前 + +- 先读 [`AGENTS.md`](AGENTS.md):它是 AI agent 应遵循规则的权威入口与索引,不是本指南的替代品。 +- 先读 [`README.zh_CN.md`](docs/README.zh_CN.md) 的硬件能力契约,以及 + [AI 硬件开发指南](docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md) 的完整硬件上下文。 +- 参与社区时请遵守 [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md);普通使用问题见 [`SUPPORT.md`](SUPPORT.md)。 +- 不要提交凭证、令牌、授权文件或个人数据。 +- 仓库的 `main` 分支始终与上游基线保持同步;fork 用户在 `feature/*` 分支开发功能(见 `docs/fork-guide.md`)。 + +## 开发与验证 + +使用 ESP-IDF 5.5.x(已知开发环境 5.5.3): + +```bash +get_idf553 # 进入仓库的 ESP-IDF 5.5.3 环境 +idf.py set-target esp32c3 # 配置目标芯片(fresh checkout 后/换 target 后运行) +idf.py build # 编译固件,验证依赖 +idf.py flash monitor # 烧录并打开日志 +idf.py fullclean # 配置过期时清空生成状态(勿用于清理用户源码改动) +``` + +当前基线含一个可脱离硬件运行的纯逻辑测试: + +```bash +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 +``` + +遵守 [`docs/development/build-and-test.md`](docs/development/build-and-test.md) 的 +验证要求:干净的 `idf.py build` 是最低自动检查,不是硬件验收;构建结果与真机结果 +分开记录,禁止把编译通过描述成硬件验证通过。 + +## 提交 Pull Request + +1. 从 `main` 创建短生命周期 `feature/*` 分支,保持一个 PR 只解决一个清晰的问题。 +2. PR 标题使用 `(): <简短描述>`,例如 `feat(bsp): ...`、`docs: ...`。 + 可用 type 见 [`docs/contribution/commit-and-pr.md`](docs/contribution/commit-and-pr.md)。 +3. Review 完整 diff,确认没有凭证、无关生成文件或意外改动。 +4. 遵守 `docs/contribution/commit-and-pr.md` 的 PR 要求:说明测试的硬件/版本、 + 行为变更摘要、构建与真机结果,链接相关 issue,并对引脚、显示旋转、codec 时钟、 + ADC、DMA 改动显式记录观察到的真机结果。 +5. 等待 CI 和 review;除维护者显式例外外,不要直接向 `main` 推送。 + +小型文档修正也欢迎直接提交 PR。涉及硬件、架构或用户数据的较大改动,建议先开 issue +讨论范围和兼容性。 + +## 贡献的许可 + +本仓库使用 [MIT](LICENSE) 许可证。提交贡献即表示你同意按本仓库的 MIT 条款并入你的贡献。 + +## 安全漏洞 + +不要在公开 issue、Pull Request 或讨论中披露漏洞、凭证或可利用细节。请按 +[`SECURITY.md`](SECURITY.md) 的私密报告流程处理。 diff --git a/README.md b/README.md deleted file mode 100644 index f2e2167..0000000 --- a/README.md +++ /dev/null @@ -1,208 +0,0 @@ -# FoloToy AI Passport - -English | [简体中文](README.zh_CN.md) - -FoloToy AI Passport is open wearable AI hardware designed for AI agents. This repository is the development baseline for the device. It goes beyond showing “what the board can run” by keeping the **hardware facts, stable interfaces, resource boundaries, reference implementations, and validation methods** that an agent needs to build applications in one place. - -The repository is organized around the following principles: - -- `main` is the smallest complete runnable baseline and an executable description of the current hardware capabilities. -- `components/bsp` isolates board-level details and exposes stable APIs to applications. -- `demo/*` branches show different paths from a product requirement to a working implementation. -- `AGENTS.md` defines how an agent should work in the repository, while `docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md` contains the complete hardware context and troubleshooting knowledge. -- Build results and physical-device results are reported separately. A successful build must never be presented as successful hardware validation. - -The intended workflow is simple: give an agent this repository and an application requirement. The agent identifies the available capabilities and constraints, selects relevant examples, implements and builds the application, and returns an acceptance checklist that can be executed on the physical device. - -## Entry point for AI agents - -Before starting development, establish context in this order: - -1. Read `AGENTS.md`, this README, and [`docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md`](docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md). -2. Run `git status --short --branch` and preserve all existing user changes. -3. Read the affected `components/bsp/include/*.h` headers and their implementations. Do not infer board behavior from common chip or development-board configurations. -4. Use `git branch -r --list 'origin/demo/*'` to find examples close to the requirement. Reuse only the relevant design patterns; do not merge an entire demo branch by default. -5. Break the requirement into inputs, outputs, state, concurrent tasks, persistence, memory budget, and failure degradation before deciding whether to change `main` or extend `components/bsp`. -6. Complete the minimum build check and all applicable logic tests. Keep explicit on-device acceptance items for every conclusion that depends on the display, buttons, audio, battery, or timing. - -### Source-of-truth priority - -When information conflicts, use this priority order: - -```text -Schematic / PCB / board revision / physical measurement - > components/bsp/include/bsp_pins.h - > BSP public headers and implementations - > docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md - > README and example applications -``` - -The repository does not currently include schematic or PCB source files. When the board revision, wiring, polarity, register behavior, or unused GPIOs are unknown, an agent must report the unknown and request evidence instead of filling the gap with parameters from another ESP32-C3 board. - -## Hardware capability contract - -The table below describes the application capabilities implemented by the current `main` branch. It is not a list of everything that might be possible according to the chip datasheet. - -| Capability | Confirmed implementation | Application interface | Boundaries that must be respected | -| --- | --- | --- | --- | -| Display | ST7789P3, 240 × 320 portrait RGB565, SPI2 at 40 MHz; LEDC backlight | `bsp_display_*`, `bsp_lvgl_*` | The ESP32-C3 has no PSRAM; the current design uses a small single DMA buffer; no LCD MISO, touch, or known TE interface | -| Input | `UP`, `DOWN`, and `OK` share an ADC resistor ladder on GPIO0 | `bsp_button_init()`, `bsp_button_read_mv()` | Callbacks run in the button component task and must not block; do not create a second ADC1 unit | -| Audio | ES8311 with full-duplex PCM over I2S0, supporting playback and microphone capture | `bsp_audio_*` | PCM reads and writes block and belong in a worker task; format changes must retain the BSP close/open sequence | -| Battery | CW2017 state-of-charge and voltage readings | `bsp_battery_*` | This capability is optional at runtime; accuracy depends on the cell and battery profile and is not equivalent to a calibrated result | -| Wi-Fi | On-demand 2.4 GHz STA scan demo | `main/demo_wifi.c` | Scans only; it does not connect, store credentials, or validate antenna/RF performance | -| Bluetooth LE | On-demand non-connectable NimBLE advertising as `FoloPassport` | `main/demo_ble.c` | ESP32-C3 does not support Bluetooth Classic; radio range, coexistence, and power draw require device measurements | -| Low power | Two-second light sleep and five-second deep sleep, both with RTC timer wakeup | `main/demo_low_power.c` | Deep sleep restarts the application; external/button wakeup and board-level power consumption remain unverified | -| Shared bus | ES8311 and CW2017 share I2C0 | `bsp_i2c_*` | Every device must reuse the bus owned by the BSP; do not create another bus on the same port for scanning or a new device | -| Logging and flashing | Native ESP32-C3 USB Serial/JTAG | ESP-IDF console | GPIO18/19 are reserved for USB; the default UART0 TX on GPIO21 conflicts with the backlight | - -All pins, addresses, panel parameters, and button voltage windows are defined only in [`components/bsp/include/bsp_pins.h`](components/bsp/include/bsp_pins.h). Application code must not duplicate these constants. See the [AI Hardware Development Guide](docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md) for the complete pin map, panel initialization, ADC thresholds, I2C addressing rules, audio clocks, and memory details. - -Applications may also use ESP-IDF timers, FreeRTOS tasks, and internal Flash/NVS; the Pomodoro branch contains an NVS example. Wi-Fi and Bluetooth LE remain ESP-IDF application services rather than BSP APIs: their menu pages initialize each stack only while open and release it on exit. `demo/claude-buddy-port` remains a fuller BLE application architecture reference, not a substitute for measuring the current board's antenna, RF performance, power consumption, and coexistence behavior. Every FoloToy AI Passport has 8 MB of Flash, and the default firmware configuration targets 8 MB with a 3 MB factory-app partition. - -### Capabilities outside the current contract - -The repository does not currently provide enough evidence to guarantee touch input, display readback, an IMU, external storage, charging control, USB insertion detection, controllable power-amplifier enable, external/button deep-sleep wakeup, arbitrary “free GPIOs,” exact battery capacity, or production-grade power specifications. A capability being present in the ESP32-C3 silicon does not mean that it is connected, powered correctly, or validated on this board. - -Requirements involving these capabilities must begin with a schematic, board revision, component documentation, or physical measurements. Only then should the BSP and its acceptance criteria be extended. - -## Start development with one requirement - -A simple request can be given directly to an agent: - -```text -On the main branch, build an offline habit-tracking application for FoloToy AI Passport. -Use the three physical buttons and the 240×320 display, and preserve records across power loss. -Follow AGENTS.md and AI_HARDWARE_DEVELOPMENT_GUIDE.md. Inspect relevant demo branches first, -keep hardware logic in components/bsp and application logic in main, deliver a runnable -implementation with tests, and report the build result, unexecuted device checks, and exact -on-device acceptance steps separately. -``` - -The more specific the requirement, the more likely the agent is to implement it correctly in one pass. Useful details include: - -- User flow: what each page displays and what short press, double press, and long press do for each button. -- State and data: whether the application needs timing, persistence across power loss, networking, recording, or communication with a computer. -- Experience goals: fonts, colors, animation, sound, response time, and error states. -- Constraints: whether the main menu may be replaced, dependencies added, Flash used, or default interactions changed. -- Acceptance criteria: which behaviors require automated tests and which must be observed on real hardware. - -When details are omitted, an agent may choose conservative defaults that do not change the product direction, but it must list those assumptions in the delivery. Decisions involving new wiring, electrical safety, board revisions, or irreversible data formats require confirmation first. - -## Demo branches are design cases, not a feature pile - -Each `demo/*` branch evolves the baseline into an independent application. The branches demonstrate how specific problems were solved. New applications should normally branch from `main` and consult relevant examples instead of merging multiple demos wholesale. - -| Branch | Application | Patterns worth reusing | -| --- | --- | --- | -| `demo/stopwatch` | Stopwatch | Minimal timer application, separation of pure logic from LVGL, host-side logic tests | -| `demo/cat-themed-pomodoro-timer` | Cat-themed Pomodoro timer | Monotonic time, pause/resume, NVS persistence, a detailed PRD, and a state model | -| `demo/rock-paper-scissors` | Rock paper scissors | RGB565 image assets, asset-generation scripts, and Flash resource tradeoffs | -| `demo/tetris-game` | Three-button Tetris | Real-time game loop, low-latency `PRESS` input, partial refresh, a pure game model, audio, and microphone interaction | -| `demo/claude-buddy-port` | Desktop AI hardware companion | Replacing the demo menu with a complete application, encrypted BLE, protocol parsing, state reduction, task communication, and extensive host tests | - -Inspect an example without switching the current working tree: - -```bash -git branch -r --list 'origin/demo/*' -git diff main...origin/demo/tetris-game -- main components tests -git show origin/demo/tetris-game:main/demo_tetris.c -``` - -Start a new application: - -```bash -git switch main -git switch -c feature/my-passport-app -``` - -Example branches may change the same menu, configuration, or driver in incompatible ways. An agent must understand the differences before extracting a state model, asset pipeline, or concurrency pattern. Code appearing in an example branch is not automatically part of the current `main` BSP contract. - -## Application and BSP boundary - -```text -Natural-language requirement - └─ main/ Pages, state machines, animation, app tasks, assets - └─ components/bsp/include/ Stable board-level APIs - └─ components/bsp/src/ GPIO, buses, devices, and driver details - └─ bsp_pins.h Single source of truth for pins and hardware parameters -``` - -To add a regular page, create `main/demo_.c` and implement the `enter`, `exit`, and `key` interface, then update: - -- Declarations in `main/demo.h`. -- The source list in `main/CMakeLists.txt`. -- The `DEMOS[]` registration in `main/main.c`. -- Menu initialization status and failure degradation if a new optional peripheral is involved. - -Only hardware capabilities shared by multiple applications belong in `components/bsp`. A BSP API must document blocking behavior, thread context, memory ownership, failure values, and initialization order. Pins and I2C addresses belong only in `bsp_pins.h`. - -### Runtime invariants - -- LVGL is not thread-safe. Code outside the LVGL context must hold `bsp_lvgl_lock()` while accessing `lv_*` objects. -- Button callbacks only dispatch lightweight events. Recording, playback, storage, and other slow operations belong in worker tasks. -- When leaving a page, stop every task or timer that may access its UI before deleting the screen and clearing object pointers. -- The default global interaction is `UP`/`DOWN` navigation in the menu, short `OK` to enter, and long `OK` to return from a page. Any change must be explicit. -- New images, fonts, network stacks, audio buffers, LVGL buffers, and task stacks must be evaluated against internal RAM. Sufficient total free heap does not guarantee a sufficiently large contiguous block. -- Testable state machines, protocols, timing, and layout calculations should be separated from ESP-IDF/LVGL and covered by host-side logic tests. - -## Build and run baseline - -The project uses ESP-IDF 5.5.x; the known development environment is 5.5.3: - -```bash -get_idf553 # Maintainer-local helper -# Or source "$HOME/esp/esp-idf-v5.5.3/export.sh" (example installation path) -idf.py set-target esp32c3 # Run for a fresh checkout or after using another target -idf.py build -idf.py flash monitor -``` - -The first build uses ESP-IDF Component Manager to fetch LVGL, `esp_lvgl_port`, `button`, `esp_codec_dev`, and other dependencies. Do not edit the generated `managed_components/` directory. If configuration state is stale, use `idf.py fullclean` and configure again, but never use it to clean user source changes. - -The current baseline includes a pure-logic test that can run independently: - -```bash -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 -``` - -Different example branches may provide their own host-test commands; follow the README on that branch. - -## Acceptance and delivery format - -`idf.py build` is the minimum automated check, not hardware validation. For changes involving physical peripherals, record at least the following on a FoloToy AI Passport: - -- USB Serial/JTAG produces stable startup logs with no reboot loop, assertion, or watchdog reset. -- Display orientation, colors, edges, refresh behavior, and backlight are correct. -- `UP`, `DOWN`, and `OK` produce the intended events, and long `OK` returns correctly. -- Audio sample rate, playback, non-zero recording, and page exit behavior are correct. -- Battery readings are plausible, and the application degrades safely when the CW2017 is absent. -- Wi-Fi rescans complete, BLE advertising is visible to a phone scanner, and both pages can be entered and exited repeatedly. -- The Low Power page uses `UP`/`DOWN` to select light or deep sleep and `OK` to run it. Light sleep wakes by timer after approximately two seconds and restores the display backlight; deep sleep restarts after approximately five seconds and reports a retained wake count. -- Repeated page transitions and concurrent operations do not continuously leak tasks, objects, or heap. - -An agent's final delivery must distinguish these outcomes: - -```text -Build: PASS / FAIL / NOT RUN -Host tests: PASS / FAIL / NOT RUN -Device tests: PASS / FAIL / NOT RUN -Unverified: items that still require a board, instrument, or user confirmation -``` - -See the [AI Hardware Development Guide](docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md) for the acceptance matrix by change type—including pins, LCD, ADC, codec, I2C, and DMA—and the troubleshooting reference. - -## Project structure - -```text -components/bsp/include/ Public BSP APIs and bsp_pins.h hardware facts -components/bsp/src/ Display, button, audio, battery, and shared-I2C implementations -main/ Minimal menu, LVGL UI, and independent hardware demo pages -tests/ Lightweight logic tests that can run without hardware -docs/ Agent hardware development guide and extension documentation -sdkconfig.defaults ESP32-C3, USB console, Flash, and LVGL defaults -partitions.csv NVS, PHY data, and 3 MB factory application layout -AGENTS.md Coding, validation, and contribution rules for agents -``` diff --git a/README.zh_CN.md b/README.zh_CN.md deleted file mode 100644 index 3b41f70..0000000 --- a/README.zh_CN.md +++ /dev/null @@ -1,207 +0,0 @@ -# FoloToy AI Passport - -[English](README.md) | 简体中文 - -FoloToy AI Passport 是一个面向 AI agent 的开放式可穿戴 AI 硬件,本仓库是这款 AI 硬件的开发基线。它不只展示“板子能运行什么”,还把 agent 开发应用所需的**硬件事实、稳定接口、资源边界、参考实现和验收方法**放在同一仓库中。 - -这个仓库的组织方式是: - -- `main` 是最小但完整的可运行基线,也是当前硬件能力的可执行说明; -- `components/bsp` 隔离板级差异,为应用提供稳定 API; -- `demo/*` 分支展示从需求到成品的不同实现路径; -- `AGENTS.md` 约束 agent 的仓库操作,`docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md` 提供完整硬件上下文和故障知识; -- 构建结果与真机结果分开记录,禁止把“编译通过”描述成“硬件验证通过”。 - -理想的使用方式是:把仓库和一句应用需求交给 agent。agent 先从这里识别能力与限制,再选择相关示例、实现、构建,并给出可在真机上执行的验收清单。 - -## 给 AI agent 的入口 - -开始开发前,按以下顺序建立上下文: - -1. 阅读 `AGENTS.md`、本 README 和 [`docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md`](docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md)。 -2. 执行 `git status --short --branch`,保留用户已有改动。 -3. 阅读需求会触及的 `components/bsp/include/*.h` 及其实现,不根据芯片或开发板的常见配置猜测本板行为。 -4. 用 `git branch -r --list 'origin/demo/*'` 查找接近需求的示例,只复用相关设计,不默认合并整个示例分支。 -5. 将需求拆成输入、输出、状态、并发任务、持久化、内存预算和失败降级,再决定修改 `main` 还是扩展 `components/bsp`。 -6. 完成最低构建检查和适用的逻辑测试;所有依赖屏幕、按键、音频、电池或时序的结论均保留真机验收项。 - -### 事实来源优先级 - -发生冲突时,使用以下优先级: - -```text -原理图 / PCB / 板卡版本 / 实机测量 - > components/bsp/include/bsp_pins.h - > BSP 公开头文件与实现 - > docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md - > README 与示例应用 -``` - -当前仓库尚未包含原理图和 PCB 源文件。遇到板卡版本、接线、极性、寄存器或未使用 GPIO 等未知信息时,agent 应明确报告未知项并请求证据,不能用其他 ESP32-C3 开发板的参数补全答案。 - -## 硬件能力契约 - -下表描述的是当前 `main` 已提供的应用能力,而不是芯片数据手册中所有可能的能力。 - -| 能力 | 已确认实现 | 应用接口 | 必须遵守的边界 | -| --- | --- | --- | --- | -| 显示 | ST7789P3,240 × 320,竖屏 RGB565,SPI2 40 MHz;LEDC 背光 | `bsp_display_*`、`bsp_lvgl_*` | ESP32-C3 无 PSRAM;当前为小型单 DMA 缓冲;没有 LCD MISO、触摸或已知 TE 接口 | -| 输入 | `UP` / `DOWN` / `OK` 三键,共用 GPIO0 的 ADC 电阻分压 | `bsp_button_init()`、`bsp_button_read_mv()` | 回调运行在 button 组件任务中,不能阻塞;不能再创建第二个 ADC1 unit | -| 音频 | ES8311,I2S0 全双工 PCM,可播放和麦克风录音 | `bsp_audio_*` | PCM 读写为阻塞调用,应放工作任务;格式切换必须保留 BSP 内的 close/open 流程 | -| 电池 | CW2017 的 SOC 与电压读取 | `bsp_battery_*` | 是可缺省能力;读数精度取决于电芯与 profile,不能等同于已标定结果 | -| Wi-Fi | 按需启动的 2.4 GHz STA 扫描示例 | `main/demo_wifi.c` | 只扫描,不连接、不保存凭据,也不代表天线/射频性能已验证 | -| Bluetooth LE | 按需启动 NimBLE,以 `FoloPassport` 做不可连接广播 | `main/demo_ble.c` | ESP32-C3 不支持经典蓝牙;距离、共存和功耗需实机测量 | -| 低功耗 | 两秒 light sleep 和五秒 deep sleep,均由 RTC timer 唤醒 | `main/demo_low_power.c` | deep sleep 会重启应用;外部/按键唤醒和板级功耗仍未验证 | -| 共享总线 | ES8311 与 CW2017 共用 I2C0 | `bsp_i2c_*` | 所有设备复用 BSP 持有的总线;不能为扫描或新设备再创建同端口总线 | -| 日志与烧录 | ESP32-C3 原生 USB Serial/JTAG | ESP-IDF console | GPIO18/19 保留给 USB;UART0 默认 TX GPIO21 与背光冲突 | - -所有引脚、地址、面板参数和按键电压窗口只在 [`components/bsp/include/bsp_pins.h`](components/bsp/include/bsp_pins.h) 定义。应用代码不得复制这些常量。完整引脚表、面板初始化、ADC 阈值、I2C 地址规则、音频时钟和内存说明见 [AI 硬件开发指南](docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md)。 - -应用也可以使用 ESP-IDF 提供的定时器、FreeRTOS 任务和内部 Flash/NVS;番茄钟分支提供了 NVS 示例。Wi-Fi 和 Bluetooth LE 仍是 ESP-IDF 应用服务,不是 BSP API:它们的菜单页只在打开期间初始化栈,退出时释放。`demo/claude-buddy-port` 仍可作为更完整的 BLE 应用架构参考,但不能替代对当前板卡天线、射频表现、功耗和共存行为的实测。所有 FoloToy AI Passport 均配备 8 MB Flash,默认使用 3 MB factory app 分区。 - -### 不属于当前能力契约的事项 - -仓库目前没有足够证据保证以下能力:触摸、屏幕读回、IMU、外部存储、充电控制、USB 插拔检测、可控功放使能、外部/按键 deep-sleep 唤醒、任意“空闲 GPIO”、电池精确容量或量产级电源指标。ESP32-C3 芯片具备某项功能,不代表这块板已经接出、供电正确或经过验证。 - -需要这些能力时,先补充原理图、板卡修订号、器件资料或实测结果,再扩展 BSP 和验收项。 - -## 用一句需求开始开发 - -简单需求可以直接这样交给 agent: - -```text -请基于 main 分支为 FoloToy AI Passport 开发一个离线习惯打卡应用。 -使用三个实体按键和 240×320 屏幕,记录保存在掉电不丢失的存储中。 -遵守 AGENTS.md 和 AI_HARDWARE_DEVELOPMENT_GUIDE.md;先查找相关 demo 分支, -保持硬件逻辑在 components/bsp、应用逻辑在 main,完成可运行实现与测试, -最后分别报告构建结果、未执行的真机项目和逐项验收方法。 -``` - -需求越具体,agent 越容易一次实现正确。建议说明: - -- 用户流程:每个页面显示什么,三个按键的短按、双击、长按分别做什么; -- 状态与数据:是否计时、断电保存、联网、录音或与电脑通信; -- 体验目标:字体、颜色、动画、声音、响应时间和异常状态; -- 限制条件:是否允许替换主菜单、增加依赖、使用 Flash 或改变默认交互; -- 验收标准:哪些行为必须自动测试,哪些必须在真实硬件观察。 - -若需求没有给出所有细节,agent 可以在不改变产品方向的范围内采用保守默认值,但应在交付中列出这些假设。涉及新接线、电源安全、硬件版本或不可恢复数据格式的决定必须先确认。 - -## 示例分支是设计案例,不是功能堆叠 - -每个 `demo/*` 分支都从基线演化出一个独立应用。它们的价值是展示具体问题的实现方式;新应用通常应从 `main` 建分支,按需参考,而不是把多个 demo 整体合并。 - -| 分支 | 展示的应用 | 值得复用的模式 | -| --- | --- | --- | -| `demo/stopwatch` | 秒表 | 最小计时应用、纯逻辑与 LVGL 分离、主机逻辑测试 | -| `demo/cat-themed-pomodoro-timer` | 猫咪养成番茄钟 | 单调时钟、暂停/恢复、NVS 持久化、较完整的 PRD 与状态模型 | -| `demo/rock-paper-scissors` | 石头剪刀布 | RGB565 图片资产、素材生成脚本、Flash 资源权衡 | -| `demo/tetris-game` | 三键俄罗斯方块 | 实时游戏循环、低延迟 `PRESS` 输入、局部刷新、纯游戏模型、音效与麦克风交互 | -| `demo/claude-buddy-port` | 桌面 AI 硬件伴侣 | 用完整应用替换 demo 菜单、加密 BLE、协议解析、状态归约、任务通信和较完整的主机测试 | - -查看示例而不切换当前工作区: - -```bash -git branch -r --list 'origin/demo/*' -git diff main...origin/demo/tetris-game -- main components tests -git show origin/demo/tetris-game:main/demo_tetris.c -``` - -开始新应用: - -```bash -git switch main -git switch -c feature/my-passport-app -``` - -示例分支之间可能改变了同一菜单、配置或驱动。agent 应先理解差异,再提取状态模型、资源流水线或并发模式;不能因为代码曾出现在示例分支,就把它当成当前 `main` 的 BSP 保证。 - -## 应用与 BSP 的边界 - -```text -自然语言需求 - └─ main/ 页面、状态机、动画、业务任务、应用资源 - └─ components/bsp/include/ 稳定的板级 API - └─ components/bsp/src/ GPIO、总线、器件和驱动细节 - └─ bsp_pins.h 引脚与硬件参数的单一事实来源 -``` - -新增普通页面时,创建 `main/demo_.c` 并实现 `enter`、`exit`、`key` 接口,然后同步修改: - -- `main/demo.h` 中的声明; -- `main/CMakeLists.txt` 中的源文件; -- `main/main.c` 的 `DEMOS[]` 注册; -- 若有新的可选外设,菜单的初始化状态与失败降级。 - -只有多个应用都会使用的硬件能力才进入 `components/bsp`。BSP API 需要说明阻塞性、线程上下文、内存所有权、失败值和初始化顺序;引脚或 I2C 地址只能加入 `bsp_pins.h`。 - -### 运行时不可破坏的规则 - -- LVGL 不是线程安全的;非 LVGL 上下文操作 `lv_*` 对象必须持有 `bsp_lvgl_lock()`。 -- 按键回调只派发轻量事件;录音、播放、存储和其他慢操作放到工作任务。 -- 页面退出时先停止可能访问 UI 的任务或定时器,再删除 screen 并清空对象指针。 -- 全局交互默认是菜单中 `UP`/`DOWN` 导航、`OK` 单击进入、页面中 `OK` 长按返回;改动时要明确说明。 -- 新图片、字体、网络栈、音频缓存、LVGL buffer 或任务栈都要评估内部 RAM;总空闲堆足够不代表存在足够大的连续内存块。 -- 可测试的状态机、协议、计时和布局计算应与 ESP-IDF/LVGL 分离,优先加入主机逻辑测试。 - -## 构建与运行基线 - -项目使用 ESP-IDF 5.5.x,已知环境为 5.5.3: - -```bash -get_idf553 # 维护者本机快捷命令 -# 或 source "$HOME/esp/esp-idf-v5.5.3/export.sh"(示例安装路径) -idf.py set-target esp32c3 # 新 checkout 或曾配置其他目标时执行 -idf.py build -idf.py flash monitor -``` - -首次构建会通过 ESP-IDF Component Manager 获取 LVGL、`esp_lvgl_port`、`button` 和 `esp_codec_dev` 等依赖。不要直接修改生成的 `managed_components/`。配置陈旧时可以使用 `idf.py fullclean` 后重新配置,但不要用它清理用户源码改动。 - -当前基线的纯逻辑测试可独立运行: - -```bash -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 -``` - -不同示例分支可能提供自己的 host test 命令,应以该分支 README 为准。 - -## 验收与交付格式 - -`idf.py build` 是最低自动检查,不是硬件验收。涉及实体外设的改动,至少在 FoloToy AI Passport 上记录: - -- USB Serial/JTAG 有稳定启动日志,无重启循环、assert 或 watchdog; -- 显示方向、颜色、边缘、刷新与背光正确; -- `UP` / `DOWN` / `OK` 的目标事件和长按返回正确; -- 音频采样速度、播放、非零录音和页面退出正确; -- 电池读数合理,CW2017 缺失时应用能安全降级; -- Wi-Fi 重新扫描可完成,手机 BLE 扫描器可看到广播,两页可反复进出; -- Low Power 页可用 `UP` / `DOWN` 选择 light 或 deep sleep,`OK` 执行;light sleep 约两秒后被 timer 唤醒并恢复背光;deep sleep 约五秒后重启,再进入页面可见 RTC 保留的唤醒计数; -- 重复进出页面和并发操作后没有任务、对象或堆持续泄漏。 - -agent 的最终交付应明确区分: - -```text -Build: PASS / FAIL / NOT RUN -Host tests: PASS / FAIL / NOT RUN -Device tests: PASS / FAIL / NOT RUN -Unverified: 仍需板卡、仪器或用户确认的事项 -``` - -按引脚、LCD、ADC、codec、I2C、DMA 等修改类型展开的验收矩阵和故障速查表见 [AI 硬件开发指南](docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md)。 - -## 项目结构 - -```text -components/bsp/include/ BSP 公开 API 与 bsp_pins.h 硬件事实 -components/bsp/src/ 显示、按键、音频、电池、共享 I2C 实现 -main/ 最小菜单、LVGL UI 与独立硬件演示页 -tests/ 可脱离硬件运行的轻量逻辑测试源 -docs/ agent 硬件开发指南与扩展文档 -sdkconfig.defaults ESP32-C3、USB console、Flash、LVGL 默认配置 -partitions.csv NVS、PHY data 和 3 MB factory app 分区布局 -AGENTS.md agent 在本仓库的编码、验证和提交规则 -``` diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..8025a26 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,54 @@ +

+ 简体中文 · English +

+ +# Security Policy + +Do not disclose unpatched security vulnerabilities, credentials, tokens, or +directly exploitable details in public issues, pull requests, discussions, or +chat. + +## Reporting a vulnerability + +The preferred channel is GitHub's private vulnerability reporting form: + + + +If that form is unavailable, open a public issue containing only a request for a +private security contact. Do not include vulnerability details or reproduction +materials in that issue; wait for a maintainer to provide a private channel. + +## What to include + +Please provide as much of the following as possible: + +- affected version, commit, or distribution channel; +- affected board, component, and configuration; +- reproduction steps, a minimal PoC, or logs, after removing credentials and + personal data; +- potential impact, exploitation requirements, and any suggested mitigation. + +This repository contains firmware for a wearable AI device. Security issues may +involve the ESP32-C3 firmware, the audio input, wireless capabilities, or +protocol handling. If the issue also involves a separately maintained server or +service, identify the affected endpoint and client version so that we can route +it to the appropriate maintainers. + +## Response process + +We will acknowledge the report, reproduce it, assess its impact, and update the +report when a fix or mitigation can be disclosed. Our target cadence: +**acknowledgement with an initial assessment within 5 business days**, and a +**90-day coordinated disclosure window** for confirmed vulnerabilities +(adjustable in coordination with the reporter). If you hear nothing for more +than 7 days, please ping us through the other channel (email or GitHub). + +## Contributor notes + +- Do not put real user data, access tokens, private keys, or internal endpoints + in issues, test fixtures, or commits. +- If you accidentally commit sensitive information, report it privately + immediately. Deleting the file from the working tree does not invalidate + secrets that may exist in Git history. +- Use public issues for ordinary bugs, documentation problems, and feature + requests. Do not use the security channel for those topics. diff --git a/SECURITY.zh_CN.md b/SECURITY.zh_CN.md new file mode 100644 index 0000000..2d32ab1 --- /dev/null +++ b/SECURITY.zh_CN.md @@ -0,0 +1,43 @@ +

+ 简体中文 · English +

+ +# 安全漏洞报告 + +请不要在公开 issue、Pull Request、讨论区或聊天中披露未修复的安全漏洞、凭证、令牌或 +可直接利用的详细信息。 + +## 报告渠道 + +首选 GitHub 的私密漏洞报告入口: + + + +如果该入口对你不可用,请提交一个公开 issue,但只请求维护者提供私密安全联系方式, +不要写入漏洞细节或复现材料;等待维护者提供私密渠道后再继续报告。 + +## 报告内容 + +请尽量提供: + +- 受影响的版本、commit 或发布渠道; +- 受影响的板卡、组件和配置; +- 可复现步骤、最小化 PoC 或日志(请先删除凭证和个人数据); +- 潜在影响、利用条件和建议的修复方向。 + +本仓库包含可穿戴 AI 设备的固件。安全问题可能涉及 ESP32-C3 固件、音频输入、无线 +能力或协议处理。如果问题同时涉及独立维护的服务器或服务,请说明受影响的端点和客户端 +版本,便于我们转交给对应的维护者。 + +## 处理方式 + +我们会在收到报告后进行确认、复现和影响评估,并在修复或缓解措施可公开时更新报告。 +目标响应节奏:**5 个工作日内确认收到并给出初步判断**;确认为有效漏洞后,我们按 +**90 天协调披露窗口**推进修复与公开(可与报告者协商调整)。如果超过 7 天没有收到 +任何回复,请通过另一渠道(邮件或 GitHub)提醒我们。 + +## 贡献者注意事项 + +- 不要把真实用户数据、访问令牌、私钥或内部 endpoint 写入 issue、测试夹具或提交。 +- 如果你误提交了敏感信息,请立即私下报告;仅删除工作区文件不能保证 Git 历史中的秘密已失效。 +- 普通缺陷、文档问题和功能请求请使用公开 issue,不要占用安全披露渠道。 diff --git a/SUPPORT.md b/SUPPORT.md new file mode 100644 index 0000000..bb50df1 --- /dev/null +++ b/SUPPORT.md @@ -0,0 +1,28 @@ +

+ 简体中文 · English +

+ +# Support + +FoloToy AI Passport is open-source hardware and firmware. The community can help +confirm reproducible issues and discuss improvements, but one-to-one +troubleshooting for every custom hardware setup or commercial support is not +guaranteed. + +## Where to start + +- Hardware facts, wiring, and known traps: read + [`README.md`](docs/README.md) and the + [AI Hardware Development Guide](docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md). +- AI agent workflow and engineering rules: read + [`AGENTS.md`](AGENTS.md) and its rule index. +- Security vulnerabilities, credentials, or exploitable details: follow + [`SECURITY.md`](SECURITY.md) and report privately. +- Ordinary bugs: open a GitHub issue with the board revision, firmware version, + and reproduction steps. +- Feature requests: use the feature request template and describe the use case + and expected outcome. +- Usage questions: open an issue with the usage question template. + +Do not post real user data, access tokens, private keys, or internal addresses +in public issues, discussions, or logs. diff --git a/SUPPORT.zh_CN.md b/SUPPORT.zh_CN.md new file mode 100644 index 0000000..998513b --- /dev/null +++ b/SUPPORT.zh_CN.md @@ -0,0 +1,20 @@ +

+ 简体中文 · English +

+ +# 使用支持 + +FoloToy AI Passport 是开源硬件与固件。社区可以帮助确认可复现的问题和改进方向, +但不承诺为每个自定义硬件环境提供一对一排障或商业服务支持。 + +## 先查什么 + +- 硬件事实、接线和已知陷阱:先看 [`README.zh_CN.md`](docs/README.zh_CN.md) 和 + [AI 硬件开发指南](docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md)。 +- AI agent 工作流和工程规则:先看 [`AGENTS.md`](AGENTS.md) 及其规则索引。 +- 安全漏洞、凭证或可利用细节:按照 [`SECURITY.md`](SECURITY.md) 私下报告。 +- 普通 Bug:提交 GitHub issue,并提供板卡版本、固件版本和复现步骤。 +- 功能建议:提交 feature request,说明使用场景和期望结果。 +- 使用问题:用「Usage question / 使用问题」issue 模板提问。 + +请不要在公开 issue、讨论或日志中提交真实用户数据、访问令牌、私钥或内部地址。 diff --git a/assets/README.md b/assets/README.md new file mode 100644 index 0000000..31a167d --- /dev/null +++ b/assets/README.md @@ -0,0 +1,16 @@ +# 资源目录(Assets) + +本目录集中存放可复用的资源(字库、图片、音乐等),按资源类型分子目录管理。每个子目录都有一份独立的 `README.md`,说明资源的使用方法。 + +## 子目录 + +- [`fonts/`](fonts/README.md):字库资源。 +- [`images/`](images/README.md):图片资源。 +- [`music/`](music/README.md):音乐/音效资源。 + +## 通用约定 + +- 每个资源放在其类型对应的独立子目录,并在该子目录内新建/维护 `README.md`。 +- 资源若可直接复制到项目工程中使用,应说明其放置路径、命名规则与引用方式。 +- 二进制资源(字体、图片、音频)不属于纯 markdown 文档,请勿与文档混放。 +- 涉及版权/授权的资源需在其 `README.md` 中注明来源与许可。 diff --git a/assets/fonts/README.md b/assets/fonts/README.md new file mode 100644 index 0000000..2c6f506 --- /dev/null +++ b/assets/fonts/README.md @@ -0,0 +1,13 @@ +# 字库资源(Fonts) + +本目录存放项目可复用的字库资源。每个字库子目录或单个字库文件,应附说明。 + +## 如何使用 + +- 字库文件(如 `.ttf`、`.otf`、LVGL 使用的 C 数组字库等)复制到本目录,并在本项目 `README.md` 记录字名、字号、支持字符集与版权信息。 +- 若需集成到 ESP-IDF 固件,参考 [`components/bsp/include/bsp_display.h`](../../components/bsp/include/bsp_display.h) 与 LVGL 字体接口,将字库转换为对应格式并放入正确资源目录。 +- 字库占用 Flash 与内存,需在集成前评估 ESP32-C3 无 PSRAM 的限制(详见 `docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md`)。 + +## 目录说明 + +> 当前为空骨架,用于存放后续加入的字库资源。加入资源时请同步更新本 `README.md` 的索引。 diff --git a/assets/images/README.md b/assets/images/README.md new file mode 100644 index 0000000..18cb35f --- /dev/null +++ b/assets/images/README.md @@ -0,0 +1,13 @@ +# 图片资源(Images) + +本目录存放项目可复用的图片资源,如 UI 图标、背景、RGB565 资源等。 + +## 如何使用 + +- 图片文件复制到本目录,并在本项目 `README.md` 记录分辨率、格式、用途与来源。 +- 与固件集成时,参考 [`components/bsp/include/bsp_display.h`](../../components/bsp/include/bsp_display.h) 与相关示例分支的图片资源管线,转换为固件所需格式(如 RGB565 数组)。 +- 图片资源占用 Flash 与内存,集成前请评估 ESP32-C3 无 PSRAM 的限制。 + +## 目录说明 + +> 当前为空骨架,用于存放后续加入的图片资源。加入资源时请同步更新本 `README.md` 的索引。 diff --git a/assets/music/README.md b/assets/music/README.md new file mode 100644 index 0000000..dddfd0b --- /dev/null +++ b/assets/music/README.md @@ -0,0 +1,13 @@ +# 音乐/音效资源(Music / Sound Effects) + +本目录存放项目可复用的音乐与音效资源。 + +## 如何使用 + +- 音频文件(如 `.wav`、`.mp3`、固件可用的编码格式)复制到本目录,并在本项目 `README.md` 记录采样率、时长、用途与来源。 +- 与固件集成时,参考 [`components/bsp/include/bsp_audio.h`](../../components/bsp/include/bsp_audio.h) 音频接口,确认播放路径、任务上下文与内存占用。 +- 音频文件占用 Flash 与内存,集成前请评估 ESP32-C3 无 PSRAM 的限制。 + +## 目录说明 + +> 当前为空骨架,用于存放后续加入的音乐/音效资源。加入资源时请同步更新本 `README.md` 的索引。 diff --git a/docs/INDEX.md b/docs/INDEX.md new file mode 100644 index 0000000..32c0d99 --- /dev/null +++ b/docs/INDEX.md @@ -0,0 +1,32 @@ +# Docs 规范索引 + +本索引用于发现 `docs/` 下的全部文档:协作规范、工程规范、fork 工作流、软硬件设计文档。 + +**状态含义**:`authoritative` = 权威、对开发与协作有约束力;`参考` = 设计 / 记录 / 骨架,供背景参考。 + +| 文档 | 类型 | 状态 | 说明 | +| --- | --- | --- | --- | +| [brand-and-product.md](./brand-and-product.md) | 品牌与产品说明 | authoritative | 品牌与产品定位、官方入口、开源与授权、产品规格引用 | +| [contribution/README.md](./contribution/README.md) | 协作规范索引 | authoritative | 通用协作规范(文档规范、提交与 PR 约定) | +| [contribution/doc-conventions.md](./contribution/doc-conventions.md) | 文档规范 | authoritative | 先读所有 README、文档生成规范、文档分类规范(公共/特定项目) | +| [contribution/commit-and-pr.md](./contribution/commit-and-pr.md) | 协作规范 | authoritative | 提交规范 + 提交与 PR 约定 | +| [development/README.md](./development/README.md) | 工程规范索引 | authoritative | 通用工程开发规范(构建验证、代码约定) | +| [development/build-and-test.md](./development/build-and-test.md) | 工程规范 | authoritative | 构建与验证(ESP-IDF 命令、逻辑测试、改动验证要求) | +| [development/coding-conventions.md](./development/coding-conventions.md) | 工程规范 | authoritative | 代码约定(语言风格、复用、注释、测试同步、资源约束) | +| [development/agent-guide.md](./development/agent-guide.md) | 工程规范 | authoritative | AI 开发工作流(上下文建立、需求拆解、BSP 边界、验收交付格式) | +| [development/CI-build-and-release.md](./development/CI-build-and-release.md) | CI 文档 | authoritative | 自动构建与发布说明(tag 触发自动编译固件并发布 Release) | +| [development/CI-sync-main.md](./development/CI-sync-main.md) | CI 文档 | authoritative | 上游同步说明(定期同步上游 main 到 fork) | +| [fork-guide.md](./fork-guide.md) | fork 工作流 | authoritative | 目录结构、main 保持干净、fork 约定、docs/assets 使用 | +| [software-design/README.md](./software-design/README.md) | 软件设计索引 | 参考 | 软件设计文档子目录骨架 | +| [hardware-design/README.md](./hardware-design/README.md) | 硬件设计索引 | 参考 | 硬件设计文档子目录骨架 | +| [hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md](./hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md) | 硬件指南 | authoritative | 完整硬件开发指南与排障参考(上游) | +| [hardware-design/specifications.md](./hardware-design/specifications.md) | 产品规格 | authoritative | 产品规格(尺寸、重量、电池、充电、NFC、按键等对外口径) | + +## 仓库根治理文档 + +以下社区治理文档位于仓库根目录(GitHub 自动识别): + +- [CONTRIBUTING.md](../CONTRIBUTING.md):贡献指南(开发验证、PR 流程、许可)。 +- [CODE_OF_CONDUCT.md](../CODE_OF_CONDUCT.md):贡献者公约行为准则。 +- [SECURITY.md](../SECURITY.md):安全漏洞报告流程。 +- [SUPPORT.md](../SUPPORT.md):使用支持与问题反馈渠道。 diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..4644813 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,119 @@ +# FoloToy AI Passport + +English | [简体中文](README.zh_CN.md) + +FoloToy AI Passport is open wearable AI hardware. This repository is the development baseline for the device. It keeps the **hardware facts, stable interfaces, resource boundaries, reference implementations, and validation methods** needed to build applications in one place. + +The repository is organized around the following principles: + +- `main` is the smallest complete runnable baseline and an executable description of the current hardware capabilities. +- `components/bsp` isolates board-level details and exposes stable APIs to applications. +- `demo/*` branches show different paths from a product requirement to a working implementation. +- Development conventions for AI assistants live in [`AGENTS.md`](../AGENTS.md) and [`docs/development/agent-guide.md`](development/agent-guide.md); the complete hardware context and troubleshooting knowledge is in [`docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md`](hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md). +- Build results and physical-device results are reported separately. A successful build must never be presented as successful hardware validation. + +## Hardware capability contract + +The table below describes the application capabilities implemented by the current `main` branch. It is not a list of everything that might be possible according to the chip datasheet. + +| Capability | Confirmed implementation | Application interface | Boundaries that must be respected | +| --- | --- | --- | --- | +| Display | ST7789P3, 240 × 320 portrait RGB565, SPI2 at 40 MHz; LEDC backlight | `bsp_display_*`, `bsp_lvgl_*` | The ESP32-C3 has no PSRAM; the current design uses a small single DMA buffer; no LCD MISO, touch, or known TE interface | +| Input | `UP`, `DOWN`, and `OK` share an ADC resistor ladder on GPIO0 | `bsp_button_init()`, `bsp_button_read_mv()` | Callbacks run in the button component task and must not block; do not create a second ADC1 unit | +| Audio | ES8311 with full-duplex PCM over I2S0, supporting playback and microphone capture | `bsp_audio_*` | PCM reads and writes block and belong in a worker task; format changes must retain the BSP close/open sequence | +| Battery | CW2017 state-of-charge and voltage readings | `bsp_battery_*` | This capability is optional at runtime; accuracy depends on the cell and battery profile and is not equivalent to a calibrated result | +| Wi-Fi | On-demand 2.4 GHz STA scan demo | `main/demo_wifi.c` | Scans only; it does not connect, store credentials, or validate antenna/RF performance | +| Bluetooth LE | On-demand non-connectable NimBLE advertising as `FoloPassport` | `main/demo_ble.c` | ESP32-C3 does not support Bluetooth Classic; radio range, coexistence, and power draw require device measurements | +| Low power | Two-second light sleep and five-second deep sleep, both with RTC timer wakeup | `main/demo_low_power.c` | Deep sleep restarts the application; external/button wakeup and board-level power consumption remain unverified | +| Shared bus | ES8311 and CW2017 share I2C0 | `bsp_i2c_*` | Every device must reuse the bus owned by the BSP; do not create another bus on the same port for scanning or a new device | +| Logging and flashing | Native ESP32-C3 USB Serial/JTAG | ESP-IDF console | GPIO18/19 are reserved for USB; the default UART0 TX on GPIO21 conflicts with the backlight | + +All pins, addresses, panel parameters, and button voltage windows are defined only in [`components/bsp/include/bsp_pins.h`](../components/bsp/include/bsp_pins.h). Application code must not duplicate these constants. See the [AI Hardware Development Guide](hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md) for the complete pin map, panel initialization, ADC thresholds, I2C addressing rules, audio clocks, and memory details. + +Applications may also use ESP-IDF timers, FreeRTOS tasks, and internal Flash/NVS; the Pomodoro branch contains an NVS example. Wi-Fi and Bluetooth LE remain ESP-IDF application services rather than BSP APIs: their menu pages initialize each stack only while open and release it on exit. `demo/claude-buddy-port` remains a fuller BLE application architecture reference, not a substitute for measuring the current board's antenna, RF performance, power consumption, and coexistence behavior. Every FoloToy AI Passport has 8 MB of Flash, and the default firmware configuration targets 8 MB with a 3 MB factory-app partition. + +### Capabilities outside the current contract + +The repository does not currently provide enough evidence to guarantee touch input, display readback, an IMU, external storage, charging control, USB insertion detection, controllable power-amplifier enable, external/button deep-sleep wakeup, arbitrary “free GPIOs,” exact battery capacity, or production-grade power specifications. A capability being present in the ESP32-C3 silicon does not mean that it is connected, powered correctly, or validated on this board. + +Requirements involving these capabilities must begin with a schematic, board revision, component documentation, or physical measurements. Only then should the BSP and its acceptance criteria be extended. + +## Start development with one requirement + +A simple request can be given directly to an AI assistant: + +```text +On the main branch, build an offline habit-tracking application for FoloToy AI Passport. +Use the three physical buttons and the 240×320 display, and preserve records across power loss. +Follow AGENTS.md and docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md. Inspect relevant demo branches first, +keep hardware logic in components/bsp and application logic in main, deliver a runnable +implementation with tests, and report the build result, unexecuted device checks, and exact +on-device acceptance steps separately. +``` + +The more specific the requirement, the more likely the assistant is to implement it correctly in one pass. Useful details include: + +- User flow: what each page displays and what short press, double press, and long press do for each button. +- State and data: whether the application needs timing, persistence across power loss, networking, recording, or communication with a computer. +- Experience goals: fonts, colors, animation, sound, response time, and error states. +- Constraints: whether the main menu may be replaced, dependencies added, Flash used, or default interactions changed. +- Acceptance criteria: which behaviors require automated tests and which must be observed on real hardware. + +When details are omitted, the assistant may choose conservative defaults that do not change the product direction, but it must list those assumptions in the delivery. Decisions involving new wiring, electrical safety, board revisions, or irreversible data formats require confirmation first. + +## Demo branches are design cases, not a feature pile + +Each `demo/*` branch evolves the baseline into an independent application. The branches demonstrate how specific problems were solved. New applications should normally branch from `main` and consult relevant examples instead of merging multiple demos wholesale. + +| Branch | Application | Patterns worth reusing | +| --- | --- | --- | +| `demo/stopwatch` | Stopwatch | Minimal timer application, separation of pure logic from LVGL, host-side logic tests | +| `demo/cat-themed-pomodoro-timer` | Cat-themed Pomodoro timer | Monotonic time, pause/resume, NVS persistence, a detailed PRD, and a state model | +| `demo/rock-paper-scissors` | Rock paper scissors | RGB565 image assets, asset-generation scripts, and Flash resource tradeoffs | +| `demo/tetris-game` | Three-button Tetris | Real-time game loop, low-latency `PRESS` input, partial refresh, a pure game model, audio, and microphone interaction | +| `demo/claude-buddy-port` | Desktop AI hardware companion | Replacing the demo menu with a complete application, encrypted BLE, protocol parsing, state reduction, task communication, and extensive host tests | + +Inspect an example without switching the current working tree: + +```bash +git branch -r --list 'origin/demo/*' +git diff main...origin/demo/tetris-game -- main components tests +git show origin/demo/tetris-game:main/demo_tetris.c +``` + +Start a new application: + +```bash +git switch main +git switch -c feature/my-passport-app +``` + +Example branches may change the same menu, configuration, or driver in incompatible ways. Understand the differences before extracting a state model, asset pipeline, or concurrency pattern. Code appearing in an example branch is not automatically part of the current `main` BSP contract. + +## Project structure + +```text +components/bsp/include/ Public BSP APIs and bsp_pins.h hardware facts +components/bsp/src/ Display, button, audio, battery, and shared-I2C implementations +main/ Minimal menu, LVGL UI, and independent hardware demo pages +tests/ Lightweight logic tests that can run without hardware +docs/ Engineering/contribution conventions, design docs, CI docs, and READMEs (README.md / README.zh_CN.md / INDEX.md) +.github/workflows/ CI workflows (build-firmware.yml, sync-main.yml) +sdkconfig.defaults ESP32-C3, USB console, Flash, and LVGL defaults +partitions.csv NVS, PHY data, and 3 MB factory application layout +AGENTS.md Coding, validation, and contribution rules for agents +CONTRIBUTING.md Contribution guide +CODE_OF_CONDUCT.md Code of conduct +SECURITY.md Security vulnerability reporting +SUPPORT.md Support channels +``` + +## Documentation + +- [`docs/INDEX.md`](INDEX.md) — 全部文档索引(协作规范、工程规范、fork 工作流、软硬件设计)。 +- [`docs/development/agent-guide.md`](development/agent-guide.md) — AI 开发工作流(面向 AI 编程助手:上下文建立、事实来源优先级、BSP 边界、运行时规则、交付格式)。 +- [`docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md`](hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md) — 硬件开发指南(引脚表、验收矩阵、故障速查)。 +- [`AGENTS.md`](../AGENTS.md) — AI 协作规范入口。 +- [`docs/fork-guide.md`](fork-guide.md) — fork 工作流。 + +> 注:本 README 只描述产品与仓库,不含给 AI 的执行说明;AI 开始开发前请先读 `docs/development/agent-guide.md`。 diff --git a/docs/README.zh_CN.md b/docs/README.zh_CN.md new file mode 100644 index 0000000..e83e2c4 --- /dev/null +++ b/docs/README.zh_CN.md @@ -0,0 +1,118 @@ +# FoloToy AI Passport + +[English](README.md) | 简体中文 + +FoloToy AI Passport 是一个开放式可穿戴 AI 硬件,本仓库是这款 AI 硬件的开发基线。它不只展示"板子能运行什么",还把开发应用所需的**硬件事实、稳定接口、资源边界、参考实现和验收方法**放在同一仓库中。 + +这个仓库的组织方式是: + +- `main` 是最小但完整的可运行基线,也是当前硬件能力的可执行说明; +- `components/bsp` 隔离板级差异,为应用提供稳定 API; +- `demo/*` 分支展示从需求到成品的不同实现路径; +- AI 开发约定见 [`AGENTS.md`](../AGENTS.md) 与 [`docs/development/agent-guide.md`](development/agent-guide.md);完整硬件上下文和故障知识见 [`docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md`](hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md); +- 构建结果与真机结果分开记录,禁止把"编译通过"描述成"硬件验证通过"。 + +## 硬件能力契约 + +下表描述的是当前 `main` 已提供的应用能力,而不是芯片数据手册中所有可能的能力。 + +| 能力 | 已确认实现 | 应用接口 | 必须遵守的边界 | +| --- | --- | --- | --- | +| 显示 | ST7789P3,240 × 320,竖屏 RGB565,SPI2 40 MHz;LEDC 背光 | `bsp_display_*`、`bsp_lvgl_*` | ESP32-C3 无 PSRAM;当前为小型单 DMA 缓冲;没有 LCD MISO、触摸或已知 TE 接口 | +| 输入 | `UP` / `DOWN` / `OK` 三键,共用 GPIO0 的 ADC 电阻分压 | `bsp_button_init()`、`bsp_button_read_mv()` | 回调运行在 button 组件任务中,不能阻塞;不能再创建第二个 ADC1 unit | +| 音频 | ES8311,I2S0 全双工 PCM,可播放和麦克风录音 | `bsp_audio_*` | PCM 读写为阻塞调用,应放工作任务;格式切换必须保留 BSP 内的 close/open 流程 | +| 电池 | CW2017 的 SOC 与电压读取 | `bsp_battery_*` | 是可缺省能力;读数精度取决于电芯与 profile,不能等同于已标定结果 | +| Wi-Fi | 按需 2.4 GHz STA 扫描 demo | `main/demo_wifi.c` | 仅扫描;不连接、不存凭证、不验证天线/射频表现 | +| Bluetooth LE | 按需以 `FoloPassport` 名义做不可连接的 NimBLE 广播 | `main/demo_ble.c` | ESP32-C3 不支持蓝牙经典;射频范围、共存与功耗需实测 | +| 低功耗 | 两秒浅睡眠与五秒深睡眠,均以 RTC 定时器唤醒 | `main/demo_low_power.c` | 深睡眠会重启应用;外部/按键唤醒与板级功耗仍未验证 | +| 共享总线 | ES8311 与 CW2017 共用 I2C0 | `bsp_i2c_*` | 所有设备复用 BSP 持有的总线;不能为扫描或新设备再创建同端口总线 | +| 日志与烧录 | ESP32-C3 原生 USB Serial/JTAG | ESP-IDF console | GPIO18/19 保留给 USB;UART0 默认 TX GPIO21 与背光冲突 | + +所有引脚、地址、面板参数和按键电压窗口只在 [`components/bsp/include/bsp_pins.h`](../components/bsp/include/bsp_pins.h) 定义。应用代码不得复制这些常量。完整引脚表、面板初始化、ADC 阈值、I2C 地址规则、音频时钟和内存说明见 [AI 硬件开发指南](hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md)。 + +应用也可以使用 ESP-IDF 提供的定时器、FreeRTOS 任务和内部 Flash/NVS;番茄钟分支提供了 NVS 示例。Wi-Fi 和 Bluetooth LE 仍是 ESP-IDF 应用服务而非 BSP API:其菜单页面仅在打开时初始化对应协议栈、退出时释放。`demo/claude-buddy-port` 仍是更完整的 BLE 应用架构参考,不能替代对当前板卡天线、射频表现、功耗和共存行为的实测。所有 FoloToy AI Passport 均配备 8 MB Flash,默认固件配置以 8 MB 为准,含 3 MB factory-app 分区。 + +### 不属于当前能力契约的事项 + +仓库目前没有足够证据保证以下能力:触摸、屏幕读回、IMU、外部存储、充电控制、USB 插拔检测、可控功放使能、外部/按键深度睡眠唤醒、任意"空闲 GPIO"、电池精确容量或量产级电源指标。ESP32-C3 芯片具备某项功能,不代表这块板已经接出、供电正确或经过验证。 + +需要这些能力时,先补充原理图、板卡修订号、器件资料或实测结果,再扩展 BSP 和验收项。 + +## 用一句需求开始开发 + +简单需求可以直接交给 AI 助手: + +```text +请基于 main 分支为 FoloToy AI Passport 开发一个离线习惯打卡应用。 +使用三个实体按键和 240×320 屏幕,记录保存在掉电不丢失的存储中。 +遵守 AGENTS.md 和 docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md;先查找相关 demo 分支, +保持硬件逻辑在 components/bsp、应用逻辑在 main,完成可运行实现与测试, +最后分别报告构建结果、未执行的真机项目和逐项验收方法。 +``` + +需求越具体,AI 助手越容易一次实现正确。建议说明: + +- 用户流程:每个页面显示什么,三个按键的短按、双击、长按分别做什么; +- 状态与数据:是否计时、断电保存、联网、录音或与电脑通信; +- 体验目标:字体、颜色、动画、声音、响应时间和异常状态; +- 限制条件:是否允许替换主菜单、增加依赖、使用 Flash 或改变默认交互; +- 验收标准:哪些行为必须自动测试,哪些必须在真实硬件观察。 + +若需求没有给出所有细节,AI 助手可以在不改变产品方向的范围内采用保守默认值,但应在交付中列出这些假设。涉及新接线、电源安全、硬件版本或不可恢复数据格式的决定必须先确认。 + +## 示例分支是设计案例,不是功能堆叠 + +每个 `demo/*` 分支都从基线演化出一个独立应用。它们的价值是展示具体问题的实现方式;新应用通常应从 `main` 建分支,按需参考,而不是把多个 demo 整体合并。 + +| 分支 | 展示的应用 | 值得复用的模式 | +| --- | --- | --- | +| `demo/stopwatch` | 秒表 | 最小计时应用、纯逻辑与 LVGL 分离、主机逻辑测试 | +| `demo/cat-themed-pomodoro-timer` | 猫咪养成番茄钟 | 单调时钟、暂停/恢复、NVS 持久化、较完整的 PRD 与状态模型 | +| `demo/rock-paper-scissors` | 石头剪刀布 | RGB565 图片资产、素材生成脚本、Flash 资源权衡 | +| `demo/tetris-game` | 三键俄罗斯方块 | 实时游戏循环、低延迟 `PRESS` 输入、局部刷新、纯游戏模型、音效与麦克风交互 | +| `demo/claude-buddy-port` | 桌面 AI 硬件伴侣 | 用完整应用替换 demo 菜单、加密 BLE、协议解析、状态归约、任务通信和较完整的主机测试 | + +查看示例而不切换当前工作区: + +```bash +git branch -r --list 'origin/demo/*' +git diff main...origin/demo/tetris-game -- main components tests +git show origin/demo/tetris-game:main/demo_tetris.c +``` + +开始新应用: + +```bash +git switch main +git switch -c feature/my-passport-app +``` + +示例分支之间可能改变了同一菜单、配置或驱动。应先理解差异,再提取状态模型、资源流水线或并发模式;不能因为代码曾出现在示例分支,就把它当成当前 `main` 的 BSP 保证。 + +## 项目结构 + +```text +components/bsp/include/ BSP 公开 API 与 bsp_pins.h 硬件事实 +components/bsp/src/ 显示、按键、音频、电池、共享 I2C 实现 +main/ 最小菜单、LVGL UI 与独立硬件演示页 +tests/ 可脱离硬件运行的轻量逻辑测试源 +docs/ 工程/协作规范、设计文档、CI 文档与 README(README.md / README.zh_CN.md / INDEX.md) +.github/workflows/ CI 工作流(build-firmware.yml、sync-main.yml) +sdkconfig.defaults ESP32-C3、USB console、Flash、LVGL 默认配置 +partitions.csv NVS、PHY data 与 3 MB factory-app 分区布局 +AGENTS.md agent 在本仓库的编码、验证和提交规则 +CONTRIBUTING.md 贡献指南 +CODE_OF_CONDUCT.md 贡献者公约行为准则 +SECURITY.md 安全漏洞报告 +SUPPORT.md 使用支持渠道 +``` + +## 文档索引 + +- [`docs/INDEX.md`](INDEX.md) — 全部文档索引(协作规范、工程规范、fork 工作流、软硬件设计)。 +- [`docs/development/agent-guide.md`](development/agent-guide.md) — AI 开发工作流(面向 AI 编程助手:上下文建立、事实来源优先级、BSP 边界、运行时规则、交付格式)。 +- [`docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md`](hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md) — 硬件开发指南(引脚表、验收矩阵、故障速查)。 +- [`AGENTS.md`](../AGENTS.md) — AI 协作规范入口。 +- [`docs/fork-guide.md`](fork-guide.md) — fork 工作流。 + +> 注:本 README 只描述产品与仓库,不含给 AI 的执行说明;AI 开始开发前请先读 `docs/development/agent-guide.md`。 diff --git a/docs/assets/.gitkeep b/docs/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/brand-and-product.md b/docs/brand-and-product.md new file mode 100644 index 0000000..57196ea --- /dev/null +++ b/docs/brand-and-product.md @@ -0,0 +1,85 @@ +# 品牌与产品说明(Brand & Product Info) + +> **面向读者**:用户、开发者、AI agent 以及任何想了解 AI Passport 品牌与产品的人 +> **读取时机**:首次接触本产品、需要了解品牌定位 / 产品名称 / 官方入口 / 产品规格,或准备对外引用产品信息之前 +> **关联文档**:设备硬件规格见 [hardware-design/specifications.md](hardware-design/specifications.md);凭证与隐私入仓红线见 [contribution/doc-conventions.md](contribution/doc-conventions.md)。 + +--- + +## 1. 品牌与产品 + +- **产品名**:**AI Passport**(英文全称 *FoloToy AI Passport*,官网英文名 "AI Passport | Open Wearable AI Agent")。 + - 名称统一写 `AI Passport`,不翻译、不加后缀、不派生变体;中文语境同样用「AI Passport」,不另造译名。 +- **品牌主体**:**FoloToy**("We are creating AI toys",创造 AI 玩具)。 + - GitHub 组织:`github.com/FoloToy` +- **产品开源仓库**:`github.com/FoloToy/ai-passport`——AI Passport 的开源**开发基线**,集中存放已确认的硬件事实、稳定接口、资源边界、参考实现与验收方法。 + +## 2. 产品定位 + +AI Passport 是一个**开放式可穿戴 AI 智能体**: + +> 可佩戴、可安装玩法、可由你重新定义的开放式 AI 智能体。 +> *A wearable, open AI agent you can redefine with installable plays.* + +- 英文表述:**Open Wearable AI Agent** +- 中文 slogan:**「一张与 AI Agent 一起开造世界的通行证」** +- 辅助表述:**「简单开放 人人可造」**("Open & simple, made by anyone") +- 核心口号:**WEAR · PLAY · CREATE**(佩戴 / 游玩 / 创造) + +### 三种用法 + +| 用法 | 说明 | +| --- | --- | +| **WEAR(佩戴)** | 出厂即身份卡。经本地 BLE 同步名称、头像、自我介绍与全屏图片,成为"开造世界的 AI 通行证";默认玩法内置一款趣味小游戏 | +| **PLAY(游玩)** | 从官方玩法库选择玩法,在浏览器一键刷入;身份卡功能保留,只替换游戏内容 | +| **CREATE(创造)** | 会写代码就自己做固件;可配合 AI Agent(Codex / Claude Code / TRAE 等)从一句需求开始开发玩法 | + +## 3. 官方入口 + +| 入口 | 地址 | +| --- | --- | +| 产品官网(中文) | `https://ai-passport.folotoy.cn/` | +| 产品官网(英文) | `https://ai-passport.folotoy.cn/en/` | +| 使用指南 | `https://ai-passport.folotoy.cn/guides/` | +| 快速上手 | `https://ai-passport.folotoy.cn/guides/getting-started/` | +| 官方玩法库 | `https://ai-passport.folotoy.cn/plays/`(主页锚点 `/#official-plays`) | +| 浏览器刷机工具 | `https://ai-passport.folotoy.cn/tools/web-flasher/`(产品官网内置入口) | +| **FOLOTOY 通用刷机工具** | `https://tool.folotoy.cn/`(独立站点,浏览器 WebSerial 刷机 + 实时设备日志,固件不上传服务器) | + +### 官方玩法库 + +当前官网展示 13 款官方玩法(编号为玩法 ID,非排序):模块拓展「AI 像素宠物」(060)、多人互动「口袋剪刀石头布」(025)、创意游戏「口袋番茄钟」(044)、创意游戏「答案之书」(008)、日常陪伴「Claude Buddy」(016)、效率工具「口袋秒表」(046)、效率工具「单词熊」(048)、创意游戏「口袋俄罗斯方块」(050)、创意游戏「老板宠物」(061)、多人互动「通行证雷达」(062)、创意游戏「Bad Apple 播放器」(063)、日常陪伴「今天心情怎么样」(064)、创意游戏「牛来互动播放器」(065)。 + +> ⚠️ 玩法列表以官网为准,可能会和实际有差距,以实际为准。 + +### 浏览器刷机工具(两处入口) + +FoloToy 提供两处浏览器刷机入口,均可安全写入本地固件,固件文件不上传服务器: + +- **`https://ai-passport.folotoy.cn/tools/web-flasher/`**:AI Passport 产品官网内置的刷机入口,与产品页 / 玩法安装流程集成。 +- **`https://tool.folotoy.cn/`**:**FOLOTOY 通用刷机工具**(独立站点)——适用于 FoloToy 设备线的通用浏览器刷机工具,无需安装软件,通过 WebSerial 写入本地固件并查看实时设备日志。 + +引用"在线刷机 / 浏览器刷机"入口时,产品官网场景优先用官网内置入口;需要给用户通用刷机工具时用 `tool.folotoy.cn`。 + +## 4. 产品规格 + +设备产品规格见 [hardware-design/specifications.md](hardware-design/specifications.md)(尺寸、重量、电池、充电、NFC、按键等)。 + +## 5. 开源与授权 + +- 产品开源仓库:`github.com/FoloToy/ai-passport`。 +- 协议:**MIT License**(Copyright (c) 2026 FoloToy)。 +- 仓库常被 fork 后二次开发;fork 约定见仓库 `docs/fork-guide.md`。 + +## 6. 命名与多语言 + +- 名称 `AI Passport` 在官网中 / 英双版保持一致,不翻译。 +- 官网提供中文(`/`)与英文(`/en/`)两版。 +- 本仓库 README 提供中英双版(`docs/README.md` / `docs/README.zh_CN.md`);本文档若需增加英文版,按仓库文档语言约定处理。 + +## 7. 与工程事实源的关系 + +- 本文档是**品牌与产品层**的说明,承载对外展示口径(名称、定位、官方入口、规格引用)。 +- 设备产品规格见 [hardware-design/specifications.md](hardware-design/specifications.md)。 +- 硬件引脚、资源边界等工程事实以仓库 `docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md` 与 `components/bsp/include/bsp_pins.h` 为准,本文档不替代工程文档。 +- 网站入口以官网实际页面为准;如官网结构变化,优先更新官网并回同步本文档。 diff --git a/docs/contribution/README.md b/docs/contribution/README.md new file mode 100644 index 0000000..ec64800 --- /dev/null +++ b/docs/contribution/README.md @@ -0,0 +1,16 @@ +# 协作规范(Contribution) + +本目录存放适用于任何项目的通用协作规范(公共文档,可提上游)。 + +## 收录标准 + +- 只收录通用协作规范(文档规范、commit 风格、PR 约定等),对任何项目成立。 +- 每条规则应写清触发条件、必须做什么、禁止做什么、验证方法和例外条件。 +- 本项目专属的功能/产品设计细节属特定项目文档,不提上游(见 [doc-conventions.md](doc-conventions.md))。 +- 可以由 lint、测试或脚本强制的要求,应同时落实到自动化检查,不能只靠 agent 阅读文字。 +- 新增规约时在本文件更新索引。 + +## 文档索引 + +- [doc-conventions.md](doc-conventions.md):先读根目录所有 README + 文档生成规范 + 文档分类规范(公共/特定项目)。 +- [commit-and-pr.md](commit-and-pr.md):提交规范 + 提交与 PR 约定。 diff --git a/docs/contribution/commit-and-pr.md b/docs/contribution/commit-and-pr.md new file mode 100644 index 0000000..8eb6c8f --- /dev/null +++ b/docs/contribution/commit-and-pr.md @@ -0,0 +1,19 @@ +# 提交与 PR 规范(Commit & PR) + +> 定位:公共文档,适用于任何项目,可提上游。 + +## 提交规范 + +- commit 标题:`type(scope): 简述`,`type` ∈ `feat/fix/docs/refactor/perf/test/chore/build/ci`,简述祈使句、≤50 字符、结尾不加句号、**用英文**。例如 `feat(bsp): ...`、`docs: ...`。 +- 一个 commit 只做一件事,message 描述最终 diff,不叙述调试过程。 +- commit 后同一轮内 `git push`(协作仓库走分支/PR,本 fork 功能开发在 `feature/*`)。 +- push 前检查仓库根是否同时存在 `AGENTS.md` 和 `CLAUDE.md`,缺失时先补齐。 +- 任何实际文件变更都同步记录到 `CHANGELOG.md`;项目没有该文件时先在仓库根创建。 +- **最终需求回写**:需求沟通形成的最终需求,不要只留在 memory;必须同步写回本文件、需求文档或项目内对应规范文件。其他记录了本项目决策、约定、踩坑、架构边界、运行方式、测试方式、发布流程或团队口径的 memory,同样要回写。 + +## 提交与 PR 约定 + +- **PR 标题与 commit 标题同规范**:`type(scope): 简述`,`type` ∈ `feat/fix/docs/refactor/perf/test/chore/build/ci`,简述祈使句、**用英文**。例如 `docs: restructure documentation and add CI workflow`。不要用名词短语当标题。 +- **PR body 用英文**:PR 描述正文用英文撰写(技术术语、路径、命令保留原样)。 +- PR 应说明测试的硬件/版本、行为变更摘要、构建与真机结果;显示类改动附照片/截图;链接相关 issue,并说明接线、引脚映射或兼容性问题。 +- 对引脚、显示旋转、codec 时钟、ADC、DMA 改动,必须在 PR 里显式记录观察到的真机结果。 diff --git a/docs/contribution/doc-conventions.md b/docs/contribution/doc-conventions.md new file mode 100644 index 0000000..6ec1677 --- /dev/null +++ b/docs/contribution/doc-conventions.md @@ -0,0 +1,22 @@ +# 文档规范(Doc Conventions) + +> 定位:公共文档,适用于任何项目,可提上游。 + +**先读全部 README**:开始工作前,阅读仓库的**全部** `README*` 说明——包括上游英文 `docs/README.md`、中文 `docs/README.zh_CN.md`,以及 fork 用户可能自行创建的根目录 `README.md` 或自定义 README。这些文件是重要的 AI 参考(含项目定位、硬件事实、使用约定等),AI 不应只依赖本文件。 + +**文档生成规范**:本仓库的说明文档(`AGENTS.md`、`CLAUDE.md`、`CHANGELOG.md`、`docs/**`、`assets/**`、`skills/**` 等)均为 AI 生成。请**勿手动输入或修改**这些文档内容——需要更新时,通过 AI agent 按本项目规范重新生成/改写,保持文档与代码、与约定一致;手动改动会造成不一致或被后续流程覆盖。例外:`docs/assets/` 是 fork 用户保存 README 补充文档与素材的目录,其内容由 fork 用户按 `docs/assets/readme.md` 约定管理,不属于上游同步的 AI 生成文档。 + +**文档分类规范**:文档分为两类,提交到上游的 PR 里**只允许包含公共文档**: + +- **公共文档**:适用于**任何项目**的通用规范/约定(如 AI 工作流、commit 风格、文档生成规范、文档分类规范、目录骨架约定、CI/构建通用做法等)。这些**可以**提交到上游项目。 +- **特定项目文档**:只适用于**本项目**的专属内容——指具体**功能实现、按钮设计、产品交互、专属业务逻辑**这类实现层面/产品设计细节。这些**不得**提交到上游项目。 + +判断原则:某段内容若属于本项目**功能/设计实现**(如某功能怎么实现、某按钮怎么设计、某交互怎么定义),即为特定项目文档,不提上游;而通用的 AI 工作流、文档规范、构建约定等,对任何项目成立,是公共文档,可提上游。 + +**中文写作规范**:编写或修改中文正文、占位文案、issue 回复或中文文档说明时生效——中文正文内的逗号、分号和括号使用全角标点(`,`、`;`、`(`、`)`)。同一文件已有更统一的中文文案风格时,跟随该文件的既有风格。代码、命令、路径、URL、标识符、YAML/JSON 字段、正则、英文句子和必须机器解析的内容保持原样,不为了中文排版替换其中的 ASCII 标点。注:PR/MR 标题与描述使用英文(见 `commit-and-pr.md`),不适用本规范。 + +**内容安全(凭证不入仓)**:凭证、令牌、密钥、授权文件和私钥**绝不写入仓库**或任何可能被 Git 跟踪的路径——没有例外。git history 是公开的,仓库可能被 fork、跨机器同步或被 agent 读取上下文,任何写进去的 token 都视同泄露。提交前用 `git diff` 扫描,看到形如 `glpat-`、`ghp_`、`sk-` 等敏感前缀立即终止,改用环境变量或系统钥匙串。误提交了敏感信息要立即私下报告,仅删除工作区文件不能保证 Git 历史中的秘密已失效。 + +**设备二维码链接含隐私参数,禁止写入代码 / 仓库**:设备(卡片)背面二维码扫码后得到的链接带有隐私令牌参数,例如 `https://ai-passport.folotoy.cn/trae/?s=4c11aeAAAAAA&k=CCAXAAAAAA`(`s`、`k` 为设备绑定的敏感标识,可能关联到具体设备或持有者)。此类链接**绝不允许**写进本仓库代码、配置、文档、示例、测试或 commit message。处理此类链接时:不要在代码库中存放、打印、提交或复制进示例;仅可出现在用户本人可直接查看的介质(如设备贴纸 / 本地记录)中。发现误提交应立即移除并告知维护者;仅删除工作区文件不能保证 Git 历史中的参数已失效。对外文档需要演示该链接形态时,使用脱敏占位(如 `https://ai-passport.folotoy.cn/trae/?s=&k=`),不得携带真实参数。 + +**文件删除安全**:删除文件或目录时,移动到系统回收站 / Trash / Recycle Bin,不直接永久删除。不使用 `rm`、`rm -rf`、`find ... -delete`、`git clean -fd` 或等价永久删除命令处理工作区内容。macOS 优先用 Finder / AppleScript / `trash`;Windows 用 Recycle Bin;Linux 用 `gio trash`、`trash-put` 或桌面回收站。缺少可用回收站工具时先询问用户,不退化为永久删除。对 Git 引用类操作(如删除本地分支)先区分清楚:它不是文件系统删除;但删除 worktree 目录、未跟踪文件、生成物或临时 checkout 目录仍必须走回收站。 diff --git a/docs/development/CI-build-and-release.md b/docs/development/CI-build-and-release.md new file mode 100644 index 0000000..4eb4ae6 --- /dev/null +++ b/docs/development/CI-build-and-release.md @@ -0,0 +1,39 @@ +# 自动构建与发布(CI / Build & Release) + +本仓库提供一套基于 GitHub Actions 的自动构建与发布流水线,用于在打 tag 时自动编译固件并发布 Release。 + +本文件与 `.github/workflows/build-firmware.yml` 一同维护,工作流行为变化时必须同步更新。 + +## 触发条件 + +- **push tag**:当向仓库推送 tag(如 `v1.0.0`、`v0.1.0-feature/xxx`)时触发自动构建,并在构建成功后自动创建 Release(带固件产物)。 +- **workflow_dispatch**:可在 GitHub Actions 页面手动触发(用于调试/预发布验证)。 + +> 平时 push 到分支(非 tag)**不会**触发构建;只有打 tag 才会。 + +## 流水线做了什么 + +1. **ccache 缓存恢复**:使用 `actions/cache` 缓存编译中间产物(`.ccache`),二次编译大幅提速。缓存 key 含 ref 与 commit SHA;缓存保留时间以仓库的 GitHub Actions 设置为准。 +2. **编译**(ESP-IDF 5.5.3 / esp32c3):`idf.py -D SDKCONFIG_DEFAULTS=sdkconfig.defaults build`。由 `sdkconfig.defaults` 启用自定义分区表(`CONFIG_PARTITION_TABLE_CUSTOM=y`、`CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"`、`CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"`),编译时读取 `partitions.csv`。 +3. **合并完整固件**:用 `idf.py merge-bin -o build/FoloToy-AI-Passport-full.bin` 把 bootloader + partition-table + app 按本次构建的 `flash_args` 合并为**可直刷的完整固件**。`sdkconfig.defaults` 关闭 `CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE`,使 `flash_args` 使用 `--flash_size 8MB` 而不是 `detect`。 +4. **上传 artifact**:每次成功构建都上传 `FoloToy-AI-Passport-full.bin`。普通分支只有从该分支手动运行 `workflow_dispatch` 才会构建;普通 push 不触发。 +5. **发布 tag**:tag 构建完成后,独立 release job 下载上述 artifact,并创建 GitHub Release。 + +构建 job 只有 `contents: read` 权限;仅 release job 在 tag 发布时获得 `contents: write`。所有 Action 均固定到完整 commit SHA,行尾注释保留对应发布版本,升级时需同时核对 SHA 与版本。 + +## 产物 + +- `FoloToy-AI-Passport-full.bin`:合并后的完整固件,可直接烧录(唯一产物)。 + +## 在线烧录 + +使用浏览器在本机完成写入与校验,固件不会上传服务器。打开 **在线刷机工具**: + +`https://ai-passport.folotoy.cn/tools/web-flasher/` + +步骤:连接设备(USB JTAG/serial debug unit)→ 选择本 Release 的合并固件 `FoloToy-AI-Passport-full.bin` → 选择波特率(如 460800)→ 开始写入。目标是 8MB Flash 板卡,无需其它参数。 + +## 相关文件 + +- `.github/workflows/build-firmware.yml`:本流水线定义。 +- 详见 `docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md`(硬件/烧录细节)。 diff --git a/docs/development/CI-sync-main.md b/docs/development/CI-sync-main.md new file mode 100644 index 0000000..65fc0a2 --- /dev/null +++ b/docs/development/CI-sync-main.md @@ -0,0 +1,29 @@ +# 上游同步(CI / Upstream Sync) + +本仓库提供一套基于 GitHub Actions 的自动上游同步流水线,用于定期把上游 `FoloToy/ai-passport` 的 `main` 分支更新同步到本 fork 的 `main` 分支。 + +本文件与 `.github/workflows/sync-main.yml` 一同维护,工作流行为变化时必须同步更新。 + +## 触发条件 + +- **schedule**:每天 00:00(UTC)自动运行一次。 +- **workflow_dispatch**:可在 GitHub Actions 页面手动触发(用于立即同步/排查问题)。 + +> 该工作流仅在仓库为 **fork** 时生效(`if: github.event.repository.fork`);非 fork 仓库不运行。 + +## 流水线做了什么 + +1. **Checkout 目标仓库**:`actions/checkout` 检出当前 fork 的 `main` 分支,并关闭 Git 凭证持久化。 +2. **同步上游**:使用固定到完整 commit SHA 的 `aormsby/fork-sync-with-upstream-action`(对应 v3.4.3),把 `FoloToy/ai-passport` 的 `main` 同步到本 fork 的 `main`。`target_repo_token` 使用自动生成且仅具 `contents: write` 权限的 `GITHUB_TOKEN`,无需手动配置。 +3. **失败检查**:同步失败时输出提示——上游 workflow 文件变更可能导致 GitHub 暂停自动同步,需手动 Sync Fork 一次。 + +## 注意事项 + +- 同步目标与上游分支均为 `main`,与 fork 用户约定(`main` 仅允许修改根目录 `README.md` 与 `docs/assets/`)配合使用:`main` 保持与上游最新基线同步、不产生冲突。 +- **在 `main` 直接开发的例外**:如果用户执意要在 `main` 分支直接开发,必须**停用/关闭本 workflow**(Actions 页面 → Disable),否则每日自动同步会把上游改动强行合入 `main`,产生冲突或覆盖本地开发内容。 +- 若同步失败,查看 Actions 日志确认是否为上游 workflow 文件变更所致;必要时按提示手动在 GitHub 页面 Sync Fork。 +- 升级 Action 时必须从官方仓库核对目标版本对应的完整 commit SHA,并同步更新 workflow 行尾的版本注释。 + +## 相关文件 + +- `.github/workflows/sync-main.yml`:本流水线定义。 diff --git a/docs/development/README.md b/docs/development/README.md new file mode 100644 index 0000000..a484c34 --- /dev/null +++ b/docs/development/README.md @@ -0,0 +1,20 @@ +# 工程规范(Development) + +本目录存放通用工程开发规范(公共文档,可提上游)。 + +## 收录标准 + +- 只收录通用工程开发规范(构建验证、代码风格、注释、测试、资源约束等),对任何项目成立。 +- `agent-guide.md` 为面向 AI 编程助手的开发工作流说明,含本项目结构细节,与通用规范并列维护。 +- 每条规则应写清触发条件、必须做什么、禁止做什么、验证方法和例外条件。 +- 涉及本板具体硬件事实的结论引用 `docs/hardware-design/`,不重复。 +- 可以由 lint、测试或脚本强制的要求,应同时落实到自动化检查,不能只靠 agent 阅读文字。 +- 新增规约时在本文件更新索引。 + +## 文档索引 + +- [agent-guide.md](agent-guide.md):AI 开发工作流(面向 AI 编程助手:上下文建立、需求拆解、BSP 边界、验收交付格式)。 +- [build-and-test.md](build-and-test.md):构建与验证(ESP-IDF 命令、逻辑测试、改动验证要求)。 +- [coding-conventions.md](coding-conventions.md):代码约定(语言风格、复用、注释、测试同步、资源约束等)。 +- [CI-build-and-release.md](CI-build-and-release.md):自动构建与发布说明(tag 触发自动编译固件并发布 Release)。 +- [CI-sync-main.md](CI-sync-main.md):上游同步说明(定期把上游 `FoloToy/ai-passport` 的 `main` 同步到本 fork 的 `main`)。 diff --git a/docs/development/agent-guide.md b/docs/development/agent-guide.md new file mode 100644 index 0000000..c520f02 --- /dev/null +++ b/docs/development/agent-guide.md @@ -0,0 +1,88 @@ +# AI Agent 开发指南(Agent Development Guide) + +> 定位:面向 AI 编程助手(Claude Code / Codex / Cursor / Cline 等),人类开发者可忽略。 +> 本文档集中说明"AI 如何在本仓库工作",收纳了原 `docs/README` 中的 AI 使用说明,并链接到各权威文档,避免重复。触发场景:AI 开始任何开发工作前,先读 `AGENTS.md`(规范入口与规则索引),再按需读本文档与硬件指南。 + +## 0. 与其他文档的关系 + +| 文档 | 作用 | 本文档的取舍 | +| --- | --- | --- | +| [AGENTS.md](../../AGENTS.md) | AI 规范入口 + 按触发场景的规则索引 | 必读;本文档不重复规则 | +| [AI 硬件开发指南](../hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md) | 硬件事实、引脚表、验收矩阵、故障速查 | 硬件细节权威源;涉及硬件结论时以其为准 | +| [build-and-test.md](build-and-test.md) | 构建与验证命令 | 本文档不重复命令,只引用 | +| [docs/README.md](../README.md) | 人读的项目总览 | 已不含 AI 说明 | + +## 1. 开始开发前:建立上下文 + +开始开发前,按以下顺序建立上下文: + +1. 阅读 `AGENTS.md`、[docs/README.md](../README.md) 和 [docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md](../hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md)。 +2. 执行 `git status --short --branch`,保留用户已有改动。 +3. 阅读需求会触及的 `components/bsp/include/*.h` 及其实现,不根据芯片或开发板的常见配置猜测本板行为。 +4. 用 `git branch -r --list 'origin/demo/*'` 查找接近需求的示例,只复用相关设计,不默认合并整个示例分支。 +5. 将需求拆成输入、输出、状态、并发任务、持久化、内存预算和失败降级,再决定修改 `main` 还是扩展 `components/bsp`。 +6. 完成最低构建检查和适用的逻辑测试;所有依赖屏幕、按键、音频、电池或时序的结论均保留真机验收项。 + +## 2. 事实来源优先级(Source-of-truth priority) + +发生冲突时,使用以下优先级: + +```text +原理图 / PCB / 板卡版本 / 实机测量 + > components/bsp/include/bsp_pins.h + > BSP 公开头文件与实现 + > docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md + > README 与示例应用 +``` + +当前仓库尚未包含原理图和 PCB 源文件。遇到板卡版本、接线、极性、寄存器或未使用 GPIO 等未知信息时,明确报告未知项并请求证据,不能用其他 ESP32-C3 开发板的参数补全答案。 + +> 硬件指南有同义说明;以本文档与硬件指南为准,README 不再重复。 + +## 3. 应用与 BSP 的边界 + +```text +Natural-language requirement + └─ main/ Pages, state machines, animation, app tasks, assets + └─ components/bsp/include/ Stable board-level APIs + └─ components/bsp/src/ GPIO, buses, devices, and driver details + └─ bsp_pins.h Single source of truth for pins and hardware parameters +``` + +新增普通页面时,创建 `main/demo_.c` 并实现 `enter`、`exit`、`key` 接口,然后同步修改: + +- `main/demo.h` 中的声明; +- `main/CMakeLists.txt` 中的源文件; +- `main/main.c` 的 `DEMOS[]` 注册; +- 若有新的可选外设,菜单的初始化状态与失败降级。 + +只有多个应用都会使用的硬件能力才进入 `components/bsp`。BSP API 需要说明阻塞性、线程上下文、内存所有权、失败值和初始化顺序;引脚或 I2C 地址只能加入 `bsp_pins.h`。 + +## 4. 运行时不可破坏的规则(Runtime invariants) + +- LVGL 不是线程安全的;非 LVGL 上下文操作 `lv_*` 对象必须持有 `bsp_lvgl_lock()`。 +- 按键回调只派发轻量事件;录音、播放、存储和其他慢操作放到工作任务。 +- 页面退出时先停止可能访问 UI 的任务或定时器,再删除 screen 并清空对象指针。 +- 全局交互默认是菜单中 `UP`/`DOWN` 导航、`OK` 单击进入、页面中 `OK` 长按返回;改动时要明确说明。 +- 新图片、字体、网络栈、音频缓存、LVGL buffer 或任务栈都要评估内部 RAM;总空闲堆足够不代表存在足够大的连续内存块。 +- 可测试的状态机、协议、计时和布局计算应与 ESP-IDF/LVGL 分离,优先加入主机逻辑测试。 + +## 5. 验收与交付格式 + +`idf.py build` 是最低自动检查,不是硬件验收。agent 的最终交付应明确区分: + +```text +Build: PASS / FAIL / NOT RUN +Host tests: PASS / FAIL / NOT RUN +Device tests: PASS / FAIL / NOT RUN +Unverified: 仍需板卡、仪器或用户确认的事项 +``` + +上板验收矩阵按修改类型(引脚、LCD、ADC、codec、I2C、DMA 等)见 [AI 硬件开发指南 §构建与验证](../hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md#构建与验证),本文档不重复完整验收清单。真机结果要与"编译通过"分开记录。 + +## 6. 相关文档 + +- 构建与验证命令:[build-and-test.md](build-and-test.md) +- 代码约定:[coding-conventions.md](coding-conventions.md) +- 硬件指南与验收矩阵:[AI 硬件开发指南](../hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md) +- 全部文档索引:[docs/INDEX.md](../INDEX.md) diff --git a/docs/development/build-and-test.md b/docs/development/build-and-test.md new file mode 100644 index 0000000..f876485 --- /dev/null +++ b/docs/development/build-and-test.md @@ -0,0 +1,24 @@ +# 构建与验证(Build & Test) + +> 定位:公共文档,适用于任何项目,可提上游。 + +使用 ESP-IDF 5.5.x(已知开发环境 5.5.3): + +```bash +get_idf553 # 进入仓库的 ESP-IDF 5.5.3 环境 +idf.py set-target esp32c3 # 配置目标芯片(fresh checkout 后/换 target 后运行) +idf.py build # 编译固件,验证依赖 +idf.py flash monitor # 烧录并打开日志 +idf.py fullclean # 配置过期时清空生成状态(勿用于清理用户源码改动) +``` + +当前基线含一个可独立运行的纯逻辑测试: + +```bash +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 +``` + +改动后至少跑 `idf.py build`(最小自动化检查)+ 适用逻辑测试;涉及物理外设的改动必须在真机运行 README 验收清单,并把"编译通过"与"硬件验证通过"分开记录(禁止把编译通过描述成硬件验证通过)。 diff --git a/docs/development/coding-conventions.md b/docs/development/coding-conventions.md new file mode 100644 index 0000000..c4275d5 --- /dev/null +++ b/docs/development/coding-conventions.md @@ -0,0 +1,14 @@ +# 代码约定(Coding Conventions) + +> 定位:公共文档,适用于任何项目,可提上游。 + +- **语言/风格**:C 用四空格缩进 + K&R 大括号,跟随相邻文件;函数/局部变量 `snake_case`,公开硬件常量 `BSP_*`,文件内状态 `s_` 前缀;BSP API 用 `bsp_` 前缀,demo 入口 `demo__`;内部符号优先 `static`。UI 文案用英文,解释性注释可用中文;保留记录硬件寄存器值与内存约束的注释。 +- **复用既有组件**:可复用硬件逻辑放 `components/bsp`;菜单/动画/业务交互/验证页面放 `main`。不要另造轮子,遵循既有 BSP API。 +- **注释要求(尽可能详细)**:项目源码需要尽可能详细地编写函数说明、变量说明,增加完善的代码注释。 + - **函数说明**:每个非平凡函数都要有注释,说明:用途/职责、参数含义、返回值、失败值、副作用、阻塞行为、线程/任务上下文、内存所有权、调用前提与初始化顺序。涉及硬件的函数额外注明寄存器操作、时序约束与已知陷阱。 + - **变量说明**:模块级/文件级变量、宏、结构体字段都要有语义注释,说明其用途、取值范围、生命周期/所有权、跨任务共享时的同步要求。硬件常量注释注明来源(数据手册/实测/推导)。 + - **逻辑注释**:复杂逻辑、状态机转移、边界条件、时序依赖、并发/同步点都要有注释解释"为什么这么做",而不只是"做了什么"。寄存器配置、魔数、位操作、时序参数必须注明含义与依据。 + - **覆盖范围**:宁可注释偏多,也不留难懂代码;新代码与修改代码同样适用;注释用中文,保留英文技术术语。 +- **测试同步**:写代码时同步新增测试用例,或修改受本次改动影响的既有测试;若暂无合适自动化测试落点,在项目规范里写清测试缺口和手工验证路径。 +- **缓存组件**:若引入缓存组件(如 NVS 缓存、内存缓存等),默认设置过期时间;长期缓存需说明保留原因、过期风险与清理机制。当前固件不含需要 TTL 约束的缓存,无需特别处理。 +- **资源约束**:ESP32-C3 无 PSRAM,不增加 LVGL buffer / 音频分配 / 任务栈前先核对内部 RAM;足够的总空闲堆不保证有足够大连续块。 diff --git a/docs/fork-guide.md b/docs/fork-guide.md new file mode 100644 index 0000000..fcf29c6 --- /dev/null +++ b/docs/fork-guide.md @@ -0,0 +1,58 @@ +# Fork 工作流(Fork Guide) + +> 定位:公共文档,适用于任何 fork 二次开发项目,可提上游。 + +## 目录结构 + +``` +docs/ + software-design/README.md 软件设计文档子目录骨架 + hardware-design/ + README.md 硬件设计文档子目录骨架 + AI_HARDWARE_DEVELOPMENT_GUIDE.md 完整硬件开发指南与排障参考(上游) + contribution/ 协作规范(doc-conventions.md、commit-and-pr.md,见 README.md 索引) + development/ 工程规范与 AI 开发工作流(build-and-test.md、coding-conventions.md、agent-guide.md,见 README.md 索引) + README.md 上游英文说明(FoloToy AI Passport;GitHub 主 README) + README.zh_CN.md 上游中文说明(FoloToy AI Passport) + INDEX.md 仓库根总索引(各目录索引表格 + 根治理文档) + assets/ fork 补充文档素材目录(README 不足以说明项目时存放补充文档与素材;上游 main 只保留空目录 `.gitkeep`,内容文件仅存在于 fork) + fork-guide.md 本文档:fork 工作流与约定 +components/bsp/ 板级支持包:显示、按键、音频、电池、I2C(稳定 API 与 bsp_pins.h 硬件事实) +main/ 设备固件应用:LVGL 菜单 + 独立 demo_*.c 硬件验证页(新 demo 需实现 demo.h 声明的 enter/exit/key 接口) +assets/ 预置资源:fonts/ images/ music/(各含 README.md) +skills/ 可复用技能目录(每个 skill 独立子目录) +tests/ 轻量级逻辑测试(无硬件可运行) +sdkconfig.defaults ESP32-C3、USB console、Flash、LVGL 默认配置 +``` + +**强约束**:`main` 始终与上游 `FoloToy/ai-passport` 的 `main` 保持同步(最新基线),不承载 fork 特有功能改动;fork 特有的固件功能都在各自功能分支(`feature/*`)开发。 + +## 为什么 `main` 保持干净 + +有两个原因——(1) **随时与上游保持一致、无冲突**,给多任务并行开发提供最新基线;(2) **默认用户会开发很多小项目**,为了便于整理,通过分支(`feature/*`)保存每个项目,`main` 只作为同步基线不混入具体项目改动。 + +**例外**:如果用户**执意要在 `main` 分支直接开发**,需要**停用/关闭 CI 的自动同步任务**(见 `.github/workflows/sync-main.yml`,说明见 [docs/development/CI-sync-main.md](development/CI-sync-main.md)),否则自动同步会把上游改动强行合入,产生冲突或覆盖本地开发内容。 + +**fork 用户注意(整个 CI 通用)**:fork 默认的 GitHub Actions 是**关闭**的,需要**手动打开启用**(GitHub 仓库 Actions 页面 → 找到需要的 workflow,如 CI 自动同步 → Enable)后,对应的 CI 才会生效。 + +## 给 fork 用户 + +fork 后,`main` 分支**只允许增加/修改根目录的 `README.md` 和 `docs/assets/` 目录**(可建自己的说明/README 变体),**不允许改其它任何文件**——这样 fork 的 `main` 与上游保持最新同步、不产生冲突。任何其它修改(固件功能、文档规整等)一律在 `feature/*` 分支进行,用 PR 合并。 + +### 为什么根目录不放置 README + +**根目录的 `README.md` 是预留给开发者自行放置的,因此上游留空**: + +- 上游 main 的根目录**故意不放 README**,把这一位置预留给 fork 开发者。上游项目说明位于 `docs/README.md`(GitHub 从 docs/ 识别主 README),不占用根目录。 +- 开发者 fork 项目后,可将**自己的内容**写到根目录的 `README.md`,以介绍 fork 后的项目——例如改动来源、二次开发说明、自定义用法等。这样 fork 的根目录 README 与上游互不冲突,也无需覆盖上游文档。 + +> **GitHub 显示行为**:GitHub 显示优先级为根目录 `README.md` > `docs/README.md`,因此 fork 用户在根目录自建 `README.md` 后即覆盖 `docs/README.md` 的显示——正契合上面"根目录 README 预留给开发者"的设计意图。 + +## docs/assets 使用约定 + +个人项目可能 `README.md` 不足以完整说明项目,`docs/assets/` 正是用于在 fork 下保存 README 的**补充文档与素材**(架构说明、产品设计、图片素材等)。`docs/assets/` 在**上游 main 上必须为空**(仅保留 `.gitkeep` 占位),因此 fork 用户应在该目录下自行创建 `readme.md` 说明使用方式。建议 `docs/assets/readme.md` 包含: + +- 本目录用途:README 的补充文档与素材所在。 +- 目录结构约定:如何组织文档与素材子目录。 +- AI 使用方法:进入仓库时如何结合上游 `docs/README.md`(或 fork 自建根 README)与本目录补充信息理解项目。 +- 边界:该目录仅存在于 fork,内容不得同步回上游 main。 diff --git a/docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md b/docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md similarity index 98% rename from docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md rename to docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md index c03be06..adb197d 100644 --- a/docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md +++ b/docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md @@ -8,7 +8,7 @@ AI 应先完成以下检查: -1. 阅读 `AGENTS.md`、本文件、`README.md` 和将要修改的 BSP 头文件/实现。 +1. 阅读 `AGENTS.md`、本文件、`docs/README.md`、`docs/README.zh_CN.md` 和将要修改的 BSP 头文件/实现。 2. 执行 `git status --short`,保留用户已有改动,不覆盖、不清理无关文件。 3. 判断修改属于哪一层:可复用硬件能力放入 `components/bsp`;菜单、动画、业务交互和验证页面放入 `main`。 4. 以 `bsp_pins.h` 为当前板卡引脚和面板参数的单一事实来源,不在 `.c` 文件重复写 GPIO、I2C 地址或屏幕尺寸。 @@ -195,7 +195,7 @@ SOC 准确度取决于电芯与 profile 的匹配程度。本驱动给出的是 ## 10. Flash、控制台和资源预算 -FoloToy AI Passport 的所有硬件批次均使用 8 MB Flash,`sdkconfig.defaults` 因此固定使用 8 MB Flash 镜像配置;`partitions.csv` 提供 24 KB NVS、4 KB PHY data 和 3 MB factory app 分区,无 OTA 槽。烧录时仍允许按实际探测容量更新镜像头。若实机探测结果不是 8 MB,应视为硬件、料号或连接异常并先确认,不能为了让未知板卡启动而把项目默认值降为 4 MB。 +FoloToy AI Passport 的所有硬件批次均使用 8 MB Flash,`sdkconfig.defaults` 因此固定使用 8 MB Flash 镜像配置,并关闭 `CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE`(不按探测容量回写镜像头,便于 `idf.py merge-bin`);`partitions.csv` 提供 24 KB NVS、4 KB PHY data 和 3 MB factory app 分区,无 OTA 槽。若实机探测结果不是 8 MB,应视为硬件、料号或连接异常并先确认,不能为了让未知板卡启动而把项目默认值降为 4 MB。 控制台固定为 USB Serial/JTAG,不使用 UART0 默认输出,因为其 TX GPIO21 与背光冲突。任何日志接口修改都必须同时检查引脚占用。 diff --git a/docs/hardware-design/README.md b/docs/hardware-design/README.md new file mode 100644 index 0000000..48a2150 --- /dev/null +++ b/docs/hardware-design/README.md @@ -0,0 +1,22 @@ +# 硬件设计(Hardware Design) + +本目录用于存放本仓库的硬件设计文档,包括板级事实、引脚映射、硬件约束、验收矩阵与排障知识。 + +## 目录约定 + +- 硬件事实以 `components/bsp/include/bsp_pins.h` 为准,属于该文件的范围在此处只作引用,不重复。 +- 硬件文档应区分「已确认事实」与「未知项」;未知项需明确报告并请求证据,不要用其它型号板子的参数补位。 +- 每次修改硬件映射(引脚、I2C、ADC、屏参、音频时钟等)需同步更新本文档并记录实机结果。 + +## 如何添加一篇硬件设计文档 + +1. 在本目录下新建一个描述性文件(如 `xxx-hw.md`)或子目录。 +2. 文档顶部写明适用板卡/版本与日期。 +3. 与软件接口相关的结论引用 `docs/software-design/` 与仓库根 `AGENTS.md`。 + +## 现有文档索引 + +- [AI_HARDWARE_DEVELOPMENT_GUIDE.md](AI_HARDWARE_DEVELOPMENT_GUIDE.md):完整的硬件开发指南与排障参考(上游已有,已归位到本目录)。 +- [specifications.md](specifications.md):产品规格(面向用户与产品的设备规格:尺寸、重量、电池、充电、NFC、按键等)。 + +> 注:`docs/hardware-design` 为本次仓库规范化目录,用于容纳硬件设计文档。上游既有硬件指南 `AI_HARDWARE_DEVELOPMENT_GUIDE.md` 已归入本目录。 diff --git a/docs/hardware-design/specifications.md b/docs/hardware-design/specifications.md new file mode 100644 index 0000000..7af76f7 --- /dev/null +++ b/docs/hardware-design/specifications.md @@ -0,0 +1,23 @@ +# 产品规格(Specifications) + +> **定位**:面向产品与用户的设备规格(对外口径)。 +> **读取时机**:需要引用设备尺寸、重量、电池、充电、NFC、按键等用户可见规格时。 +> **与工程文档的关系**:芯片、引脚、总线、接口等工程事实以 `docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md` 与 `components/bsp/include/bsp_pins.h` 为准;本文档承载产品规格口径。 + +以下为设备产品规格(源自官方产品页): + +| 项目 | 规格 | +| --- | --- | +| 形态 | 可穿戴,透明外壳(屏幕 / 主板 / NFC / 麦克风 / 扬声器 / 电池均为产品语言一部分) | +| 尺寸 | 60 × 95 × 8.5 mm | +| 重量 | 50 g | +| MCU | ESP32-C3(8MB Flash) | +| 显示 | 240 × 320 彩色 TFT | +| 无线 | 2.4 GHz Wi-Fi(802.11 b/g/n);Bluetooth® 5 LE(可同步头像 / 昵称 / Token / 个性化内容) | +| NFC | 被动 NFC 标签(NTAG213,支持读卡器 / 手机读写普通 NDEF 数据) | +| 输入 | 上 / 下 / 确定三枚功能键 + 独立电源键(硬件实现,不可改功能) | +| 电源 | 按住电源键 0.5s 开机;长按约 2s 关机;自动息屏后按任意功能键唤醒 | +| 音频 | 内置麦克风 + 内置扬声器 | +| 充电 | USB Type-C 2.0 5V | +| 电池 | 内置 520 mAh 可充电锂电池 | +| 其他 | 专属二维码(QR fallback,含恢复固件入口) | diff --git a/docs/software-design/README.md b/docs/software-design/README.md new file mode 100644 index 0000000..11bc248 --- /dev/null +++ b/docs/software-design/README.md @@ -0,0 +1,21 @@ +# 软件设计(Software Design) + +本目录用于存放本仓库的软件设计文档,包括应用层、组件层与系统层的设计说明、模块划分、接口约定、状态机、资源约束与测试策略。 + +## 目录约定 + +- 每个设计主题一个子目录或一个独立 `.md` 文件,名称与主题一致,便于检索。 +- 文档面向 AI agent 与开发者,应包含:目标、范围、输入/输出、状态、并发任务、持久化、内存预算与失败降级。 +- 涉及硬件事实的结论在 `hardware-design/` 中维护;软件设计只依赖其稳定的接口。 + +## 如何添加一篇软件设计文档 + +1. 在本目录下新建一个描述性文件(如 `xxx-design.md`)或子目录。 +2. 在文档顶部写明适用范围与所属版本/提交。 +3. 若与硬件行为强相关,链接到 `docs/hardware-design/` 对应文档,不要在此重复硬件数据。 + +## 现有文档索引 + +- [AGENTS.md](../../AGENTS.md):仓库权威 AI 规范的入口与索引。 + +> 注:`docs/software-design` 用于容纳软件设计文档。协作规范见 `docs/contribution/`,工程规范和 CI 说明见 `docs/development/`,fork 工作流见 `docs/fork-guide.md`;这些入口均由 `AGENTS.md` 索引。 diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 2eb2cf7..6dbeff4 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -5,8 +5,8 @@ CONFIG_IDF_TARGET="esp32c3" # --- Flash --- # FoloToy AI Passport 的所有硬件批次均使用 8MB Flash。 CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y -# 烧录时按实际探测容量回写镜像头。 -CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y +# 固定 8MB 镜像头,关闭 detect,便于 idf.py merge-bin。 +CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=n # 无 OTA 的硬件演示固件;3MB app 分区给 Wi-Fi/NimBLE 留出升级余量。 CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" diff --git a/skills/README.md b/skills/README.md new file mode 100644 index 0000000..9c396ca --- /dev/null +++ b/skills/README.md @@ -0,0 +1,21 @@ +# 技能目录(Skills) + +本目录用于保存项目可能用到的 skill(面向 AI agent 的可复用技能/工作流说明)。**每个 skill 必须按独立目录保存**,便于检索与维护。 + +## 目录约定 + +- 每个 skill 一个子目录,目录名即 skill 名称,命名简短、语义明确。 +- 每个 skill 目录内至少有一个说明文件(建议 `SKILL.md`),顶部用 YAML frontmatter 标注 `name` 与 `description`,其中 `description` 作为触发指纹,说清「何时触发、做什么」。 +- 复杂的 skill 可在其目录下增加 `references/`(长文档)、`scripts/`(可执行脚本)、`assets/`(模板/样例),与主文件分开放。 +- 文档应为纯 markdown,不含二进制内容。 + +## 如何添加一个 skill + +1. 在 `skills/` 下新建以 skill 名命名的目录。 +2. 目录内新建 `SKILL.md`,顶部写 `name` + `description` frontmatter。 +3. 视需要增加 `references/`、`scripts/`、`assets/` 子目录。 +4. 在本 `README.md` 的索引表中登记该 skill 的名称与一句话说明。 + +## 现有技能索引 + +> 当前为空骨架,后续加入的 skill 在此登记。