docs: reorganize reference area and unify directory READMEs

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

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
<p align="right">
<a href="README.zh_CN.md">简体中文</a> · <strong>English</strong>
</p>
# Reference
This area holds reference material for AI Passport development that is not a
binding requirement: reusable development experience and archived application
playbooks. These are consulted when developing something new, not enforced as
rules. Reference is organized by contributing developer's GitHub username: under
each `reference/<username>/` folder, experience entries are stored as flat files
and application playbooks as subdirectories.
The engineering rules themselves live under
[`../development/`](../development/README.md); the collaboration conventions under
[`../contribution/`](../contribution/README.md).
## Contributors
### Shinku-Chen
**Experience entries:**
- [Audio Compression Trade-offs on ESP32-C3](shinku-chen/audio-compression-trade-offs.md) — how a voice-playback codec was chosen on limited flash (IMA-ADPCM vs Opus vs MP3), with measured capacity and decoder cost.
- [Post-Release Follow-up for the AI Passport Publishing Flow](shinku-chen/post-release-follow-up.md) — confirm the publish destination, include the data partition in a release, and the consent gates for the post-release tracks.
- [Display Refresh and Deep-sleep on ESP32-C3 (No PSRAM)](shinku-chen/display-refresh-and-deep-sleep.md) — direct panel refresh of a single image rect, RTC-GPIO deep-sleep wakeup, and the LVGL object-type misuse crash signature.
**Application playbooks:**
- [Voice Keychain](shinku-chen/voice-keychain/README.md) — a sound-effects keychain that turns the AI Passport into a pocket audio player.
- [What to Eat Today](shinku-chen/eat-what/README.md) — a button-driven food roulette that turns the AI Passport into a "what should I eat?" spinner.
### PhoenixZHC
**Experience entries:**
- [Network Audio Streaming and Memory Budgeting on AI Passport](phoenixzhc/network-audio-streaming-and-memory.md) — bounded HTTP audio streaming, ES8311/I2S ownership, and joint memory budgeting for decoding, JSON, DMA, and LVGL.
- [SoftAP Provisioning and Resource Budgets on AI Passport](phoenixzhc/softap-provisioning-and-resource-budget.md) — DHCP state, captive-portal compatibility, bounded forms and uploads, and no-PSRAM resource planning.
## Adding an experience entry
Each release may produce **one or more** reusable, post-release learnings; each is
added as its own entry (with the release tag or commit as context). Follow the
repository language rule: keep the default `.md` path in English and the paired
`.zh_CN.md` in Simplified Chinese, aligned in the same change.
An entry is a single `.md` file (with its `.zh_CN.md` peer) stored flat under
`reference/<username>/` and named after the entry's content summary in
lowercase-kebab-case (e.g. `audio-compression-trade-offs.md`), describing the
topic rather than an opaque timestamp. Each entry is routed before submission:
general, upstream-benefiting experience goes to the upstream
`FoloToy/ai-passport` as a PR; fork-specific customization stays in the fork per
[`docs/fork-guide.md`](../fork-guide.md).
## Archiving an application
When an application is published, archive it under `reference/<username>/<app-name>/`
with an AI-generated bilingual functional summary (`README.md` / `.zh_CN.md`) and
optionally a how-to guide. The archive is **text-only** — record the cover image
by file name and format only, and do not store the firmware `.bin`. The `plays-archive`
skill drives the archive and its convention.
## Related
- Repository overview and demo branches: [`../README.md`](../README.md)
+45
View File
@@ -0,0 +1,45 @@
<p align="right">
<strong>简体中文</strong> · <a href="README.md">English</a>
</p>
# 参考(Reference)
本目录存放 AI Passport 开发中**不构成硬性要求**的参考资料:可复用的开发经验与已归档的应用档案。开发新东西时参考它们,而不是把它们当作强制规则。参考资料按贡献者的 GitHub 用户名组织:每个 `reference/<username>/` 目录下,经验条目以平铺文件存放,应用档案以子目录存放。
工程规则本身位于 [`../development/`](../development/README.zh_CN.md);协作规范位于 [`../contribution/`](../contribution/README.zh_CN.md)。
## 贡献者
### Shinku-Chen
**经验条目:**
- [ESP32-C3 上音频压缩方式的权衡](shinku-chen/audio-compression-trade-offs.zh_CN.md) — 在有限 Flash 上如何为语音播放应用选编解码(IMA-ADPCM vs Opus vs MP3),含实测容量与解码器成本。
- [发布后收尾:AI Passport 发布流程的衔接](shinku-chen/post-release-follow-up.zh_CN.md) — 确认发布目的地、发布时包含数据分区、以及发布后收尾各轨道的同意门槛。
- [ESP32-C3(无 PSRAM)上的显示刷新与深睡](shinku-chen/display-refresh-and-deep-sleep.zh_CN.md) — 直接刷新单个图片矩形、RTC GPIO 深睡唤醒,以及 LVGL 对象类型误用的崩溃特征。
**应用档案:**
- [音效钥匙扣](shinku-chen/voice-keychain/README.zh_CN.md) — 把 AI Passport 变成口袋音频播放器的音效钥匙扣。
- [今天吃啥](shinku-chen/eat-what/README.zh_CN.md) — 按键驱动的食物轮盘,把 AI Passport 变成「今天吃什么」小转盘。
### PhoenixZHC
**经验条目:**
- [AI Passport 网络音频流与内存预算经验](phoenixzhc/network-audio-streaming-and-memory.zh_CN.md) — 有边界的 HTTP 音频流、ES8311/I2S 资源归属,以及解码、JSON、DMA 与 LVGL 的统一内存预算。
- [AI Passport SoftAP 配网与资源预算经验](phoenixzhc/softap-provisioning-and-resource-budget.zh_CN.md) — DHCP 状态、弹窗认证兼容、表单与上传边界,以及无 PSRAM 条件下的资源规划。
## 新增经验条目
一次发布可沉淀**一条或多条**可复用经验,每条作为独立条目新增,以发布版本(tag 或 commit)作为上下文。遵守仓库语言规则:默认 `.md` 路径用英文、配套 `.zh_CN.md` 用简体中文,并在同一次变更中对齐。
条目是放在 `reference/<username>/` 下的单个 `.md`(及其 `.zh_CN.md`),按条目内容概要命名(小写连字符,例如 `audio-compression-trade-offs.md`),描述主题而非时间戳。每条经验在提交前分流:通用、上游也受益的经验作为 PR 提交到上游 `FoloToy/ai-passport`;纯 fork 定制按 [`docs/fork-guide.md`](../fork-guide.zh_CN.md) 留在 fork。
## 归档应用
应用发布后,在 `reference/<username>/<app-name>/` 下归档,附一份 AI 生成的双语功能说明(`README.md` / `.zh_CN.md`),可选配一份使用指南。档案为**纯文本**——封面图仅记录文件名与格式,不存放固件 `.bin`。`plays-archive` skill 驱动归档及其约定。
## 相关
- 仓库总览与 demo 分支:[`../README.md`](../README.zh_CN.md)
@@ -0,0 +1,119 @@
<p align="right">
<a href="network-audio-streaming-and-memory.zh_CN.md">简体中文</a> · <strong>English</strong>
</p>
# Network Audio Streaming and Memory Budgeting on AI Passport
This note collects reusable lessons from adding HTTP audio streaming to AI
Passport. It is intentionally application-neutral: the focus is the board's
ESP32-C3, ES8311 audio path, display workload, and no-PSRAM memory limit.
## Start from the board boundary
AI Passport has 8 MB flash and no PSRAM. The ST7789P3 display, Wi-Fi/TLS,
decoder, HTTP client, JSON parser, and LVGL therefore compete for internal RAM.
The ES8311 and CW2017 also share I2C0, so application code must reuse the BSP
bus instead of creating another driver instance.
The authoritative pin and bus definitions are in
[`bsp_pins.h`](../../../components/bsp/include/bsp_pins.h):
| Signal | AI Passport connection |
| --- | --- |
| ES8311 control | I2C0, SDA GPIO10, SCL GPIO7, 7-bit address `0x18` |
| I2S clocks | MCLK GPIO6, BCLK GPIO5, WS GPIO3 |
| I2S data | DOUT GPIO2, DIN GPIO4 |
| Display | ST7789P3, 240 × 320 |
Use [`bsp_audio`](../../../components/bsp/src/bsp_audio.c) as the owner of the
codec and I2S channels. PCM reads and writes are blocking operations and belong
in worker tasks, never in LVGL or button callbacks.
## Keep the streaming pipeline bounded
A stable playback pipeline has explicit ownership at every stage:
1. A controller validates the request and starts one playback worker.
2. The worker opens the HTTP stream and accepts both fixed and unknown content
lengths.
3. A bounded input buffer feeds the decoder incrementally; the complete file is
never accumulated in RAM.
4. Decoded PCM is converted to the format opened by the BSP and written to I2S.
5. One cleanup path closes HTTP, decoder, audio, and UI state on success,
cancellation, timeout, and decode failure.
For MP3 with a Helix-style decoder, one measured starting point was a 24 KiB
compressed-input buffer, a 2304-sample PCM buffer, and an 8 KiB playback-task
stack. These are measurements from one firmware, not board defaults. Record
minimum free heap, largest free block, and task stack high-water marks, then
shrink or grow the buffers from evidence.
Do not assume every decoded frame matches the target output format. Open the
codec using the source sample rate, convert stereo to mono when the application
needs mono, and calculate progress from decoded PCM samples. Byte-based progress
is misleading for variable-bit-rate streams and unavailable for chunked HTTP.
## Treat memory as one system budget
The common failure is not simply “the audio buffer is too small.” A firmware may
run out of one large contiguous block while total free heap still looks healthy.
Before each expensive phase, log both free heap and largest free block.
Budget these consumers together:
- TLS and HTTP receive buffers;
- decoder input, PCM output, and decoder state;
- I2S DMA descriptors and DMA buffers;
- LVGL draw buffers, image decoders, and screen objects;
- JSON documents and temporary response strings;
- worker-task stacks.
On the upstream BSP, LVGL uses a 20-row draw buffer, about 9.6 KiB at RGB565.
That is a useful baseline because enlarging the display buffer or I2S DMA ring
directly reduces headroom for networking and decoding. Change one buffer family
at a time and repeat playback while the UI is actively refreshing.
## Size JSON by the response, not the request
One real crash pattern came from parsing a response with a fixed 4096-byte JSON
document while the actual payload required about 6971 bytes. The request itself
was small, so request-size testing did not reveal the problem.
Safer rules are:
- reject an oversized HTTP response before parsing when its length is known;
- when the length is unknown, accumulate only up to an explicit cap;
- use a parser capacity derived from the accepted response limit;
- check deserialization errors and stop before reading missing fields;
- keep large metadata responses out of the playback worker when possible.
An optional relay service can normalize large or unstable upstream APIs into a
small device contract, but it should not hide firmware limits. Keep device-side
caps, timeouts, and error handling even when a relay is used.
## Concurrency and UI rules
Allow only one owner of the audio device. A new request should either be rejected
or cancel and join the existing worker before another worker opens I2S. Button
callbacks should post commands; they must not perform DNS, HTTP, decode, or PCM
writes.
Reuse the playback screen instead of recreating a full object tree on every
track. Update progress at a modest rate and modify only the changed labels or
bar. This reduces heap fragmentation and prevents display work from starving
the decoder.
## Verification checklist
- Play fixed-length and chunked streams, including a stream without
`Content-Length`.
- Exercise mono/stereo, supported sample rates, malformed frames, slow network,
server disconnect, cancellation, and repeated track changes.
- Refresh the display during playback and verify that audio does not underrun.
- Log free heap, largest free block, and stack high-water marks before connect,
after TLS, after decoder creation, during steady playback, and after cleanup.
- Repeat start/stop cycles and confirm memory returns to a stable baseline.
The reusable lesson is to make every buffer and owner explicit. On AI Passport,
streaming is reliable when network, decoder, I2S, display, and JSON memory are
designed as one bounded pipeline rather than tuned independently.
Loaded 3 of 105 files, more files were not shown because too many files have changed in this diff. Show more