Application Security Blog | Technical Insights | Corellium

Build Android Kernel Debian | Corellium | [Step-by-Step Guide]

Written by Corellium | May 9, 2024 7:56:28 PM

These instructions are written for and tested on Debian Bullseye and Ubuntu 20.04, but should be straightforward to adapt to other Linux distributions. Building on Mac or Windows has not been tested and is not currently supported.

Prepare to Build the Kernel Image

To create a viable custom kernel for Android, first install the dependencies:

The next steps depend on the version of Android you're after.

Android 7, 8, 9, and 10 (Kernel 4.4)

1. Clone the common kernel repository and checkout commit hash 0566f6529a7b8d15d8ff50797331717b346f9aa4.

2. Download this patch and save it to $COMMON_CHECKOUT:

android-common-4.4.patch

3. Apply the patch with:

4. Download this tarball and save it to $COMMON_CHECKOUT:

drivers-corellium.tar.gz

5. Extract the tarball to the correct directory from the $COMMON_CHECKOUT location:

6. Save this file to $COMMON_CHECKOUT/arch/arm64/configs/corellium_defconfig.

corellium_defconfig_4.4

Android 11 (Kernel 5.4)

1. Clone the common kernel repository and checkout the android11-5.4.161_r00 tag.

2. Download this patch and save it to $COMMON_CHECKOUT:

android-common-5.4.patch

3. Apply the patch with: 

4. Download this tarball and save it to $COMMON_CHECKOUT:

drivers-corellium.tar.gz

5. Extract the tarball to the correct directory from the $COMMON_CHECKOUT location:

6. Save this file to $COMMON_CHECKOUT/arch/arm64/configs/corellium_defconfig.

corellium_defconfig_5.4

Android 12 (Kernel 5.10)

1. Clone the common kernel repository and checkout the android12-5.10.81_r00 tag.

2. Download this patch and save it to $COMMON_CHECKOUT:

android-common-5.10.patch

3. Apply the patch with: 

4. Download this tarball and save it to $COMMON_CHECKOUT:

drivers-corellium.tar.gz

5. Extract the tarball to the correct directory from the $COMMON_CHECKOUT location:

6. Save this file to $COMMON_CHECKOUT/arch/arm64/configs/corellium_defconfig.

corellium_defconfig_5.10

Android 13 and 14 (Kernel 5.15)

1. Clone the common kernel repository and checkout the android13-5.15-2022-08_r6 tag.

2. Download this patch and save it to $COMMON_CHECKOUT:

android-common-5.15.patch

3. Apply the patch with: 

4. Download this tarball and save it to $COMMON_CHECKOUT:

drivers-corellium.tar.gz

5. Extract the tarball to the correct directory from the $COMMON_CHECKOUT location:

6. Save this file to $COMMON_CHECKOUT/arch/arm64/configs/corellium_defconfig.

corellium_defconfig_5.15

Build the Kernel

For portability, build the kernel inside a Docker container.

To build the kernel image use the following:

Tweak and Rebuild the Kernel Image

Once the build is finished, a usable kernel image is found in your checkout directory under arch/arm64/boot/Image. It is recommended to first test the default-configured kernel image on the respective Android device version to ensure the build was successful before making changes to the kernel.

Rebuild the kernel image with your changes by running:

Notes

Kernels compiled from physical devices and uploaded a Corellium virtual device will not work. This is because Corellium only supports a specific chipset and hardware configuration.

Advance Your Mobile Security Research with Corellium

Experience Corellium’s groundbreaking virtualization technology for mobile devices and discover never-before-possible mobile vulnerability and threat research for iOS and Android phones. Set up a meeting today to explore how our platform can optimize mobile security research and malware analysis.