This document provides comprehensive documentation for the ESP-IDF configuration system, including
YAML configuration management, validation, and integration with all scripts.
π Table of Contents
π Overview
The ESP-IDF configuration system provides centralized,
intelligent configuration management for all scripts in the HardFOC Interface Wrapper project.
It features YAML-based configuration, automatic validation, intelligent fallbacks,
and cross-platform compatibility.
Core Features
Centralized Configuration: Single YAML file manages all script behavior
Enhanced Validation: Smart combination validation and error prevention
Smart Defaults: Automatic ESP-IDF version selection based on app and build type
Smart Fallbacks: Graceful degradation when configuration is incomplete
Cross-Platform: Consistent behavior across Linux and macOS
Environment Integration: Environment variable overrides and customization
Key Capabilities
YAML configuration parsing with yq and fallback methods
Smart combination validation - Prevents invalid app + build type + IDF version combinations
Automatic ESP-IDF version selection - Chooses the right version when not specified
## Check if a build combination is valid
is_valid_combination(){local app_type="$1"local build_type="$2"local idf_version="$3"# Validate app type existsif! is_valid_app_type "$app_type";then return 1;fi# Validate build type is supportedif! is_valid_build_type "$build_type";then return 1;fi# Check if app supports this IDF versionlocal app_idf_versions_array=$(get_app_idf_versions_array "$app_type")if!echo"$app_idf_versions_array" | grep-q"$idf_version";then return 1;fi# Check if app supports this build type for this IDF versionlocal app_build_types=$(get_build_types "$app_type")local clean_build_types=$(echo"$app_build_types" | sed's/\[//g' | sed's/\]//g' | sed's/"//g' | tr','' ')if[["$clean_build_types"==*"$build_type"*]];then return 0;fi
return 1
}
Smart Default Selection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
## Enhanced IDF version selection with comprehensive validation## Now handled by enhanced get_idf_version() and is_valid_combination()## Get app-specific IDF version with fallbackidf_version=$(get_idf_version "gpio_test")## Comprehensive combination validationif is_valid_combination "gpio_test""Release""release/v5.5";then
echo"Valid combination for CI pipeline"fi## Enhanced build type validation with app overridesif is_valid_build_type "Release""gpio_test""release/v5.5";then
echo"Valid build type for app and IDF version"fi
## Application definitions and configurationsapps:ascii_art:description:"ASCIIartgeneratorapplication"source_file:"AsciiArtComprehensiveTest.cpp"category:"utility"build_types:["Debug","Release"]idf_versions:["release/v5.5"]ci_enabled:truefeatured:truedependencies:[]tags:["demo","utility","ascii"]gpio_test:description:"GPIOperipheraltestingapplication"source_file:"GpioComprehensiveTest.cpp"category:"peripheral"build_types:["Debug","Release"]idf_versions:["release/v5.5"]ci_enabled:truefeatured:truedependencies:["gpio_driver"]tags:["peripheral","gpio","testing"]adc_test:description:"ADCperipheraltestingapplication"source_file:"AdcComprehensiveTest.cpp"category:"peripheral"build_types:["Debug","Release"]idf_versions:["release/v5.5"]ci_enabled:truefeatured:falsedependencies:["adc_driver","gpio_driver"]tags:["peripheral","adc","analog"]
## System and environment configurationsystem_config:# Operating system supportplatforms:-"linux"-"macos"# Shell requirementsshell:"bash"min_bash_version:"4.0"# Python requirementspython_version:"3.6+"required_packages:["PyYAML"]# Tool requirementsrequired_tools:["git","cmake","ninja","ccache"]optional_tools:["yq","screen","tmux"]# Cache configurationcache_directories:-"$HOME/.ccache"-"$HOME/.espressif"-"$HOME/.cache/pip"
Configuration File Validation
YAML Schema Validation
The configuration system validates:
Syntax: Valid YAML format and structure
Required Fields: Essential configuration elements
Data Types: Correct data types for each field
Relationships: Valid references between sections
Constraints: Value ranges and valid options
Configuration Integrity Checks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
## Validation rulesvalidation:# App validationapps:-source_file must exist-build_types must be valid-idf_versions must be supported# Build type validationbuild_types:-cmake_build_type must be valid-optimization flags must be valid-defines must be strings# Metadata validationmetadata:-default_app must exist in apps-default_build_type must be valid-target must be supported
The configuration system supports portable scripts through the PROJECT_PATH environment variable
and --project-path command-line flag.
Project Path Resolution
1
2
3
4
## Priority order for project path resolution:
1. --project-path command-line flag
2. PROJECT_PATH environment variable
3. Default: ../ relative to script location
Portable Usage Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
## Using --project-path flag
./build_app.sh --project-path /path/to/project gpio_test Release
./flash_app.sh --project-path ../project flash_monitor adc_test
./manage_idf.sh --project-path /opt/esp32-project list
## Using PROJECT_PATH environment variableexport PROJECT_PATH=/path/to/project
./build_app.sh gpio_test Release
./flash_app.sh flash_monitor adc_test
## Python scripts
python3 get_app_info.py list --project-path /path/to/project
python3 generate_matrix.py --project-path /path/to/project
Configuration File Discovery
When using portable scripts, the system automatically:
Resolves the project directory path (absolute or relative)
Looks for app_config.yml in the project directory
Validates that the configuration file exists
Loads and parses the configuration
Error Handling
1
2
3
## Clear error messages for missing project or config
ERROR: PROJECT_PATH specified but app_config.yml not found: /path/to/project/app_config.yml
Please check the project path or unset PROJECT_PATH to use default location.
## Configuration initialization
init_config # Initialize configuration system
load_config_yq # Load configuration using yq
load_config_basic # Load configuration using fallback method## Configuration validation
validate_current_config # Validate current configuration
validate_app_type # Validate application type
validate_build_type # Validate build type## Configuration access
get_app_types # Get all available application types
get_app_description # Get application description
get_app_source_file # Get application source file
get_app_category # Get application category
get_build_types # Get all available build types
get_idf_versions # Get supported ESP-IDF versions
get_app_idf_versions # Get ESP-IDF versions for specific app
get_build_types # Get build types (with app override support)## Configuration utilities
get_build_directory # Get build directory path
get_project_name # Get project name
get_build_directory_pattern # Get build directory pattern
get_project_name_pattern # Get project name pattern
Helper Functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
## YAML processing
check_yq # Check if yq is available
run_yq # Execute yq with appropriate syntax
detect_yq_version # Detect yq version and set syntax## Validation helpers
is_valid_app_type # Check if app type is valid
is_valid_build_type # Check if build type is valid
is_valid_idf_version # Check if ESP-IDF version is valid
is_valid_combination # Check if app + build type + IDF version combination is valid## Configuration utilities
get_featured_app_types # Get featured application types
is_ci_enabled # Check if app is CI-enabled
is_featured # Check if app is featured
## Standard app_config.ymlmetadata:default_app:"gpio_test"default_build_type:"Release"target:"esp32c6"idf_versions:["release/v5.5"]description:"ESP32HardFOCInterfaceWrapper"version:"2.1.0"apps:gpio_test:description:"GPIOtestingapplication"source_file:"GpioComprehensiveTest.cpp"category:"peripheral"build_types:["Debug","Release"]idf_versions:["release/v5.5"]ci_enabled:truefeatured:truebuild_config:build_types:Debug:cmake_build_type:"Debug"optimization:"-O0"debug_level:"-g3"Release:cmake_build_type:"Release"optimization:"-O2"debug_level:"-g"
## Advanced app_config.yml with all featuresmetadata:default_app:"gpio_test"default_build_type:"Release"target:"esp32c6"idf_versions:["release/v5.5","release/v5.4"]description:"ESP32HardFOCInterfaceWrapper-AdvancedConfiguration"version:"2.1.0"last_updated:"2025-01-15"maintainer:"HardFOCTeam"repository:"https://github.com/example/hf-internal-interface-wrap"apps:gpio_test:description:"ComprehensiveGPIOtestingandvalidationapplication"source_file:"GpioComprehensiveTest.cpp"category:"peripheral"build_types:["Debug","Release","RelWithDebInfo"]idf_versions:["release/v5.5","release/v5.4"]ci_enabled:truefeatured:truedependencies:["gpio_driver","common_utils"]tags:["peripheral","gpio","testing","validation"]test_timeout:300memory_requirements:"2MB"adc_test:description:"ADCperipheraltestingandcalibrationapplication"source_file:"AdcComprehensiveTest.cpp"category:"peripheral"build_types:["Debug","Release"]idf_versions:["release/v5.5"]ci_enabled:truefeatured:falsedependencies:["adc_driver","gpio_driver","calibration"]tags:["peripheral","adc","analog","calibration"]test_timeout:600memory_requirements:"3MB"build_config:build_types:Debug:description:"Debugbuildwithmaximumdebugginginformation"cmake_build_type:"Debug"optimization:"-O0"debug_level:"-g3"defines:["DEBUG","VERBOSE_LOGGING","ASSERTIONS_ENABLED"]assertions:truelogging_level:"DEBUG"stack_usage:truesanitizers:["address","undefined"]Release:description:"Production-readyoptimizedbuild"cmake_build_type:"Release"optimization:"-O2"debug_level:"-g"defines:["NDEBUG","PRODUCTION_BUILD"]assertions:falselogging_level:"INFO"stack_usage:falsesanitizers:[]RelWithDebInfo:description:"Releasebuildwithdebuginformationforprofiling"cmake_build_type:"RelWithDebInfo"optimization:"-O2"debug_level:"-g"defines:["NDEBUG","PROFILING_ENABLED"]assertions:falselogging_level:"INFO"stack_usage:falsesanitizers:[]build_directory_pattern:"build*{app_type}*{build_type}*{idf_version}"project_name_pattern:"esp32*{app_type}*app"ccache_enabled:trueparallel_builds:trueincremental_builds:truesize_analysis:truedependency_checking:truewarning_as_errors:falseflash_config:auto_detect_ports:trueport_scan_timeout:5port_test_timeout:3flash_mode:"dio"flash_freq:"80m"flash_size:"4MB"monitor_baud:115200auto_logging:truelog_rotation:truemax_log_files:50log_retention_days:30system_config:platforms:["linux","macos"]shell:"bash"min_bash_version:"4.0"python_version:"3.6+"required_packages:["PyYAML"]required_tools:["git","cmake","ninja","ccache"]optional_tools:["yq","screen","tmux"]cache_directories:["$HOME/.ccache","$HOME/.espressif","$HOME/.cache/pip"]
π Enhanced Functionality
App-Specific Overrides
Smart Build Type Handling: get_build_types(app_type) now checks app-specific overrides first
Version-Aware Validation: Functions now understand the relationship between IDF versions and build types
Intelligent Fallbacks: When app overrides arenβt specified, functions fall back to metadata defaults
π Enhanced Validation Functions
is_valid_build_type(build_type, app_type, idf_version): Comprehensive validation with app and version context
is_valid_combination(app_type, build_type, idf_version): Single function for complete combination validation
get_app_build_types_for_idf_version(app_type, idf_version): Get build types for specific app-IDF combinations
CI Pipeline Optimization
Robust Combination Validation: Prevents invalid app + build type + IDF version combinations
Smart Error Messages: Clear guidance on what combinations are allowed
Fallback Parsing: Works reliably even when yq is not available in CI environments
Enhanced Function Examples
Smart Build Type Retrieval
1
2
3
4
5
6
## Before: Only global build typesbuild_types=$(get_build_types)# Returns: Debug Release## After: App-specific with fallbackbuild_types=$(get_build_types)# Global: Debug Releaseapp_build_types=$(get_build_types "gpio_test")# App-specific: Debug Release
Comprehensive Validation
1
2
3
4
5
6
7
8
9
## Before: Separate validation functions
validate_app_type "gpio_test"
validate_build_type "Release"
validate_app_idf_version "gpio_test""release/v5.5"## After: Single comprehensive validationif is_valid_combination "gpio_test""Release""release/v5.5";then
echo"Valid combination for CI pipeline"fi
Version-Aware Build Type Validation
1
2
3
4
5
6
7
8
## Enhanced validation with contextif is_valid_build_type "Release""gpio_test""release/v5.5";then
echo"Valid build type for app and IDF version"fi## Get version-specific build typesversion_build_types=$(get_build_types_for_idf_version "release/v5.5")echo"Build types for v5.5: $version_build_types"
Migration Guide
Functions Removed in Version 2.0
get_app_build_types() β Use get_build_types(app_type) instead
validate_app_build_type() β Use is_valid_build_type(build_type, app_type) instead
validate_app_idf_version() β Use is_valid_combination(app_type, build_type, idf_version) instead
get_idf_version_smart() β Use get_idf_version(app_type) + is_valid_combination() instead
Updated Function Signatures
1
2
3
4
5
6
7
## Before
get_build_types()# Only global
is_valid_build_type(build_type)# Basic validation## After
get_build_types([app_type])# Global or app-specific
is_valid_build_type(build_type, [app_type], [idf_version])# Comprehensive validation