- Last edited one year ago ago
How to customize kernel for Android
The environment must be installed using the Distribution Package adapted to your microprocessor device. See the list of Android Distribution Package.
Get the kernel sources as explained in How to build kernel for Android.
To execute the following instructions, go to your distribution root directory and initialize your environment as follows:
source build/envsetup.sh bspsetup lunch aosp_<BoardId>-userdebug
2 Updating the kernel configuration
menuconfig, you can adapt the configuration file to your needs. Some guidelines are given below.
2.1 Saving the current configuration
Before changing the kernel configuration, it is recommended to build the kernel using the current configuration:
A default config file named
defconfig.default is generated in
2.2 Creating a new kernel configuration
You can load a
.config file and modify any entry using this interface. Instructions on how to navigate are provided at the top of the windows.
Do not forget to click save.
This generates a
.config file located in
out-bsp/<STM32Series>/KERNEL_OBJ/, as well as a
defconfig file at the same location.
2.3 Testing the new kernel configuration
To test the new configuration, rebuild the kernel, update the prebuilts and flash, as explained in How to build kernel for Android.
2.4 Applying the newly generated kernel configuration
To make your change permanent, first compare the new
defconfig file with the
defconfig.default file generated at first build.
You can use a graphical tool such as
meld out-bsp/<STM32Series>/KERNEL_OBJ/defconfig out-bsp/<STM32Series>/KERNEL_OBJ/defconfig.default
Then report the changes into the
android-soc.config file located in
Eventually force the regeneration of the .config:
defconfig.default is then updated.
To test your configuration, rebuild the kernel and update the prebuilts and flash, as explain in How to build kernel for Android.
3 Changing the kernel command line
You can customize the kernel command line call at boot time.
The arguments are defined in the
BoardConfig.mk file located in
Adapt the value of the BOARD_KERNEL_CMDLINE variable to your needs.
Rebuild the bootimage to apply the changes:
Then flash the boot partition:
4 Changing the Device Tree
The kernel device tree used is set in the
dt.mk file available under the
device/stm/<STM32Series>/build/tasks/ directory. For more information refer to the Device tree and How to create your board device tree pages.
The device trees are located inside the Linux® kernel source code previously loaded. A Device Tree can be modified directly in
Once the Device Tree has been modified, rebuild it:
build_kernel -i dtb make -j
Then flash again the DT partition.