Everything that can be left out of the firmware is a Kconfig symbol: SoCs, drivers, subsystems, services, debug aids and their parameters. The configuration is resolved with Kconfiglib when the build directory is configured, and the result drives both the C sources and the CMake build.
The root of the tree is the application’s Kconfig, pebble/Kconfig for the
firmware, or the top-level Kconfig for an application without one. Both
source Kconfig.pebbleos, which sources the rest of the tree:
soc/*/Kconfig.defconfig and subsys/bluetooth/Kconfig.defconfig
first, so their defaults win over the ones given with the definitions;
soc/Kconfig, with the SoC and CPU symbols, from the vendor directories
(see SoCs);
the board’s files, only for the selected board, revision, core and board
variant: boards/<board>/Kconfig, Kconfig.<revision>, Kconfig.<core>,
Kconfig.<board variant>, Kconfig.<core>_<board variant>, then the same
Kconfig.defconfig files;
lib/c, kernel, subsys, drivers and third_party, each with
a Kconfig that sources its own subdirectories.
A symbol is defined next to the code it enables: a driver class’s
Kconfig lives in drivers/<class>/, with one Kconfig.<driver> per
driver next to it, a subsystem’s in subsys/<name>/.
Kconfig options lists every option, with its dependencies,
defaults and location.
A series of SoCs has its code and its Kconfig in soc/<vendor>/<series>/,
as soc/sf32lb/sf32lb52x, the QEMU machine soc/qemu/pebble and the host
soc/native/posix:
File |
Contents |
|---|---|
|
The SoCs of the series, entries of the SoC choice a board picks in its |
|
The series symbol, what the series selects, and its options |
|
The defaults the series gives to common symbols |
|
The family symbol, |
soc/<vendor>/Kconfig.soc and soc/<vendor>/Kconfig.defconfig source those of
the series, and soc/Kconfig those of every vendor directory.
soc/CMakeLists.txt builds the directory of the selected family, which builds
that of the selected series.
A build’s configuration is resolved from these fragments, in this order:
Fragment |
Purpose |
|---|---|
|
What the board is: SoC, boot chain and console |
|
What a revision changes |
|
What a core ( |
|
What a board variant ( |
|
What a board variant changes on one core ( |
|
Driver classes, subsystems, services and features every firmware enables |
|
What the |
|
What the firmware enables or tunes on one board, and the SDK platform it offers there |
|
The same, for one variant only |
|
Changes made with pbl menuconfig |
|
Overrides given when configuring |
The pebble/ fragments are the firmware’s. Another application brings the same
files from its own directory instead, see Applications.
Overrides are passed to pbl configure or to CMake:
pbl configure --board obelix@pvt -DCONFIG_RELEASE=y
The variant is selected with --variant (-DVARIANT=), not by setting
CONFIG_RECOVERY_FW directly; prj_prf.conf sets it, and the build stops
if the two disagree.
The fragments add to each other: a symbol can be assigned in only one of
them, and a later fragment cannot change what an earlier one set. To change
a value for one build, override it with -D.
Configuration warnings are errors. The build stops when:
a fragment or an override names a symbol that does not exist;
a fragment assigns a symbol an earlier fragment already assigned;
a value cannot be applied because of the symbol’s dependencies; the error names the unsatisfied ones.
Every symbol reaches all three consumers:
C sources: autoconf.h is force-included into every compilation,
so symbols are plain macros. An enabled bool symbol is defined to 1
and a disabled one is not defined at all, so test it with
#ifdef CONFIG_TOUCH.
CMake: config.cmake sets one variable per enabled symbol, used by
the _ifdef helpers; see CMake.
Linker script: preprocessed with autoconf.h, so memory layout and
sections can depend on the configuration.
.config in the build directory holds the resolved configuration.
A class is a menuconfig symbol, with one symbol per driver inside its
if block. No class is on by default: the application enables the
classes it uses, drivers select the classes they use, and a SoC selects
the ones its own code calls, such as its system timer. The board’s
defconfig enables none. Inside an enabled class, a driver whose devices
come from the board’s Devicetree defaults to the tree having one
(default DT_HAS_NORDIC_NRF52832_TWIM_ENABLED). Otherwise, a driver that
only exists on one SoC defaults to y there (default y if SOC_QEMU_PEBBLE).
A driver selects the classes it uses, such as the bus it sits on
(select I2C) or the supplies it takes (select REGULATOR), so an
application asks for an accelerometer without knowing how the board
wires it. This is safe because only drivers inside an enabled class
select, and the selected classes have no dependencies of their own. A driver that is not inside such a class,
such as a regulator or a GPIO key, does not select: it sits inside the
class its users select, or the one the application enables.
What hardware or drivers provide is a hidden symbol (no prompt) that the
providers select, such as BACKLIGHT_HAS_COLOR or CPU_HAS_FPU. Code
and other symbols depend on the capability, not on a list of providers.
A library that is not always needed is gated behind a symbol, and its
consumers select (or imply) it: BT selects MBEDTLS, and
SERVICE_VOICE selects SPEEX.
A default that depends on the board or SoC goes in its
Kconfig.defconfig, which is read before the definitions:
config FLASH_SIZE
default 0x100000
A module’s log level comes from a template:
module = TASK_WDT
module-str = Task watchdog
source "subsys/logging/Kconfig.template.log_level"
It defines CONFIG_TASK_WDT_LOG_LEVEL and its choice; see
Logging.
Generated from PebbleOS 7416f78a1. This page is maintained in the pebbleos repository: docs/development/build_system/kconfig.md.