Table of Contents
These instructions are written for Debian Bullseye, but should be straightforward to adapt to other Linux distributions.
Installation
To create a viable kernel for Android, first install the dependencies:
sudo apt-get install --no-install-recommends docker.io git patch tar
Then, clone the repository:
git clone https://android.googlesource.com/kernel/goldfish
cd goldfish/
The next steps depend on the version of Android you're after.
Android 7 / 8
Change to the android-goldfish-3.18 branch:
git checkout android-goldfish-3.18
export GOLDFISH_CHECKOUT=$(realpath .)
Download this patch and save it to $GOLDFISH_CHECKOUT
:
Apply the patch with:
patch -p1 < android-goldfish-3.18.patch
Then, download this defconfig and save it to $GOLDFISH_CHECKOUT/arch/arm64/configs/corellium_defconfig
:
Android 9 / 10
Change to the android-goldfish-4.4-dev branch:
git checkout android-goldfish-4.4-dev 2export GOLDFISH_CHECKOUT=$(realpath .)
Once that's done, download this tarball and save it to $GOLDFISH_CHECKOUT
:
Once that's saved, replace the Goldfish platform drivers:
rm --force --recursive drivers/platform/goldfish
mkdir drivers/platform/goldfish
tar --extract --directory drivers/platform/goldfish --file goldfish.tar.gz --gunzip
Next, download this defconfig and save it to $GOLDFISH_CHECKOUT/arch/arm64/configs/corellium_defconfig
:
Build the Kernel
For portability, build the kernel inside a Docker container:
mkdir goldfish-build-environment/
cd goldfish-build-environment/
cat > Dockerfile << END
FROM ubuntu:16.04
RUN apt-get update && apt-get upgrade --assume-yes && apt-get install --assume-yes --no-install-recommends bc bison flex gcc gcc-aarch64-linux-gnu libc6-dev make
END
sudo docker build --tag=goldfish-build-environment .
sudo docker run --interactive --tty --mount=type=bind,source=$GOLDFISH_CHECKOUT,target=/goldfish goldfish-build-environment bash -c 'cd /goldfish/ && ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make corellium_defconfig && ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make'
Using the Kernel Image
Once the build is finished, a usable kernel image is found in $GOLDFISH_CHECKOUT/arch/arm64/boot/Image
.
You can now tweak the kernel as you like. After you’ve made your changes, run:
sudo docker run --interactive --tty --mount=type=bind,source=$GOLDFISH_CHECKOUT,target=/goldfish goldfish-build-environment bash -c 'cd /goldfish/ && ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make'
To rebuild the kernel with your changes.