Skip to main content

Kernel Configuration System

ElenixOS manages compile-time kernel configuration via Kconfig. Final effective values are determined by two independent merge stages: the Kconfig merge layer and the C preprocessor layer.

Kconfig Merge Layer

The script kconfig.py genconfig merges the following three layers using replace=Truelater values overwrite earlier ones:

  1. Kconfig built-in default statements — kernel-defined baseline defaults
  2. defaults.conf — version-controlled file establishing the project baseline
  3. build/.config — unversioned file storing local modifications from menuconfig

The merge output is written to build/generated/eos_config_gen.h. Each value maps one-to-one to its native macro name, emitted under an #ifndef guard.

C Preprocessor Layer

The header eos_config.h includes configuration definitions in a fixed order, with all symbols guarded by #ifndeffirst definition wins:

  1. Compiler -D flags
  2. eos_platform_config.h — manual platform overrides (optional)
  3. eos_config_gen.h — Kconfig merge output (optional, auto-generated by the build)
  4. eos_config_defaults.h — kernel fallback defaults

Any stage can prevent subsequent stages from taking effect, forming a complete override chain from the build command line down to the kernel fallback.

Operations

The project root Makefile provides the following targets:

TargetAction
make / make buildcmake --build build (CMake auto-reconfigures as needed)
make menuconfigEdit build/.config (cmake -B build && cmake --build build --target menuconfig)
make runBuild and run

Dependency Installation

pip install kconfiglib

Multiple Build Directories

.config files are fully isolated per build directory. Native and WASM builds can hold independent configurations:

# Native
cmake -B build
make menuconfig # Edit build/.config

# WASM
cmake -B build-wasm -D EOS_PLATFORM=WASM
cmake --build build-wasm --target menuconfig # Edit build-wasm/.config
note

menuconfig requires terminal curses support. On Windows, use MSYS2 terminal.

Boundary with CMake Options

CMake options (-DUSE_FREERTOS=ON, etc.) govern build behavior—compilation units, link targets, compiler flags. Kconfig options govern kernel runtime behavior—memory strategy, filesystem type, font engine, logging policy. The two operate at distinct stages with no functional overlap.

CI Behavior

GitHub Actions executes pip install -r requirements.txt before the build step. CMake configuration auto-completes Kconfig merge and header generation. Should genconfig fail, the build proceeds, falling back to eos_config_defaults.h.

Fallback Mechanism

When Kconfig is not installed or genconfig fails, the kernel falls back to eos_config_defaults.h. The minimal flow cmake -B build && cmake --build build remains available under all conditions.