Code Generation and Build Integration
Before compilation, BMGR parses the board’s YAML description into a set of explicit configuration source files and build inputs. idf.py bmgr is the user-facing entry command.
When running idf.py bmgr -b <board>, BMGR performs the following steps in order:
Scans board directories, collecting candidate boards from the default directory, custom directory, and component directories.
Determines the currently selected board based on the command-line arguments (name or index).
Locates the board’s
board_peripherals.yaml,board_devices.yaml,board_info.yaml,sdkconfig.defaults.board, andKconfig.projbuild.Parses peripherals and devices, generating corresponding configuration structures, handle tables, and board-level metadata.
Generates the
Kconfig.projbuildfor the current board and appends the board directory’sKconfig.projbuild.Generates
board_manager.defaults, connecting the board’s default configuration and capability symbols to the build.Outputs the source files, build files, and tooling summary files under
components/gen_bmgr_codesfor compilation.
In BMGR’s model, board configuration code comes from the YAML file description and the script’s parsing and generation process, not from manually selecting devices or peripherals in menuconfig. components/gen_bmgr_codes is not a cache or a view-only intermediate artifact; it is an actual component that participates in the ESP-IDF build.
Generated Output Files
File |
Description |
|---|---|
|
Peripheral configuration structure definitions generated from |
|
Generated peripheral handle entry points, type mappings, and initialization function hooks. |
|
Device configuration structure definitions generated from |
|
Generated device handle entry points, initialization/deinitialization function mappings, and device linked list. |
|
Generated board-level metadata, such as board name, chip, version, description, and manufacturer. |
|
Configuration struct definitions for |
|
|
|
Kconfig symbol definitions and selection entries for the current board, projecting board-level capabilities into the project configuration system. |
|
Component dependency manifest for the current board; device |
|
A unified board-level summary for tooling and debugging; useful for viewing the devices, peripherals, component dependencies, and occupied I/O of the current board. |
BMGR does not organize compilation by manually selecting devices or peripherals one by one in menuconfig; instead, it first generates board_manager.defaults from the board-level YAML, and the board capability macros contained therein take effect during the subsequent build. When running idf.py, BMGR injects these settings into sdkconfig to drive BMGR’s conditional compilation.
During debugging, it is recommended to triage by symptom:
If the behavior does not match expectations, check
gen_board_periph_config.candgen_board_device_config.cfirst.If the symptom is a build failure or dependency resolution error, check whether the generated files under
components/gen_bmgr_codesare complete, whether the capability symbols inboard_manager.defaultsmatch expectations, and whethersdkconfigis consistent withboard_manager.defaults.