3

I've been doing some kernel development on the Google pixel 9a "tegu" platform (latest version on https://developers.google.com/android/drivers), where Google uses Bazel to compile the kernel into a boot.img. I can flash this boot.img file onto the pixel to have my custom kernel running on the hardware.

So far, I've been able to get source code changes reflected in the boot.img I flash onto the pixel, and that custom kernel boots properly. Now, I want to be able to edit the kernel's config flags to do things like get 16KB paging and enable KUNIT testing (conditional compilation in the build process).

Bazel manages build process specifications with a list of defined "build targets" in the BUILD.bazel file. These build targets provide instructions on how to compile the kernel down to an Image file, then package that into a boot.img along with ramdisk, etc.

Bottom-line: I want to either create my own Bazel build target or edit an existing one in BUILD.bazel that lets me specify my own config flags, then flash that custom kernel onto my Google pixel 9a.

You can find the repo I've been using (including the BUILD.bazel file) at https://android.googlesource.com/kernel/common/+/refs/heads/android14-6.1

So far, I've tried creating my own Bazel build target, though the boot.img file produced by kernel_images() needs a dtb.img file, which I do not have.

I've also tried editing the kernel_aarch64 target in define_common_kernels() by adding my own fragment with the defconfig_fragments[] field. This has yielded partial success in the sense that kernel_build() produces a usable Image file I can load up in qemu and confirm that the kernel compiled with my specified config flags (16KB pages, KUNIT, etc). The issue with this approach has been trying to get kernel_images() to package this Image up into a usable boot.img that doesnt rely on the previous GKI prebuilt configs (which kernel_images seems to be set up to use by default).

You can see the specifics in the BUILD.bazel file, common_kernels.bzl, and kernel_images.bzl files.

I'm very new to Bazel, so I think that there's likely some feature I'm missing that makes this process a whole lot simpler. All I need from Bazel is to compile my kernel with a custom set of config flags, then get a usable boot.img from that.

1 Answer 1

0

I really like the Raspberry-Vanilla project, it’s a great starting point for development of aosp/kernel.

You can check out their manifest here:

https://github.com/raspberry-vanilla/android_kernel_manifest/tree/android-16.0

And here’s the link to their kernel:

https://github.com/raspberry-vanilla/android_kernel_brcm_rpi

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.