Merge main into docs/toolchain-troubleshooting

This commit is contained in:
cjiio committed 2026-09-15 15:04:20 +08:00
commit ef17566aae
78 files changed
+2911 -549

No files matched your search

+13 -6
View File
@@ -7,10 +7,17 @@
Use ESP-IDF 5.5.3. On a clean machine or when the toolchain is missing, follow
the [environment bootstrap](environment-setup.md) first.
> Prefer `./tools/validate.sh --firmware` for firmware builds and flash its
> verified `build/FoloToy-AI-Passport-full.bin` at offset `0x0` only when the
> target is blank or the merged byte range ends before protected `cardid`.
> On a provisioned device, use segmented `idf.py flash`. Treat
> **No original-firmware backup is required before downloading (flashing) new
> firmware to the device.** Reading out the installed firmware is not a
> prerequisite. Flashing replaces the installed firmware and does not provide
> automatic restoration of it. This does not mean user data is preserved: if
> you need existing settings or records, export or otherwise save them first.
> See [flashing and stored data](firmware-layout.md#flashing-and-stored-data).
> Prefer `./tools/validate.sh --firmware` for firmware builds. Flash its
> verified `build/FoloToy-AI-Passport-full.bin` at offset `0x0` for a blank
> device or an intentional complete refresh. The merged image may reset NVS;
> use segmented `idf.py flash` when existing NVS state must be preserved. Treat
> `idf.py build` and `idf.py flash` as incremental development commands, not the
> default delivery path.
@@ -56,7 +63,7 @@ exclusions.
The tracked `dependencies.lock` pins Managed Component resolution. After changing an `idf_component.yml`, regenerate the lock with ESP-IDF 5.5.3, review version changes, and commit it with the manifest. An ordinary build must not leave an unexplained lock-file diff.
Firmware validation uses a fresh temporary build directory and an isolated `sdkconfig` generated from the tracked defaults. It does not consume or overwrite a developer's root `sdkconfig`, and it copies only the verified merged image to `build/FoloToy-AI-Passport-full.bin`. The gate also enforces the [protected Flash layout](protected-flash-layout.md): the protected `cardid` address, application size, partition-table MD5, and absence of device-specific identity data.
Firmware validation uses a fresh temporary build directory and an isolated `sdkconfig` generated from the tracked defaults. It does not consume or overwrite a developer's root `sdkconfig`, and it copies only the verified merged image to `build/FoloToy-AI-Passport-full.bin`. The gate also validates the [configured firmware layout](firmware-layout.md): image offsets from `flash_args`, partition-table MD5, bounds and non-overlap, and an application that starts in and fits its configured app partition. User-defined partition layouts are allowed.
The baseline also has a hardware-independent logic test:
@@ -71,7 +78,7 @@ Use the unified validation entry point:
```bash
./tools/validate.sh --static # repository checks, workflows, links, secrets, host tests
./tools/validate.sh --firmware # build, merge-bin, offsets, and protected layout
./tools/validate.sh --firmware # build, merge-bin, offsets, and configured layout
./tools/validate.sh # complete gate; requires an activated ESP-IDF environment
```
@@ -7,10 +7,15 @@
使用 ESP-IDF 5.5.3。全新机器或缺少工具链时,先按
[环境引导](environment-setup.zh_CN.md)完成安装。
> 固件编译优先运行 `./tools/validate.sh --firmware`,烧录优先把验证通过的
> `build/FoloToy-AI-Passport-full.bin` 写入空白设备;对已有身份的设备,只有合并文件
> 在保护区 `cardid` 之前结束时才可从 `0x0` 直刷,其余情况使用分段
> `idf.py flash`。`idf.py build` 和
> **向设备下载(烧录)新固件前,无需备份设备内部原有固件。** 不要求先读出
> 原固件,也不把原固件备份作为烧录前置条件。烧录会覆盖原固件,不会自动恢复
> 原固件。这不代表用户数据会被保留:如果需要保留已有设置或记录,应事先
> 导出或另行保存。详见[烧录与已存数据](firmware-layout.zh_CN.md#烧录与已存数据)。
> 固件编译优先运行 `./tools/validate.sh --firmware`。空白设备初始化或有意完整
> 刷新时,把验证通过的 `build/FoloToy-AI-Passport-full.bin` 从 `0x0` 写入;
> 合并镜像可能重置 NVS,需要保留已有 NVS 状态时使用分段 `idf.py flash`。
> `idf.py build` 和
> `idf.py flash` 只作为增量开发命令,不作为默认交付方式。
```bash
@@ -49,7 +54,7 @@ ccache 缓存位于 `build/` 之外,因此 `idf.py fullclean` 和临时验证
仓库提交 `dependencies.lock` 以固定 ESP-IDF Managed Components 的解析结果。修改 `idf_component.yml` 后必须使用 ESP-IDF 5.5.3 重新生成锁文件、review 版本变化并与 manifest 一起提交;普通构建不应产生未提交的锁文件差异。
固件门禁使用全新的临时构建目录,并从仓库 `sdkconfig.defaults` 生成隔离的 `sdkconfig`。它不会读取或覆盖开发者根目录的 `sdkconfig`,只把验证通过的合并镜像复制到 `build/FoloToy-AI-Passport-full.bin`。门禁同时强制检查[受保护的 Flash 布局](protected-flash-layout.zh_CN.md):受保护的 `cardid` 地址、应用大小、分区表 MD5 以及单机身份数据不入包。
固件门禁使用全新的临时构建目录,并从仓库 `sdkconfig.defaults` 生成隔离的 `sdkconfig`。它不会读取或覆盖开发者根目录的 `sdkconfig`,只把验证通过的合并镜像复制到 `build/FoloToy-AI-Passport-full.bin`。门禁同时验证[当前配置的固件布局](firmware-layout.zh_CN.md):从 `flash_args` 读取镜像偏移,检查分区表 MD5、边界和不重叠,并确认应用从所配置的 app 分区起点开始且未超出分区。允许用户自定义分区布局。
当前基线含一个可独立运行的纯逻辑测试:
@@ -64,7 +69,7 @@ cc -std=c11 -Wall -Wextra -Werror -Imain \
```bash
./tools/validate.sh --static # 仓库一致性、workflow、文档链接、敏感信息、host tests
./tools/validate.sh --firmware # ESP-IDF build、merge-bin、偏移与保护布局校验
./tools/validate.sh --firmware # ESP-IDF build、merge-bin、偏移与当前布局校验
./tools/validate.sh # 完整验证
```
@@ -5,8 +5,8 @@
# Coding Conventions
- Write C with four-space indentation and K&R braces, following neighboring files. Use `snake_case`, `BSP_*` public constants, `s_` file-local state, `bsp_` public BSP APIs, and `demo_<feature>_<action>` demo entry points. Prefer `static` for internal symbols.
- Keep UI text and default documentation in English. Explanatory source comments may use Chinese while retaining established English technical terms.
- The baseline enables only LVGL Montserrat 14 and 20, which do not contain CJK glyphs. Chinese UTF-8 text therefore renders as missing-glyph boxes; changing source-file encoding does not fix it. Before adding Chinese UI text, compile and select a CJK font that covers every displayed character, prefer a glyph subset over a full font, configure a suitable fallback for mixed-language text, budget Flash and internal RAM, and verify the result on the device.
- Keep baseline-demo UI text and default documentation in English. Application UI may use Chinese when its font support is implemented and verified. Explanatory source comments may use Chinese while retaining established English technical terms.
- Before adding Chinese UI text, complete the [font checklist](#chinese-fonts-and-missing-glyphs); changing strings to UTF-8 alone does not add missing glyphs.
- Put reusable hardware behavior in `components/bsp`; keep menus, animations, product interaction, and validation pages in `main`.
- The `ui_pixel` theme (sky background, grass, title plate, mascot, ink-outlined panels) is part of the user interface, not a removable component. When trimming components or routing straight to a feature screen, keep the theme and build the screen through `ui_pixel_screen_create()` / `ui_pixel_panel_create()`.
- Show the battery level in the top-right corner of a user interface by default, unless the developer specifies a different placement or explicitly does not want it. Read it from `bsp_battery_soc()` (and `bsp_battery_mv()` where useful); render it as a small battery indicator or percentage in the top-right area of the screen, and degrade gracefully when it reads `-1` (unavailable). Place it where it does not overlap the existing cloud decoration (`add_cloud`, around `x≈188, y≈8`): use the clear sky space beside or below the cloud, or the very top-right edge, rather than covering the cloud.
@@ -15,3 +15,45 @@
- If adding a cache, define expiration and cleanup unless durable retention is explicitly justified.
- The ESP32-C3 has no PSRAM. Review internal RAM and largest-contiguous-block impact before increasing LVGL buffers, audio allocations, network state, or task stacks.
- **Watch power consumption.** This is a wearable powered by a small battery; keep it efficient. Avoid keeping the screen lit for long periods: dim or turn off the backlight, and return to a low-power state (light/deep sleep) whenever the screen is idle, so the device is not left displaying a bright screen while doing nothing. See the guidance on sleep in [`../hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md`](../../hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md).
## Chinese fonts and missing glyphs
For configuration, converter commands, CMake integration, safe fallback code, and glyph-check examples, follow the [detailed LVGL Chinese text guide](lvgl-chinese-fonts.md).
The baseline enables Montserrat 14 and 20 in [`sdkconfig.defaults`](../../../sdkconfig.defaults); neither contains Chinese glyphs. A correct UTF-8 string can therefore appear as boxes or blank text. Serial-console output, an installed computer font, and a successful firmware build do not prove that LVGL can render that text.
### Before implementing or changing Chinese UI
1. **Define coverage.** Collect all displayed text: titles, buttons, hints, empty/error states, units, punctuation, and dynamic content. Include Latin letters, digits, full-width punctuation, and any `LV_SYMBOL_*` icons in the chosen font or fallback chain. Regenerate each affected size/subset when text changes. A built-in CJK subset or a subset extracted from fixed UI strings does not guarantee arbitrary Chinese names, Wi-Fi SSIDs, or server/user input; define the supported character set and an explicit unsupported-character policy.
2. **Generate reproducible assets.** Select a licensed font whose source actually contains the required glyphs. Prefer a subset at the sizes needed by the application instead of embedding an entire font family. Keep reusable sources/generated files under `assets/fonts/` and record the license, converter version, command, character inventory, size, and bit depth in the [assets documentation](../../../assets/README.md). Use output compatible with the LVGL version pinned in [`dependencies.lock`](../../../dependencies.lock) (currently 9.5.0). See the [official font converter](https://github.com/lvgl/lv_font_conv) for generation options; this baseline does not bundle an application-specific Chinese font.
3. **Compile and select the font.** Add the generated `.c` file to the consuming component's CMake `SRCS`, declare its exported symbol with `LV_FONT_DECLARE`, and assign it to the actual text widget/part. Copying a TTF/OTF or `.c` into `assets/` does not automatically compile, load, or select it. Check the generated `sdkconfig` has `CONFIG_LV_TXT_ENC_UTF8=y`; changing defaults alone does not necessarily update an existing configuration (see [build and test](build-and-test.md)).
4. **Check style overrides and fallback.** Changing the default font or a screen's inherited font does not override explicit child fonts. [`main/ui_pixel.c`](../../../main/ui_pixel.c) sets a local font in `ui_pixel_label()` and explicitly uses Montserrat 20 for its title; menu/demo labels also select fonts directly. Audit titles, labels, widget parts, and focused/pressed/disabled states. For mixed text, use a font containing all required glyphs or a deliberate fallback chain. Do not cast away `const` to modify Flash-resident font descriptors, create fallback cycles, or free a font while widgets still use it.
5. **Budget resources.** Inspect Flash/static RAM after generation and free heap/largest free block at runtime, including when networking is active. Constant bitmap font data can reside in Flash; runtime font loading, decoding, and caches may need RAM. Do not blindly enlarge the LVGL heap or display buffers to treat missing glyphs; more memory cannot supply glyphs absent from the font.
For example, after generating and linking `app_font_20` with the required glyphs, select it explicitly. This symbol is illustrative, not a font supplied by this repository. Run object operations in the LVGL task or while holding `bsp_lvgl_lock()`:
```c
LV_FONT_DECLARE(app_font_20);
/* Inside the application's UI creation function. */
lv_obj_t *label = lv_label_create(parent);
lv_obj_set_style_text_font(label, &app_font_20, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(label, "\u4E2D\u6587 ABC 123");
```
### Troubleshooting order
| Symptom | Check first |
| --- | --- |
| Latin text works; Chinese is blank or boxed | Actual widget font and its fallback coverage, UTF-8 input, and `CONFIG_LV_TXT_ENC_UTF8`; disabling `CONFIG_LV_USE_FONT_PLACEHOLDER` only hides the missing-glyph indicator, not the defect |
| Only some characters or new text fail | Missing subset entries, punctuation, each font size, and dynamic text outside the supported set; regenerate and relink the affected assets |
| Body text works but titles/buttons or selected states fail | Explicit local fonts, theme/state overrides, and the font on the widget part that draws the text |
| Glyph coverage is correct but text is invisible or cut off | Text color/opacity, hidden flags, label size, line height, parent clipping, and draw/allocation errors; do not assume every blank label is a font defect |
### Required acceptance
- Check every required printable Unicode code point against each font/fallback chain actually used. With the pinned LVGL API, `lv_font_get_glyph_dsc()` must succeed and `is_placeholder` must be false; a placeholder is not coverage. Decode UTF-8 into code points rather than testing individual bytes. Record uncovered code points and add a repeatable coverage check alongside the application's font-generation pipeline.
- On the device, verify all pages and error/empty states, Chinese/Latin/digit/punctuation/icon mixtures, different sizes and interaction states, long text, and dynamic content both inside and outside the declared supported set. Check for boxes, blanks, clipping, and fallback baseline/line-height mismatches; do not accept one successful sample label as whole-application validation.
- Report the tested text/character set, font sizes, and resource changes. The baseline's host tests do not validate a derivative application's font coverage or screen output. Without a physical-device check, report `Device tests: NOT RUN` and explicitly list Chinese rendering under `Unverified`.
Font selection and fallback semantics: [LVGL 9.5 font overview](https://docs.lvgl.io/9.5/main-modules/fonts/overview.html). Missing-glyph handling: [LVGL 9.5 implementation](https://github.com/lvgl/lvgl/blob/v9.5.0/src/font/lv_font.c).
Loaded 3 of 78 files, more files were not shown because too many files have changed in this diff. Show more