Kernel configuration (Kernel.toml)
Build-time configuration, zero runtime cost — mirrors docs/guides/configuration.md
§1How configuration takes effect
The configuration file is Kernel.toml at the repository root. At build time build.rs parses it and generates kernel/src/config.rs; kernel code consumes the constants via use crate::config::*.
Kernel.toml --build.rs--> kernel/src/config.rs --use--> kernel modules
Two iron rules: ①
kernel/src/config.rs is generated — never hand-edit it; ② editing Kernel.toml triggers a rebuild automatically; if it does not take effect, cargo clean and rebuild.§2Viewing and editing
make config # view the current configuration (cat Kernel.toml)
make menuconfig # TUI configuration (needs whiptail)
make menuconfig offers 12 categories: Memory / SMP / Scheduler / Network / Sub-features / Drivers / Boot / Debug / Performance / Security / View / Save.
§3Common configuration sections
| Section | Common keys | Meaning |
|---|---|---|
| [platform] | default_platform | the default build architecture (e.g. "riscv64") |
| [memory] | kernel_heap_size / physical_memory / page_size / user_stack_size | kernel heap, physical memory (MB), page size, user stack (MB) |
| [smp] | enable_smp / max_cpus | SMP switch and the CPU-count cap |
| [network] | eth_mtu / tcp_socket_table_size | NIC MTU, TCP socket table capacity |
| [printk] | ring_buffer_size / log_level | kmsg ring buffer and the default log level |
| [performance] | opt_level / lto | optimization level and LTO |
| [mount] [filesystem] [process] [sync] [graphics] | — | other sections: see the comments in Kernel.toml |
The repository's current values win: a few keys move with stage needs (e.g. the kernel heap size was raised for heavy userspace); this page lists names and meanings only — where doc defaults conflict with
Kernel.toml, the latter wins.§4Using it in kernel code
use crate::config::*;
let heap = KERNEL_HEAP_SIZE;
let cpus = MAX_CPUS;
let mtu = ETH_MTU;
// common: ENABLE_SMP, KERNEL_HEAP_SIZE, PAGE_SIZE,
// USER_STACK_TOP, ENABLE_NETWORK, DEFAULT_TIME_SLICE_MS ...
Verify the generated result: cat kernel/src/config.rs or grep "MAX_CPUS\|USER_STACK" kernel/src/config.rs.
§5Common errors
- Build fails with
Error: Configuration file parsing failed— a TOML syntax error inKernel.toml(format, type, missing quotes); fix where build.rs points. - Configuration changed but behavior did not — confirm you edited
Kernel.tomlrather than the generated file;cargo clean && cargo build --package rux --features riscv64forces regeneration. make menuconfigreports missing whiptail —sudo apt-get install whiptail(RHEL:sudo yum install newt).