The AOSP tree contains only prebuilt kernel binaries. However, vendors always
need to add customized modules into the kernel.
For Android Kernel, refer to https://source.android.com/docs/setup/build/building-kernels,
For Cuttlefish device, refer to https://source.android.com/docs/devices/cuttlefish/kernel-dev.
Prebuilt Kernel
When and AVD image is built, it copies the prebuilt kernel image to the output folder:
$(LOCAL_DIR)/sdk_car_x86_64.mk
is expanded to device/generic/car/sdk_car_x86_64.mk
.
This makefile inherates from other makefiles:
Kernel is defined in the makefile device/generic/goldfish/board/emu64x/details.mk
:
The variable EMULATOR_KERNEL_FILE
is finally expanded to kernel/prebuilts/6.6/x86_64/kernel-6.6
:
Compile Kernel
Android Kernel is hosted in a different repo from the AOSP project.
Check the branches and their build systems at https://source.android.com/docs/setup/reference/bazel-support.
- Android 13 introduced building kernels with Bazel (Kleaf) - it is super fast
- Older Android version is build.sh, which is quite slow
For Cuttlefish device, refer to https://source.android.com/docs/devices/cuttlefish/kernel-dev.
Cuttlefish supports the following kernel manifests on aosp-main
repo,
branches: common-android14-6.1
, common-android14-5.15
, common-android-mainline
Define macros:
Initialize the repo:
Download source code:
Build Virtual kermel and modules:
Check the Kernel image:
Run with new Kernel
Cuttlefish Device
It is easy to tell Cuttlefish to use new kernel and initramfs
(included all virtual kernel modules):
Android Virtual Device
This needs to be rebuilt to run with new kernel:
Compilation may fail due to a missing kernel module. Remove it in the make file: