--- kind: dependency_management name: "Dependency Management Across Multiple Build Systems: ESP-IDF Component Manager, MicroPython Manifest and Sphinx requirements" category: dependency_management scope: - '**' source_files: - esp32s3/firmware/main/idf_component.yml - esp32s3/firmware/components/esp_lcd_jd9853/idf_component.yml - esp32s3/firmware/components/gen_bmgr_codes/idf_component.yml - esp32s3/firmware/boards/manifest.py - esp32s3/firmware/boards/mpython_v3/manifest.py - firmware/port/boards/manifest.py - esp32s3/firmware/eim_config.toml - esp32s3/docs/requirements.txt - firmware/port/Makefile --- # 1. Systems and Tools in Use This repository maintains two firmware trees at the same time (firmware/port/, based on the ESP32 MicroPython port; esp32s3/firmware/, based on ESP-IDF v5.x + MicroPython v1.24.1) plus the Sphinx documentation, so three parallel dependency declaration mechanisms exist: - **ESP-IDF Component Manager** (`idf_component.yml`): used for the C/C++ component dependencies of esp32s3/firmware, pulled from the official Espressif component registry through the `espressif/xxx` namespace. - **MicroPython frozen manifest** (`manifest.py` / `mpconfigboard.mk`): used to compile Python modules into the firmware image (frozen bytecode), controlling the standard library and third-party packages available at runtime. - **Sphinx documentation dependencies** (`docs/requirements.txt`): pin the Python package versions required to build the documentation. In addition, `esp32s3/firmware/eim_config.toml` uses EIM (Espressif Install Manager) to configure the IDF toolchain, the Python environment, and the PyPI mirror (Tsinghua tuna), enabling accelerated local downloads. # 2. Key Files and Locations | Layer | Key file | Purpose | |---|---|---| | S3 firmware top level | `esp32s3/firmware/main/idf_component.yml` | Declares the ESP-IDF component dependencies (mdns, tinyusb, esp-sr, esp_audio_codec, esp_video_codec, esp32-camera, joltwallet/littlefs, esp_websocket_client, and more) | | S3 custom component | `esp32s3/firmware/components/esp_lcd_jd9853/idf_component.yml` | Display driver component; declares dependencies on `cmake_utilities` and `idf >= 4.4` | | S3 code generation component | `esp32s3/firmware/components/gen_bmgr_codes/idf_component.yml` | Depends on `compents/esp_lcd_jd9853: 2.0.2` | | S3 board-level manifest | `esp32s3/firmware/boards/*/manifest.py` | Reuses the base package set through `include("$(PORT_DIR)/boards/manifest.py")`, then pulls in the on-board Python modules with `freeze("modules")` | | S3 base manifest | `esp32s3/firmware/boards/manifest.py` | Enables MicroPython packages such as `bundle-networking`, `aioespnow`, `dht`, `ds18x20`, `onewire`, `upysh`, and `collections` | | ESP32 port manifest | `firmware/port/boards/manifest.py` | Freezes `$(PORT_DIR)/modules` and `$(BOARD_DIR)/modules` into the firmware | | Documentation dependencies | `esp32s3/docs/requirements.txt` | Pins the exact versions of 276 packages such as Sphinx, Jupyter, PyQt, and NumPy | | Toolchain configuration | `esp32s3/firmware/eim_config.toml` | Specifies the IDF path, the toolchain directory, the PyPI mirror (`https://pypi.tuna.tsinghua.edu.cn/simple`), and the IDF mirror (`https://jihulab.com/esp-mirror`) | | Build script | `firmware/port/Makefile` | Requires the `ESPIDF` environment variable to point at a supported git hash (v3.3.2 or v4.0.1) and initializes submodules through `make submodules` | # 3. Architecture and Conventions ## 3.1 Layered Component Sources - **Official components**: referenced through the `espressif/xxx` namespace, with version numbers expressed as semantic constraints (`~1.1.0`, `^2.0`, `==1.5.4`, `>=5.2.0`, and so on). Examples: `espressif/mdns: ~1.1.0`, `espressif/esp32-camera: ^2.0`. - **Git branch override**: `tinyusb` uses `git: https://github.com/micropython/tinyusb-espressif.git` + `version: cherrypick/dwc2_zlp_fix` to temporarily work around upstream issue #3154, illustrating the strategy of "replacing an upstream version with a patched branch". - **Local override_path**: all GMF (Graphics & Multimedia Framework) related components (`gmf_loader`, `gmf_app_utils`, `esp_capture`, `esp_board_manager`, `gmf_core`, `gmf_io`, `gmf_audio`, `gmf_ai_audio`, `gmf_video`, `gmf_misc`, `esp_audio_render`) point to external Git submodules through `override_path: ../../esp-gmf/...` and bypass the component registry entirely. - **Third-party components**: `joltwallet/littlefs: ==1.20.4` is pinned exactly as the file system backend. ## 3.2 MicroPython Package Freezing Strategy - The base network stack is pulled in in bulk through `require("bundle-networking")`. - Sensor and communication protocols (`dht`, `ds18x20`, `onewire`, `aioespnow`) are declared explicitly through `require()`. - Board-level Python modules are compiled into the firmware from the `.py` files in `esp32s3/firmware/modules/` through `freeze("modules")`, forming the modules available at runtime (such as `ai_cloud.py`, `ATGM336H_5N.py`, `neopixel.py`, `weather.py`, `xunfei.py`, and more). - The ESP32 port (`firmware/port/`) likewise freezes `port/modules` and `port/boards//modules` through `manifest.py`. ## 3.3 Documentation Dependency Pinning `esp32s3/docs/requirements.txt` is a typical pip freeze artifact. It contains 276 lines of exact versions (such as `Sphinx @ file:///...`, `PyQt==1.9.0`, `numpy @ file:///...`), and many entries use the `@ file:///` form pointing at wheels in the CI build cache, which shows that the file is mainly intended for CI reproducibility rather than for local developer installation. In actual development it should be used together with `python -m venv` and `pip install -r requirements.txt`. ## 3.4 Toolchain and Mirrors `eim_config.toml` explicitly configures mirrors inside China: - `mirror = "https://dl.espressif.cn/github_assets"` - `idf_mirror = "https://jihulab.com/esp-mirror"` - `pypi_mirror = "https://pypi.tuna.tsinghua.edu.cn/simple"` This ensures that the IDF toolchain, the Python packages, and the GitHub Assets are all downloaded from mirrors inside China, improving build speed. # 4. Conventions and Constraints - **ESP-IDF version pinning**: `firmware/port/Makefile` hard-codes the supported IDF commit hashes through `ESPIDF_SUPHASH_V3` / `ESPIDF_SUPHASH_V4` and validates the git hash of the current IDF at build time; on mismatch it prints a WARNING and continues (not a fatal error). - **Python version constraint**: the ESP32 port requires `pyparsing==2.3.1` (<2.4) and exits with an error otherwise; the S3 port specifies `python_version_override = "python313"` in `eim_config.toml`. - **Submodule management**: the README explicitly requires `git clone --recursive` and `make submodules`. GMF related components point at the external `esp-gmf` submodule through `override_path` and must be maintained separately. - **Private/local component isolation**: all GMF components point to local paths through `override_path`, which keeps them out of the public component registry and makes internal iteration easier. - **upip is not enabled**: the freeze call for `upip.py` in `manifest.py` is commented out, showing that the firmware does not include a remote package manager and that dependencies must be frozen into the image at build time. - **No vendored third-party source**: apart from a few in-house libraries such as `lib/decode_png` and `lib/utils`, no `vendor/` directory was found; third-party C components are pulled exclusively through the ESP-IDF Component Manager. - **Documentation and firmware are decoupled**: `docs/requirements.txt` is only used for the Sphinx build and does not affect firmware compilation; firmware dependencies are concentrated in the two files `idf_component.yml` and `manifest.py`.