1. Prerequisites[edit source]
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[edit source]
By using menuconfig
, you can adapt the configuration file to your needs. Some guidelines are given below.
2.1. Saving the current configuration[edit source]
Before changing the kernel configuration, it is recommended to build the kernel using the current configuration:
build_kernel
A default config file named defconfig.default
is generated in out-bsp/<STM32Series>/KERNEL_OBJ/
directory.
2.2. Creating a new kernel configuration[edit source]
Start menuconfig
:
build_kernel menuconfig
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[edit source]
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[edit source]
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
.
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 device/stm/<STM32Series>-kernel/source/kconfig/<kernel version>/
.
Eventually force the regeneration of the .config:
build_kernel defaultconfig
Note: the 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[edit source]
You can customize the kernel command line call at boot time.
The arguments are defined in the BoardConfig.mk
file located in device/stm/<STM32Series>/<BoardId>/
.
Adapt the value of the BOARD_KERNEL_CMDLINE variable to your needs.
Rebuild the bootimage to apply the changes:
make bootimage-nodeps
Then flash the boot partition:
4. Changing the Device Tree[edit source]
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 device/stm/<STM32Series>-kernel/linux-<STM32Series>/arch/arm/boot/dts
.
Once the Device Tree has been modified, rebuild it:
build_kernel -i dtb make -j
Then flash again the DT partition.