Here, we provide instructions on building AOSP 13 with Aster changes that executes on Qemu.
The sources that were modified to be used in this guide are available at github.com/aster-cca .
Please be aware that this guide is preliminary, and the source code is highly experimental. We will further enhance the guide / sources within the next few months.
In case you want to raise an issue with the project or any part of the source code, please report it the central issue git for the overall Aster project.
Before you get started, see Aster in action. This demo integrates into the Android Virtualization Framework (AVF) on Android 13 and boots a protected VM (pVM) with Aster/ Arm CCA instead of protected KVM (pKVM).
microdroid_manager[54]: started.
microdroid_manager[54]: payload verification successful.
microdroid_manager[54]: Saved data is verified.
microdroid_manager[54]: DICE derivation for payload
microdroid_manager[54]: executing main task Task { type_: MicrodroidLauncher, command: "MicrodroidTestNativeLib.so", args: ["hello", "microdroid"] }Hello Microdroid
We recommend using a fresh installation of Ubuntu 24.04 on a machine that is not your primary device. At least 500GB of flash memory should be available to keep the source files and binaries. We recommend a machine with at least 64GB of DRAM memory for building.
Be aware that both building and running the project will be very slow. We recommend reading the entire guide before getting started.
We split this guide into 3 parts. First we give instructions on how to pull and install the base AOSP system that we used for our build, and will provide the basis. Then we incorporate the changes required for Aster. Lastly, we give instructions on how to execute the setup.
First, we explain on how to get all the source code required for the project and then give instructions on how to build it.
The process for obtaining all sources is described manually, to be able to catch any unexpected errors that might occur, and to ensure that all sources are actually preserved.
We place all our examples in the folder /home/ubuntu/cca and recommend creating it:
mkdir -p /home/ubuntu/ccaFirst, fetch this git, that contains instructions, scripts for compiling and running the project, and git manifests that put the source code version to the state that we used, when fetching it from Google later on.
cd /home/ubuntu/cca
git clone https://github.com/aster-cca/instructionsNext we will require the repo tool to get the next source code files. Install it with apt:
sudo apt-get install repoThen create a folder for the AOSP sources and switch into it:
mkdir -p /home/cca/android/aosp
cd /home/cca/android/aospFor the next steps: should for any of the fetched sources there be an error regarding that some sources were not syncable: this is okay, because we will replace them anyway later with our own sources.
Then init and sync the repo with our manifest:
repo init --partial-clone --no-use-superproject -b android-13.0.0_r2 -u https://android.googlesource.com/platform/manifest
rm ./.repo/manifests/default.xml
cp /home/cca/instructions/manifests/aosp.xml ./.repo/manifests/default.xml
repo sync -c -j8Additionally AOSP misses some gits that we need to fetch additionally:
cp /home/cca/instructions/manifests/aosp-missing.xml ./.repo/local_manifests/restore-missing.xml
repo sync -c -j8It might happen that during compilation there comes an error about a namespace conflict. In this case remove the following git:
rm -rf /home/cca/android/aosp/kernel/hardware/qcom/sdm845Next, we fetch the Kernel with our manifest. For this we first create the folder, and then also replace the manifest and sync.
mkdir -p /home/cca/android/kernel15-660
cd /home/cca/android/kernel15-660
repo init -u https://android.googlesource.com/kernel/manifest -b common-android15-6.6
rm ./.repo/manifests/default.xml
cp /home/cca/instructions/manifests/kernel15-660.xml ./.repo/manifests/default.xml
repo sync -c -j8To avoid compilation errors later on we also need to modify the rust version in the prebuilts:
cd /home/cca/andoid/kernel15-660/prebuilts/rust/linux-x86/
mv 1.73.0b 1.73.0Additionally, the source code folder needs some empty folder in which it will later copy in the binaries, so AOSP finds them. We will create them now:
cd /home/ubuntu/cca/android/aosp/kernel/prebuilts
mkdir -p mykernel660/arm64
cd /home/ubuntu/cca/android/aosp/kernel/prebuilts/common-modules/virtual-device
mkdir -p mykernel660To make the source code compilable, we need to include certain changes to several gits. In the following, we will replace these gits with our own sources, and checkout the specific revisions. This includes the virtual device module, the Virtualization Apex, the system core package, the goldfish and cuttlefish devices and prebuilts, and the crosvm VMM for AOSP, and the actual Android kernel, and kernel prebuilts.
system/core:
cd /home/ubuntu/cca/android/aosp/kernel/system
rm -rf ./core
git clone https://github.com/aster-cca/aosp-system-core core
cd core
git checkout origin/vanilla -b vanillakernel virtual device:
cd /home/ubuntu/cca/android/kernel15-660/common-modules
rm -rf ./virtual-device
git clone https://github.com/aster-cca/kernel15_660-common_modules-virtual_device virtual-device
cd virtual-device
git checkout origin/vanilla -b vanillaVirtualization apex:
cd /home/ubuntu/cca/android/aosp/packages/modules
rm -rf ./Virtualization
git clone https://github.com/aster-cca/aosp-packages-modules-virtualization Virtualization
cd Virtualization
git checkout origin/vanilla -b vanillaVirtual devices and prebuilts (where necessary):
cd /home/ubuntu/cca/android/aosp/device/
rm -rf ./generic/goldfish
rm -rf ./google/cuttlefish
rm -rf ./google/cuttlefish_prebuilts
git clone https://github.com/aster-cca/aosp-device-generic-goldfish generic/goldfish
git clone https://github.com/aster-cca/aosp-device-google-cuttlefish google/cuttlefish
git clone https://github.com/aster-cca/aosp-device-google-cuttlefish__prebuilts google/cuttlefish_prebuilts
cd ./generic/goldfish
git checkout origin/vanilla -b vanilla
cd ../../google/cuttlefish
git checkout origin/vanilla -b vanilla
cd ../cuttlefish_prebuilts
git checkout origin/vanilla -b vanillacrosvm VMM:
cd /home/ubuntu/cca/android/aosp/external/
rm -rf ./crosvm
git clone https://github.com/aster-cca/aosp-external-crosvm crosvm
cd crosvm
git checkout origin/vanilla -b vanillaAndroid kernel:
cd /home/ubuntu/cca/android/kernel15-660
rm -rf ./common
git clone https://github.com/aster-cca/kernel15_660-common common
cd common
git checkout origin/vanilla -b vanillaKernel Prebuilts: These are provided in a compressed zip due to file size limitations with github. In the following, we fetch and extract it/
cd /home/ubuntu/cca
mkdir -p /home/ubuntu/cca/android/aosp/kernel/prebuilts/cca
wget https://github.com/aster-cca/aosp-kernel-prebuilts-cca/releases/download/v1.0.0/aosp-kernel-prebuilts-cca.zip
unzip aosp-kernel-prebuilts-cca.zip -d /home/ubuntu/cca/android/aosp/kernel/prebuilts/cca/First, we create the directory structures for syncing all of these source files:
mkdir -p /home/ubuntu/cca/linaro
mkdir -p /home/ubuntu/cca/linaro-eac5
mkdir -p /home/ubuntu/cca/u-boot/u-boot-mainlineNext we sync qemu, TFA and RMM:
cd /home/ubuntu/cca/linaro
git clone https://github.com/aster-cca/linaro-qemu qemu
cd qemu
git checkout origin/vanilla -b vanilla
cd /home/ubuntu/cca/linaro-eac5
git clone https://github.com/aster-cca/linaro_eac5-tfa trusted-firmware-a
cd trusted-firmware-a
git checkout origin/vanilla -b vanilla
cd /home/ubuntu/cca/linaro-eac5
git clone https://github.com/aster-cca/linaro_eac5-rmm rmm
cd rmm
git checkout origin/vanilla -b vanillaUnfortunately, the edk2 sources we used are no longer available upstream. Therefore, we provide the sources as zip file under TODO. We download them and place it in the linaro-eac5 folder.
cd /home/ubuntu/cca/linaro-eac5
wget <TODO>
tar -xvf edk2.zipFor u-boot we first need to initialize a repo again and then replace the main source folder. We follow a similar procedure as for aosp and kernel:
cd /home/ubuntu/cca/u-boot/u-boot-mainline
repo init -u https://android.googlesource.com/kernel/manifest -b u-boot-mainline
rm ./.repo/manifests/default.xml
cp /home/cca/instructions/manifests/u-boot.xml ./.repo/manifests/default.xml
repo sync -c -j8
rm -rf ./u-boot
git clone https://github.com/aster-cca/ubootmainline-u_boot u-boot
cd u-boot
git checkout origin/vanilla -b vanillaLastly, we fetch the toolchain for compiling the project from Arm:
mkdir -p /home/ubuntu/cca/assets/toolchain-aarch64
cp /home/cca/instructions/scripts/setup-toolchain.sh ./
chmod +x ./setup-toolchain.sh
./setup-toolchain.shThis should conclude the preparation steps for compiling AOSP vanilla.
We provide scripts that help with compiling the sources, located under the scripts subdirectory in this git.
First, ensure that all scripts are executable:
cd /home/cca/instructions/scripts
chmod +x ./*.shNext, execute the compilation scripts in the following order:
cd /home/cca/instructions/scripts
./build_qemu.sh
./build_tfa.sh
./build_rmm.sh
./build_kernel.sh
./build_aosp13.sh
./build_uboot.sh
./build_aosp13.shBe aware that during compilation (especially of AOSP), the console might crash without displaying any errors. In that case, just re-run the script that crashed, and it should continue where it stopped. This might happen multiple times.
After syncing and compiling the sources, it would be good to verify that everything boots up well. For this purpose, open two console windows. In one of them launch the script ./run_aosp13.sh, and in the other one ./helper_telnet.sh. Launch a VNC client and connect to localhost:5900. Wait until AOSP boots, and you see the Android main menu in the VNC client.
We provide a more elaborate explanation later under Part 3.
After verifying that AOSP starts up and is executing we are now ready for incorporating the Aster changes. This will entail changing the branches on the modified source trees and fetching additional sources for the pVM kernel.
We already synced our custom gits in the first part that already incorporated changes to get the project working in the vanilla state. The next step is to flip the branches s.t. they use Aster changes instead. This will entail the Firmware, RMM, host kernel, crosvm, Virtualization Apex, u-boot.
cd /home/ubuntu/cca/android/kernel15-660/common
git checkout origin/aster -b aster
cd /home/ubuntu/cca/android/aosp/external/crosvm
git checkout origin/aster -b aster
cd /home/ubuntu/cca/u-boot/u-boot-mainline/u-boot
git checkout origin/aster -b aster
cd /home/ubuntu/cca/linaro-eac5/trusted-firmware-a
git checkout origin/aster -b aster
cd /home/ubuntu/cca/linaro-eac5/rmm
git checkout origin/aster -b aster
cd /home/ubuntu/cca/android/aosp/packages/modules/Virtualization
git checkout origin/aster -b asterNext, we need to fetch the Microdroid kernel, and incorporate our changes and fix the rust version:
mkdir -p /home/ubuntu/cca/android/kernel15-660-microdroid
cd /home/ubuntu/cca/android/kernel15-660-microdroid
repo init -u https://android.googlesource.com/kernel/manifest -b common-android15-6.6
rm ./.repo/manifests/default.xml
cp /home/cca/instructions/manifests/kernel15-660-microdroid.xml ./.repo/manifests/default.xml
repo sync -c -j8
rm -rf ./common
git clone https://github.com/aster-cca/kernel15_660_microdroid-common common
cd common
git checkout origin/aster -b aster
cd /home/ubuntu/cca/android/kernel15-660-microdroid/prebuilts/rust/linux-x86/
mv 1.73.0b 1.73.0TODO sync virtual device as well! TODO add as branch to host kernel instead of git duplicate
After changing all the gits, we can rebuild AOSP with Aster changes:
cd /home/cca/instructions/scripts
./build_tfa.sh
./build_rmm.sh
./build_kernel.sh
./build_kernel_microdroid.sh
./build_aosp13.sh
./build_uboot.sh
./build_aosp13.shAfter checking out the new sources we are nearly ready to launch pVMs in realm world. First, we introduce how to launch the setup with or without bare metal debugging, how to connect to the AOSP console with ADB. Afterwards, we will show how to install the microdroid app and the bootloader for launching the pVMs.
In total, we need at least 2 consoles and one VNC client. The first console contains the Qemu output, another one opens a telnet connection to get the Android console output. The VNC client renders the Android GUI. Additionally, it is possible to attach a debugger (gdb) to Qemu, which would require a 3rd console.
Console 1, Qemu:
# for regular execution w/o Aster
./run_aosp13.sh
# or, for execution with debugger support w/o Aster
./run_aosp13_debug.sh
# for regular execution w/ Aster
./run_aosp13_aster.sh
# or, for execution with debugger support w/ Aster
./run_aosp13_debug_aster.shConsole 2, Telnet:
./helper_telnet.shConsole 3, Debugger (if activated):
./helper_gdb.shAfter the two or 3 consoles are connected, execution will start, and you should see output on the telnet console. If debugging is enabled, you might have to continue execution with c. For using the gui, open a VNC viewer (e.g. Remmina, and connect to localhost:5900.)
Booting up AOSP takes a long time (approx 10-20 minutes). The VNC client will only show content at the end of the booting stage. There will be mouse cursor divergence, meaning that the input mouse cursor is not fully synchronized to the cursor in the VNC.
Although the telnet already exposes a console interface to Android, it lacks support for certain commands, which would only be available with an adb connection. For this purpose, we will connect to the emulator via adb in the following.
Theoretically, the emulated device should show up under adb devices -l after booting. However, adb does not correctly detect Qemu restarts. Therefore, to reset adb, execute the following commands:
adb kill-server
adb devices -l # It should show the Qemu device, but as offline
adb devices -l # The Qemu device should now be online and ready
adb shellTo launch pVMs, we need to install Microdroid app and the bootloader while the Aster-modified AOSP is running. Therefore, start AOSP for Aster in non-debug mode as described above.
Compile and install Microdroid test app as follows:
cd /home/cca/instructions/scripts
./build_microdroid_java_demo.shYou will notice during installation that incremental installation is not functional which is why the installer performs a streamed install. This is normal and expected.
Next we need to install the bootloader. For this, execute the following two commands:
./build_uboot.sh
./build_bootloader.shThis should complete the preparations for launching pVMs in realm mode.
pVMs can be launched either through the GUI or via the console. We recommend using the console, as the UI performance is not great. Therefore, we have prepared a script that can initiate the launch from the host. In a new console, switch into the scripts folder and execute ./run_vm_app.sh.
You will notice outputs in the telnet console from the RMM and / or TFA, e.g., when IPA state changes. In our experience booting the pVM is extremely slow in the emulation. The output might appear unresponsive, but should eventually continue. First, you should be able to see uboot output in the console you launched the above script from. After a short while it should continue with uboot initialization and after a longer time, there should be a bootlog of the kernel (the output stayed for us for a long time on SMC_RSI_IPA_STATE_SET: 0x9c000000 to 0xa0000000).
Eventually, the pVM should execute the Microdroid test app payload. Note that sometimes the execution of the payload seems to be unsuccessful. This seems to be due to some timeouts that occurred because of the long pVM boot time.
This software and all associated repositories are provided "AS IS", without warranty of any kind, express or implied. No guarantee of correctness, functionality, or fitness for purpose. No support or maintenance is provided. Use at your own risk.