1. System / Framework
The runtime configuration system of the ESP32-S3 product line in this repository is built on top of ESP-IDF v5.x + MicroPython v1.24.1 and is organized as three stacked layers:
Build-time configuration: composed from the ESP-IDF
sdkconfig.*fragments through CMake, controlling compiler options and the low-level behaviour of LWIP/mbedTLS/FreeRTOS and friends.Board-level configuration: the
mpconfigboard.hof each board type determines the enabled Python built-in modules, VFS, USB REPL, I2C/SPI pin mapping, and so on.Runtime persistent configuration: user settings are stored as key/value pairs in the ESP32-S3 NVS (Non-Volatile Storage) and exposed to Python as the
esp32.NVStype.File system / application scripts: at boot the frozen
_boot.py, thenboot.pyandmain.pyin LittleFS, are executed in order and serve as the application-level configuration entry points.Development tool configuration:
esp32s3/firmware/eim_config.tomlis the local environment configuration of the EIM (Espressif IoT Manager) tool and takes no part in firmware compilation.
2. Key Files and Locations
ESP-IDF sdkconfig fragments (build time):
esp32s3/firmware/boards/sdkconfig.base,sdkconfig.ble,sdkconfig.spiram*,sdkconfig.p4_wifi_*,sdkconfig.riscv,sdkconfig.flash_2MiB,sdkconfig.free_ram, and more; thesdkconfig.boardandsdkconfig.usbfiles in each board directory override the defaults.MicroPython board-level configuration:
esp32s3/firmware/boards/*/mpconfigboard.h(one per board) declaresMICROPY_HW_BOARD_NAME,MICROPY_HW_MCU_NAME, the pins, and the feature switches (such asMICROPY_PY_AUDIO,MICROPY_PY_RFID);mpconfigboard.cmakedeclaresIDF_TARGET=esp32s3,SDKCONFIG_DEFAULTS,MICROPY_SOURCE_BOARD, andMICROPY_FROZEN_MANIFEST.Board-level main.c:
esp32s3/firmware/builtins/main.c(the common S3 entry point) andesp32s3/firmware/boards/*/main.c(board-specific entry points) are responsible for initializing NVS, creating mp_task, and loading_boot.py/boot.py/main.py.NVS Python interface:
esp32s3/firmware/builtins/esp32_nvs.cimplements theNVS(namespace)object and theget_i32/set_i32/get_blob/set_blob/erase_key/commitmethods, always using theuser_nvsnamespace.Partition table:
esp32s3/firmware/boards/*/partitions-*.csv(such aspartitions-16MiB.csv) defines thenvs,phy_init,factory,vfs(spiffs/littlefs),voice_data(fat),model(spiffs), anduser_nvspartitions.Application scripts: each board type can place its own
boot.py/main.pyin thefile_system/<board>/directory;makeimg.pypacks them into a LittleFS image that is written to thevfspartition.EIM tool configuration:
esp32s3/firmware/eim_config.tomlis only used for the local EIM toolchain installation path and mirror settings and does not end up in the firmware.
3. Architecture and Design Conventions
Layered configuration:
sdkconfig.baseprovides the common baseline, eachsdkconfig.*fragment is stacked according to a feature (BLE, PSRAM, Wi-Fi chip family, RISC-V), and the board-levelsdkconfig.board/sdkconfig.usbthen override the concrete hardware differences. Adding a board type requires copying one set and modifyingmpconfigboard.h,partitions-*.csv, andsdkconfig.board.Board type enumeration: the S3 firmware supports 5 board types –
mpython_v3,labplus_for_xuejing,labplus_Ledong_v2,labplus_xunfei_js_middle,labplus_xunfei_js_primary. Each has its ownmpconfigboard.h,main.c,partitions-*.csv,manifest.py, and so on underesp32s3/firmware/boards/<board>/.The boot flow is the configuration loading flow:
app_main()->MICROPY_BOARD_STARTUP()(which by default callsboardctrl_startup()to initialize NVS) ->xTaskCreatePinnedToCore(mp_task, ...)-> insidemp_task,pyexec_frozen_module("_boot.py")->pyexec_file_if_exists("boot.py")-> if the friendly REPL is active and no forced exit was requested,pyexec_file_if_exists("main.py"). Thereforeboot.py/main.pyare the main mount points for application-level configuration.NVS namespace convention: all NVS reads and writes go through
esp32.NVS("user_nvs"), opening the namespace nameduser_nvs, which is provided by theuser_nvspartition in the partition table (offset0xFFC000, size0x4000). Keys are strings; values support i32 and blob.Log levels:
sdkconfig.basesets the default log level toERRORand the maximum level toINFOso thatesp.osdebug()can raise the log level at runtime.USB/serial REPL selection: S3 board types switch between USB Serial JTAG, native USB OTG, and UART REPL through the
MICROPY_HW_ESP_USB_SERIAL_JTAG,MICROPY_HW_ENABLE_USBDEV, andMICROPY_HW_ENABLE_UART_REPLmacros.Memory and VFS: S3 board types enable
MICROPY_VFS,MICROPY_FATFS_ENABLE_LFN, andMICROPY_MODULE_FROZEN_MPY=1, which together with thevfs(LittleFS) partition in the partition table allows Python code to be loaded from the file system.
4. Conventions and Constraints
Configuration set required for a new board type: at a minimum
mpconfigboard.h,mpconfigboard.cmake,main.c,partitions-*.csv,sdkconfig.board, andmanifest.py(optional), plus registration in the top-level CMake underboards/.NVS writes must be committed: the
commit()method exposed byesp32_nvs.cflushes the buffer to Flash; not calling it can cause data loss.NVS corruption recovery:
boardctrl_startup()automatically erases and retries whennvs_flash_init()returnsESP_ERR_NVS_NO_FREE_PAGESorESP_ERR_NVS_NEW_VERSION_FOUND, avoiding a hang at boot.Application configuration takes precedence over build configuration:
boot.py/main.pycan override at runtime the behaviour determined by build-time macros (for example enabling debug logs dynamically or switching network parameters), but they cannot change theMICROPY_*macros already compiled into the firmware.The partition layout must not be changed casually: the
user_nvspartition sits at the end of the partition table (0xFFC000) and its size0x4000is the upper limit of the NVS storage capacity; modifying the partition table requires a matching update ofCONFIG_PARTITION_TABLE_CUSTOM_FILENAMEinsdkconfig.base.The EIM configuration is for developer machines only: fields such as
path,idf_path, andmirrorineim_config.tomlpoint at local paths and should not be committed to version control in a way that affects other people’s builds (the current repository keeps sample values).Platform identification: S3 board types distinguish the MCU model through
MICROPY_HW_MCU_NAME = "ESP32S3"; applications can determine the target chip throughsys.platformand themachinemodule.
5. Relationship with Documentation and Examples
The documentation side (
esp32s3/docs/) is mainly aimed at teachers, students, and developers, describing APIs and tutorials rather than build-time configuration details; however,mpython.rstunderlibrary/mPython/and the source filempython.pywrap the on-board features, and the availability of those features is controlled by macros inmpconfigboard.h(such asMICROPY_PY_AUDIO,MICROPY_PY_RFID).Example programs usually live in
esp32s3/firmware/examples/or in thefile_system/directory of each board type; they are loaded by the boot flow throughboot.py/main.py, which is the real-world usage of “application-level configuration”.