These instructions are written for Debian Bullseye, but should be straightforward to adapt to other Linux distributions. To create a viable kernel for Android 9 and 10:

1. Install dependencies:

sudo apt-get install --no-install-recommends docker.io git patch tar

2. Clone the repository:

git clone https://android.googlesource.com/kernel/goldfish 
cd goldfish/
git checkout android-goldfish-4.4-dev
export GOLDFISH_CHECKOUT=$(realpath .)

3. Download this tarball and save it to $GOLDFISH_CHECKOUT/.

goldfish.tar.gz

4. 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

5. Download this defconfig and save it to $GOLDFISH_CHECKOUT/arch/arm64/configs/corellium_defconfig:

corellium_defconfig

6. 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'

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.

Did this answer your question?