1. Build System and Toolchain
This repository’s ESP32-S3 product line adopts a unified, modern firmware build system:
ESP32-S3 mPython Board series (
esp32s3/firmware/): Built with ESP-IDF v5.x (defaultv5.5.4, seeeim_config.toml) + CMake; the top-levelCMakeLists.txtselects the board viaMICROPY_BOARD, automatically concatenates theSDKCONFIG_DEFAULTSlist to generatesdkconfig.combined, is ultimately driven to compile by IDF’sproject.cmake, and parses the partition table viamakeimg.pyto generate.binand.uf2.
The documentation side uses Sphinx (esp32s3/docs/conf.py) and generates the Chinese manual via make html / make.bat, separate from the firmware source code; mPython Core 2.0’s esp32s3/docs/boards/ledong_v2/ can be built independently.
2. Key Files and Packages
Build entry points:
esp32s3/firmware/CMakeLists.txt,esp32s3/firmware/esp32_common.cmake,esp32s3/firmware/makeimg.py(parses the partition table, generates bin/uf2, injects voice_data/srmodels).Board-level configuration:
esp32s3/firmware/boards/<board>/mpconfigboard.cmake(declaresIDF_TARGET=esp32s3,SDKCONFIG_DEFAULTS,MICROPY_SOURCE_BOARD,MICROPY_FROZEN_MANIFEST),partitions-16MiB.csv(defines the factory/vfs/voice_data/model/fr/user_nvs partitions),sdkconfig.board(Kconfig options such as audio/GMF AI voice, BLE, SPIRAM).Environment configuration:
esp32s3/firmware/eim_config.toml(specifies the IDF path, toolchain versions, and mirror sources).Release script:
esp32s3/firmware/makeimg.pydynamically reads offsets from the partition table and validates overflow, avoiding manual hard-coding.
3. Architecture and Conventions
3.1 Multi-Board Abstraction
Selects
boards/<board>/mpconfigboard.cmakeviaMICROPY_BOARD(defaultmpython_v3) and supports theMICROPY_BOARD_VARIANTvariant; each board has its ownsdkconfig.board,partitions-*.csv, andmanifest.py.
3.2 Configuration Layering
Base configuration:
sdkconfig.baseprovides common Kconfig values.Capability switches: composable fragments such as
sdkconfig.ble,sdkconfig.spiram,sdkconfig.usb.Board-specific:
sdkconfig.boardcentralizes board-level peripherals (such as the S3’s GMF AI Audio and SR_WN_WN9_NIHAOXIAOZHI_TTS).Build-time concatenation: in CMake,
foreach(SDKCONFIG_DEFAULT ${SDKCONFIG_DEFAULTS})writes tosdkconfig.combined.in, which is then copied tosdkconfig.combined.
3.3 Firmware Image Assembly
CMake builds
micropython.bin+ bootloader + partition-table.bin;makeimg.pyfirst callsmklittlefsto packagefile_system/<board>intolittlefs.bin, then writes to the vfs/voice_data/model partitions according to the partition-table offsets, and finally generates an additional.uf2for S3/S2 chips.
3.4 Python Module Freeze Strategy
boards/manifest.pyincludesasyncio, requiresbundle-networking,aioespnow,dht,ds18x20,onewire,upysh,collections, and other standard libraries, and appends custom Python modules per board.
3.5 Dependency and Toolchain Management
Declares
idf_versions=["v5.5.4"]and the required toolsets (xtensa/riscv/clang/ninja/openocd) viaeim_config.toml.Uses
lockfiles/dependencies.lock.esp32s3to constrain the component versions pulled by the ESP-IDF Component Manager; under CI, a build fails if the lockfile changes.
4. Conventions and Constraints
Board naming: ESP32-S3 boards reside uniformly under
esp32s3/firmware/boards/<name>/; five are currently supported:mpython_v3,labplus_Ledong_v2,labplus_for_xuejing,labplus_xunfei_js_middle, andlabplus_xunfei_js_primary.Partition-table-driven layout: All offsets come from
partitions-*.csv, parsed bymakeimg.pyviagen_esp32part.PartitionTable.from_binary(); any manual modification must synchronously update the CSV; the build assertsoffset >= cur_offsetto prevent overlap.VFS file system: Uses LittleFS; packages the contents of the two subdirectories
file_system/common/*andfile_system/<board>/*viamklittlefsand writes them into thevfspartition.Font resources:
makeimg.pyreferences theNoto_Sans_CJK_SC_Light16.binfont file for GUI display.Version information:
makeimg.pyalso extractsgit describe --tags, the short hash, and the build date into the firmware filename for version traceability.Build artifact isolation: Outputs to the CMake
BUILDdirectory (defaultbuild/) to avoid conflicts during parallel multi-board builds.Documentation-firmware decoupling:
esp32s3/docs/contains only Sphinx sources and example code and does not participate in firmware compilation; example code resides inesp32s3/docs/3_examples/andesp32s3/firmware/examples/, for user reference rather than as part of the build system.