3.1. Android Kernel
3.1.1. Downloading sources
Fetch the code using repo
:
$ mkdir ${YOUR_PATH}/ti-kernel-aosp/ && cd $_
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_Kernel-6.6.xml
$ repo sync
Tip
To save some disk space, pass the --depth=1
option to repo init
:
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_Kernel-6.6.xml --depth=1
3.1.2. Build Instructions
3.1.2.1. Building everything from scratch
$ cd ${YOUR_PATH}/ti-kernel-aosp/
$ export TARGET_KERNEL_USE="6.6"
$ export DIST_DIR=${YOUR_PATH}/ti-aosp-15/device/ti/am62x-kernel/kernel/${TARGET_KERNEL_USE}
$ tools/bazel run //common:ti_dist -- --dist_dir=$DIST_DIR
Android uses Kleaf, a Bazel-based build system to build the kernel. AOSP documentation can be found here and Kleaf documentation here
Attention
Kernel builds hangs when using the btrfs
file system.
This is a known issue according to the kleaf documentation
Make sure to pass the --workaround_btrfs_b292212788
flag to bazel when using btrfs
.
3.1.2.2. Rebuilding faster
$ cd ${YOUR_PATH}/ti-kernel-aosp/
$ export TARGET_KERNEL_USE="6.6"
$ export DIST_DIR=${YOUR_PATH}/ti-aosp-15/device/ti/am62x-kernel/kernel/${TARGET_KERNEL_USE}
$ tools/bazel run --config=fast //common:ti_dist -- --dist_dir=$DIST_DIR
3.1.2.4. Rebuild Android images
We should re-generate the Android images to include the newly build kernel. Follow the Android Build Instructions to do so.
3.1.3. Flashing instructions
In order to flash a new kernel, several images should be flashed:
$ adb reboot fastboot
< Wait for fastbootd reboot >
$ cd <PATH/TO/IMAGES>
$ fastboot flash boot boot.img
$ fastboot flash vendor_boot vendor_boot.img
$ fastboot flash vendor_dlkm vendor_dlkm.img
$ fastboot reboot
The board should boot with the new kernel.
3.1.4. Enabling new drivers
Since the kernel is based on the Generic Kernel Image, new drivers should always be added as modules.
To enable new modules:
Run
menuconfig
as documented previously, Select=m
for the driver.Edit
$YOUR_PATH/ti-kernel-aosp/BUILD.bazel
to add your new module. Look for the following section:_TI_MODULE_OUTS = [ # keep sorted "crypto/af_alg.ko", "crypto/algif_hash.ko",
In the
_TI_MODULE_OUTS
array, add the path to your new kernel module.Rebuild the kernel as documented in Build Instructions.
If the driver module needs to be loaded early (in the ramdisk), edit
$YOUR_PATH/ti-aosp-15/device/ti/am62x/BoardConfig-common.mk
and add the path to your module:BOARD_VENDOR_RAMDISK_KERNEL_MODULES += \ device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/your_module.ko
Finally, rebuild the Android images.