Kernel
Building Android Kernel
Android is built around a Linux kernel. By default, Android’s
boot.img
is build from a binary kernel Image located in:
~/src/khadas-aosp-14/device/amlogic/yukawa-kernel/6.1
This guide describes how to rebuild and customize a Linux kernel for Android.
Fetching the kernel code
Fetch the code using repo
:
mkdir ~/src/khadas-kernel/ && cd $_
repo init -u https://gitlab.baylibre.com/baylibre/amlogic/atv/aosp/kernel/manifest.git -b yukawa-android14-6.1
repo sync
Note
To save same disk space, pass the --clone-depth=1
option to repo init
:
repo init -u https://gitlab.baylibre.com/baylibre/amlogic/atv/aosp/kernel/manifest.git -b yukawa-android14-6.1 --clone-depth=1
Building the kernel
In this section, we will assume that we already have an Android source tree which has been fully build and is located in:
~/src/khadas-aosp-14/
Build everything from scratch
For the 6.1 kernel, use:
cd ~/src/khadas-kernel/
export DIST_DIR=~/src/khadas-aosp-14/device/amlogic/yukawa-kernel/6.1
tools/bazel run //yukawa-device:yukawa_dist -- --dist_dir=$DIST_DIR
Re-running this command will rebuild incrementally
Rebuilding all involved Android images
To test the kernel changes, we have to re-generate the relevant Android images:
boot.img
: contains the kernel binary and the main device treevendor.img
: contains the kernel modules
To rebuild the Android images, do:
cd ~/src/khadas-aosp-14/
source build/envsetup.sh
lunch yukawa-userdebug
make bootimage vendorimage
Flashing the kernel
cd $ANDROID_PRODUCT_OUT
adb reboot fastboot
fastboot flash boot boot.img
fastboot flash vendor vendor.img
fastboot reboot