1# Microdroid kernel 2 3This directory contains prebuilt images of the Linux kernel that is used in 4Microdroid. The kernel is built from the same source tree as Generic Kernel 5Image (GKI), but with a different config where most of the config items are 6turned off to make the kernel fast & slim. 7 8## How to build the Microdroid kernels 9 10### Checkout the GKI source code. 11 12```bash 13repo init -u https://android.googlesource.com/kernel/manifest -b common-android14-6.1 14repo sync 15``` 16 17### Build the Microdroid kernels manually 18 19For ARM64 20```bash 21tools/bazel clean 22tooln/bazel run --config=fast //common:kernel_aarch64_microdroid_dist -- --dist_dir=out/dist 23``` 24 25For x86\_64, 26```bash 27tools/bazel clean 28tools/bazel run --config=fast //common:kernel_x86_64_microdroid_dist -- --dist_dir=out/dist 29``` 30 31Note that 32[`--config=fast`](https://android.googlesource.com/kernel/build/+/refs/heads/main/kleaf/docs/fast.md) 33is not mandatory, but will make your build much faster. 34 35The build may fail in case you are doing an incremental build and the config has changed (b/257288175). Until that issue 36is fixed, do the clean build by invoking `tools/bazel clean` before the build command. 37 38### Change the kernel configs 39 40For ARM64 41```bash 42tools/bazel run //common:kernel_aarch64_microdroid_config -- menuconfig 43``` 44 45For x86\_64 46```bash 47tools/bazel run //common:kernel_x86_64_microdroid_config -- menuconfig 48``` 49 50## How to update Microdroid kernel prebuilts 51 52### For manually built kernels (only for your own development) 53 54Copy the built kernel image to the Android source tree directly, and build the virt APEX. 55 56For ARM64, 57```bash 58cp out/dist/Image <android_checkout>/packages/modules/Virtualization/microdroid/kernel/arm64/kernel-6.1 59``` 60 61For x86\_64, 62```bash 63cp out/dist/bzImage <android_checkout>/packages/modules/Virtualization/microdroid/kernel/x86_64/kernel-6.1 64``` 65 66### For official updates 67 68Use the `download_from_ci` script to automatically fetch the built images from 69a specific `<build_id>` and make commits with nice history in the message. 70 71```bash 72cd <android_checkout>/packages/modules/Virtualization 73repo start <topic_name> 74cd <kernel_checkout> 75ANDROID_BUILD_TOP=<android_checkout> ./build/kernel/gki/download_from_ci --update-microdroid -b <bug_id> <build_id> 76cd <android_checkout>/packages/modules/Virtualization 77repo upload . 78``` 79