xref: /aosp_15_r20/kernel/configs/README.md (revision 1d3556b860e096874ddca674556f5d20fb3a73b0)
1*1d3556b8SAndroid Build Coastguard Worker# Android Kernel Configs
2*1d3556b8SAndroid Build Coastguard Worker
3*1d3556b8SAndroid Build Coastguard Worker## How are kernel config settings typically stored?
4*1d3556b8SAndroid Build Coastguard Worker
5*1d3556b8SAndroid Build Coastguard WorkerWhen building the Linux kernel for a particular platform one usually begins by
6*1d3556b8SAndroid Build Coastguard Workerbasing the kernel configuration off of a particular defconfig. The platform’s
7*1d3556b8SAndroid Build Coastguard Workerdefconfig contains all of the Linux kconfig settings required to properly
8*1d3556b8SAndroid Build Coastguard Workerconfigure the kernel build (features, default system parameters, etc) for that
9*1d3556b8SAndroid Build Coastguard Workerplatform. Defconfig files are typically stored in the kernel tree at
10*1d3556b8SAndroid Build Coastguard Worker`arch/*/configs/`.
11*1d3556b8SAndroid Build Coastguard Worker
12*1d3556b8SAndroid Build Coastguard WorkerIt may be desirable to modify the kernel configuration beyond what the hardware
13*1d3556b8SAndroid Build Coastguard Workerplatform requires in order to support a particular hardware or software
14*1d3556b8SAndroid Build Coastguard Workerfeature. Storing these kernel configuration changes is often done using
15*1d3556b8SAndroid Build Coastguard Workerfragments. These are files which have the same format as a defconfig but are
16*1d3556b8SAndroid Build Coastguard Workertypically much smaller, as they only contain the kernel configuration settings
17*1d3556b8SAndroid Build Coastguard Workerneeded to support the hardware or software feature/behavior in question.
18*1d3556b8SAndroid Build Coastguard WorkerMaintainers of hardware extensions or software features can use fragments to
19*1d3556b8SAndroid Build Coastguard Workercompactly express their kernel requirements. The fragments can be combined
20*1d3556b8SAndroid Build Coastguard Workerwith a platform defconfig using the kernel's make rules or using the
21*1d3556b8SAndroid Build Coastguard Worker`scripts/kconfig/merge_config.sh` script in the kernel tree.
22*1d3556b8SAndroid Build Coastguard Worker
23*1d3556b8SAndroid Build Coastguard Worker## How are Android's kernel configs stored?
24*1d3556b8SAndroid Build Coastguard Worker
25*1d3556b8SAndroid Build Coastguard WorkerThe kernel configs are stored in the [kernel/configs repo](https://android.googlesource.com/kernel/configs/).
26*1d3556b8SAndroid Build Coastguard Worker
27*1d3556b8SAndroid Build Coastguard WorkerKernel configuration settings that must be present for Android to function are
28*1d3556b8SAndroid Build Coastguard Workerlocated in the base config fragment, `android-base.config`. Configuration settings
29*1d3556b8SAndroid Build Coastguard Workerthat enhance Android’s functionality in some way but are not required for it to
30*1d3556b8SAndroid Build Coastguard Workerrun are located in the recommended config fragment, `android-recommended.config`.
31*1d3556b8SAndroid Build Coastguard Worker
32*1d3556b8SAndroid Build Coastguard WorkerSome kernel config requirements only apply on certain architectures. Other
33*1d3556b8SAndroid Build Coastguard Workerrequirements only apply if some other kernel config option has a particular
34*1d3556b8SAndroid Build Coastguard Workervalue. The platform owner may also have a choice between several config
35*1d3556b8SAndroid Build Coastguard Workeroptions. These types of constraints cannot be expressed with a simple kernel
36*1d3556b8SAndroid Build Coastguard Workerconfig fragment. In releases up to and including Android P, kernel config
37*1d3556b8SAndroid Build Coastguard Workerrequirements that are specific to a particular architecture are contained in
38*1d3556b8SAndroid Build Coastguard Workerarchitecture-specific base config fragments, such as
39*1d3556b8SAndroid Build Coastguard Worker`android-base-arm64.config`. If an architecture-specific base config fragment
40*1d3556b8SAndroid Build Coastguard Workerdoes not exist for a particular architecture in Android P or an earlier
41*1d3556b8SAndroid Build Coastguard Workerrelease, it means there are no required kernel config options for Android
42*1d3556b8SAndroid Build Coastguard Workerspecific to that architecture. Note that the architecture-agnostic kernel
43*1d3556b8SAndroid Build Coastguard Workerconfig requirements from `android-base.config` still apply in that case.
44*1d3556b8SAndroid Build Coastguard Worker
45*1d3556b8SAndroid Build Coastguard WorkerIn releases after Android P the architecture-specific base config fragments are
46*1d3556b8SAndroid Build Coastguard Workerremoved, and conditional kernel config requirements are stored in
47*1d3556b8SAndroid Build Coastguard Worker`android-base-conditional.xml`.
48*1d3556b8SAndroid Build Coastguard Worker
49*1d3556b8SAndroid Build Coastguard WorkerIn Android R or above, additional config fragments are added conditionally
50*1d3556b8SAndroid Build Coastguard Workeron build variants. In particular, `non_debuggable.config` contains additional
51*1d3556b8SAndroid Build Coastguard Workerrequirements for user builds.
52*1d3556b8SAndroid Build Coastguard Worker
53*1d3556b8SAndroid Build Coastguard WorkerKernel configs vary by kernel version, so there are sets of kernel configs for
54*1d3556b8SAndroid Build Coastguard Workereach version of the kernel that Android supports.
55*1d3556b8SAndroid Build Coastguard Worker
56*1d3556b8SAndroid Build Coastguard Worker## How can I easily combine platform and required Android configs?
57*1d3556b8SAndroid Build Coastguard Worker
58*1d3556b8SAndroid Build Coastguard WorkerAssuming you already have a minimalist defconfig for your platform, a possible
59*1d3556b8SAndroid Build Coastguard Workerway to enable these options would be to use the aforementioned
60*1d3556b8SAndroid Build Coastguard Worker`merge_config.sh` script in the kernel tree. From the root of the kernel tree:
61*1d3556b8SAndroid Build Coastguard Worker
62*1d3556b8SAndroid Build Coastguard Worker```sh
63*1d3556b8SAndroid Build Coastguard WorkerARCH=<arch> scripts/kconfig/merge_config.sh <...>/<platform>_defconfig <...>/android-base.config <...>/android-base-<arch>.config <...>/android-recommended.config
64*1d3556b8SAndroid Build Coastguard Worker```
65*1d3556b8SAndroid Build Coastguard Worker
66*1d3556b8SAndroid Build Coastguard WorkerThis will generate a `.config` that can then be used to save a new defconfig or
67*1d3556b8SAndroid Build Coastguard Workercompile a new kernel with Android features enabled.
68*1d3556b8SAndroid Build Coastguard Worker
69*1d3556b8SAndroid Build Coastguard WorkerThe kernel build system also supports merging in config fragments directly. The
70*1d3556b8SAndroid Build Coastguard Workerfragments must be located in the `kernel/configs` directory of the kernel tree
71*1d3556b8SAndroid Build Coastguard Workerand they must have filenames that end with the extension ".config". The
72*1d3556b8SAndroid Build Coastguard Workerplatform defconfig must also be located in `arch/<arch>/configs/`. Once these
73*1d3556b8SAndroid Build Coastguard Workerrequirements are satisfied, the full defconfig can be prepared with:
74*1d3556b8SAndroid Build Coastguard Worker
75*1d3556b8SAndroid Build Coastguard Worker```sh
76*1d3556b8SAndroid Build Coastguard Workermake ARCH=<arch> <platform>_defconfig android-base.config android-base-<arch>.config android-recommended.config
77*1d3556b8SAndroid Build Coastguard Worker```
78*1d3556b8SAndroid Build Coastguard Worker
79*1d3556b8SAndroid Build Coastguard WorkerIf there is an `android-base-conditional.xml` file for your release/kernel
80*1d3556b8SAndroid Build Coastguard Workerversion combination, it is necessary to review it and manually edit your
81*1d3556b8SAndroid Build Coastguard Workerdefconfig to satisfy any applicable requirements.
82*1d3556b8SAndroid Build Coastguard Worker
83*1d3556b8SAndroid Build Coastguard Worker## Are the config requirements tested?
84*1d3556b8SAndroid Build Coastguard Worker
85*1d3556b8SAndroid Build Coastguard WorkerStarting with Android O the base kernel configs are not just advisory. They are
86*1d3556b8SAndroid Build Coastguard Workertested as part of
87*1d3556b8SAndroid Build Coastguard Worker[VTS](https://android.googlesource.com/platform/test/vts-testcase/hal/+/master/treble/framework_vintf/AndroidTest.xml)
88*1d3556b8SAndroid Build Coastguard Worker(specifically the SystemVendorTest.KernelCompatibility subtest of
89*1d3556b8SAndroid Build Coastguard WorkerCtsOnGsiTrebleFrameworkVintfTest), and also during device boot when the vendor
90*1d3556b8SAndroid Build Coastguard Workerinterface (which includes the kernel configuration) and framework compatibility
91*1d3556b8SAndroid Build Coastguard Workermatrix are compared.
92*1d3556b8SAndroid Build Coastguard Worker
93*1d3556b8SAndroid Build Coastguard Worker## Ensuring Device Upgradability
94*1d3556b8SAndroid Build Coastguard Worker
95*1d3556b8SAndroid Build Coastguard WorkerDevices launched with prior releases of Android must be able to upgrade to
96*1d3556b8SAndroid Build Coastguard Workerlater releases of Android. This means that AOSP must function not only with
97*1d3556b8SAndroid Build Coastguard Workerdevice kernels that adhere to the Android kernel configs of the current
98*1d3556b8SAndroid Build Coastguard Workerrelease, but also with those device kernels that adhere to the configs of past
99*1d3556b8SAndroid Build Coastguard Workerreleases. To facilitate that in the VtsKernelConfig test and in the framework
100*1d3556b8SAndroid Build Coastguard Workercompatibility matrix, past versions of the Android kernel config requirements
101*1d3556b8SAndroid Build Coastguard Workerare stored in the kernel/configs repo. During tests the appropriate versions
102*1d3556b8SAndroid Build Coastguard Workerof the configs are accessed depending on the launch level of the device.
103*1d3556b8SAndroid Build Coastguard Worker
104*1d3556b8SAndroid Build Coastguard WorkerIf you are adding a new feature to AOSP which depends on a particular kernel
105*1d3556b8SAndroid Build Coastguard Workerconfiguration value, either that kernel configuration value must already be
106*1d3556b8SAndroid Build Coastguard Workerpresent in the base android config fragments of past releases still on the
107*1d3556b8SAndroid Build Coastguard Workersupported upgrade path, or the feature must be designed in a way to degrade
108*1d3556b8SAndroid Build Coastguard Workergracefully when the required kernel configuration is not present (and not be
109*1d3556b8SAndroid Build Coastguard Workeressential to AOSP’s overall functionality). All configs on the supported
110*1d3556b8SAndroid Build Coastguard Workerupgrade path are in the kernel/configs repo.
111*1d3556b8SAndroid Build Coastguard Worker
112*1d3556b8SAndroid Build Coastguard WorkerSupport for kernel configs from previous dessert releases is dropped from AOSP
113*1d3556b8SAndroid Build Coastguard Workerwhen the upgrade path from that dessert release is no longer supported.
114*1d3556b8SAndroid Build Coastguard Worker
115*1d3556b8SAndroid Build Coastguard Worker# Organization and Maintenance of the Kernel Config Repo
116*1d3556b8SAndroid Build Coastguard Worker
117*1d3556b8SAndroid Build Coastguard WorkerThe top level of the kernel configs repo contains directories for each
118*1d3556b8SAndroid Build Coastguard Workersupported kernel version. These contain the kernel config requirements (and
119*1d3556b8SAndroid Build Coastguard Workerrecommendations) for the next release. There are also directories at
120*1d3556b8SAndroid Build Coastguard Workerthe top level for previous releases. These directories contain the
121*1d3556b8SAndroid Build Coastguard Workerfinal kernel config requirements (for all supported kernel versions) for those
122*1d3556b8SAndroid Build Coastguard Workerreleases and must not be changed once those releases have been
123*1d3556b8SAndroid Build Coastguard Workerpublished. AOSP must support all kernel configurations in this repo.
124*1d3556b8SAndroid Build Coastguard Worker
125*1d3556b8SAndroid Build Coastguard WorkerFor release branches the structure is similar, except there are no configs at
126*1d3556b8SAndroid Build Coastguard Workerthe top level. When a release is branched from master the top-level configs are
127*1d3556b8SAndroid Build Coastguard Workercopied into a new directory for the release (this change is propagated to
128*1d3556b8SAndroid Build Coastguard Workermaster) and the top-level configs are removed (this change is not propagated to
129*1d3556b8SAndroid Build Coastguard Workermaster) since no development beyond that release is done in that branch.
130*1d3556b8SAndroid Build Coastguard Worker
131*1d3556b8SAndroid Build Coastguard Worker## I want to add/modify/remove a kernel config requirement. What do I do?
132*1d3556b8SAndroid Build Coastguard Worker
133*1d3556b8SAndroid Build Coastguard WorkerModify the top level kernel configs in AOSP. Make sure to modify the configs
134*1d3556b8SAndroid Build Coastguard Workerfor all applicable kernel versions. Do not modify the config fragments in
135*1d3556b8SAndroid Build Coastguard Workerrelease directories.
136*1d3556b8SAndroid Build Coastguard Worker
137*1d3556b8SAndroid Build Coastguard WorkerBecause there is no tool to consistently generate these config fragments,
138*1d3556b8SAndroid Build Coastguard Workerplease keep them alphabetically (not randomly) sorted.
139*1d3556b8SAndroid Build Coastguard Worker
140*1d3556b8SAndroid Build Coastguard Worker### `android-x.y/android-base.config`
141*1d3556b8SAndroid Build Coastguard Worker
142*1d3556b8SAndroid Build Coastguard WorkerThis file lists all common kernel configuration requirements on kernel version
143*1d3556b8SAndroid Build Coastguard Worker`x.y`.
144*1d3556b8SAndroid Build Coastguard Worker
145*1d3556b8SAndroid Build Coastguard Worker### `android-x.y/android-base-conditional.xml`
146*1d3556b8SAndroid Build Coastguard Worker
147*1d3556b8SAndroid Build Coastguard WorkerContains the following:
148*1d3556b8SAndroid Build Coastguard Worker
149*1d3556b8SAndroid Build Coastguard Worker* Minimum LTS required
150*1d3556b8SAndroid Build Coastguard Worker* Conditional requirements.
151*1d3556b8SAndroid Build Coastguard Worker
152*1d3556b8SAndroid Build Coastguard Worker### `android-x.y/Android.bp`
153*1d3556b8SAndroid Build Coastguard Worker
154*1d3556b8SAndroid Build Coastguard WorkerBuild rules from the aforementioned files to a
155*1d3556b8SAndroid Build Coastguard Worker[framework compatibility matrix](https://source.android.com/devices/architecture/vintf/comp-matrices)
156*1d3556b8SAndroid Build Coastguard Worker. See
157*1d3556b8SAndroid Build Coastguard Worker[this link](https://source.android.com/devices/architecture/vintf/match-rules#kernel)
158*1d3556b8SAndroid Build Coastguard Workerfor details of the output format.
159*1d3556b8SAndroid Build Coastguard Worker
160*1d3556b8SAndroid Build Coastguard Worker## I want to edit a released kernel requirement. What do I do?
161*1d3556b8SAndroid Build Coastguard Worker
162*1d3556b8SAndroid Build Coastguard WorkerDon't edit a released kernel requirement unless necessary. If you have to make
163*1d3556b8SAndroid Build Coastguard Workersuch a change, after discussing the change with maintainers, keep in mind that
164*1d3556b8SAndroid Build Coastguard Workeryou **CANNOT** make a requirement more restrictive. Specifically,
165*1d3556b8SAndroid Build Coastguard Worker
166*1d3556b8SAndroid Build Coastguard Worker### Allowed
167*1d3556b8SAndroid Build Coastguard Worker* Support a new kernel version by creating a new `<dessert>/android-x.y`
168*1d3556b8SAndroid Build Coastguard Worker  directory
169*1d3556b8SAndroid Build Coastguard Worker* Remove a line from `<dessert>/android-*/android-base.config`
170*1d3556b8SAndroid Build Coastguard Worker* Remove a line from `<dessert>/android-*/android-base-*.config`
171*1d3556b8SAndroid Build Coastguard Worker* In `<dessert>/android-*/android-base-conditional.xml`
172*1d3556b8SAndroid Build Coastguard Worker    * Lower minimum LTS requirement from `x.y.u` to `x.y.v` (where `v < u`)
173*1d3556b8SAndroid Build Coastguard Worker    * Remove a `<group>`
174*1d3556b8SAndroid Build Coastguard Worker    * Add a condition `<group><conditions><config>`
175*1d3556b8SAndroid Build Coastguard Worker    * Remove a conditional requirement `<group><config>`
176*1d3556b8SAndroid Build Coastguard Worker
177*1d3556b8SAndroid Build Coastguard Worker### Not allowed
178*1d3556b8SAndroid Build Coastguard Worker* Add or change a line from `<dessert>/android-*/android-base.config`
179*1d3556b8SAndroid Build Coastguard Worker* Add or change a line from `<dessert>/android-*/android-base-*.config`
180*1d3556b8SAndroid Build Coastguard Worker* Add new conditional requirements `<dessert>/android-*/android-base-*.config`
181*1d3556b8SAndroid Build Coastguard Worker* Rename existing conditional requirements `<dessert>/android-*/android-base-*.config`
182*1d3556b8SAndroid Build Coastguard Worker* In `<dessert>/android-*/android-base-conditional.xml`
183*1d3556b8SAndroid Build Coastguard Worker    * Raise minimum LTS requirement from `x.y.u` to `x.y.v` (where `v < u`)
184*1d3556b8SAndroid Build Coastguard Worker    * Add a new `<group>`
185*1d3556b8SAndroid Build Coastguard Worker    * Remove or change a condition `<conditions><config>`
186*1d3556b8SAndroid Build Coastguard Worker    * Add or change a conditional requirement `<group><config>`
187*1d3556b8SAndroid Build Coastguard Worker* Other changes that are not in the [Allowed](#allowed) list
188