Download, build, and run

This page explains how to download, build, and run AAOS SDV on Cuttlefish.

Get the AAOS SDV source code

Use the instructions provided in Download the Android source.

Set up your build environment

From within your working directory, source the envsetup.sh script to set up your build environment:

source build/envsetup.sh

This script imports several commands that let you work with the Android source code, including the commands used on this page. To view the source of the script, see platform/build/envsetup.sh. To view the built-in help, type hmm.

Choose a target

Before building SDV, identify a target to build. To identify your target to build, use the lunch command followed by a string representing the target you're building for. For example, use this command to build a target for the Cuttlefish emulator:

lunch sdv_core_cf-aosp_current-userdebug

This command selects the product, release configuration, and variant to build and stores the selection in the environment.

lunch targets for SDV are provided in a separate Git project located in the device/google/sdv directory. See a detailed description of available targets at device/google/sdv/README.md. The main Cuttlefish (cf) targets are:

  • sdv_core_cf-aosp_current-userdebug - Build an image of AAOS SDV Core (sdv_core) that runs on Cuttlefish (cf).
  • sdv_media_cf-aosp_current-userdebug - Build an image of AAOS SDV Core with virtIO-virtualized media APIs (sdv_media).
  • sdv_media_har_cf-aosp_current-userdebug - Build an image that extends the AAOS SDV media (sdv_media_cf) lunch target to contain the high-availability renderer (HAR). HAR runs automatically on boot.
  • sdv_ivi_cf-aosp_current-userdebug - Build an image of In-Vehicle Infotainment (IVI) containing the SDV Gateway and Java sample apps.
  • sdv_ivi_cf_ds-aosp_current-userdebug - Build an image that extends the AAOS SDV IVI target (sdv_ivi_cf) and includes Display Safety's DriverUI and Instrument Cluster implementation.

Build AAOS SDV

Run the following command to build your target. Depending on the specification of your workstation, the first build takes between 30 and 60 minutes. Subsequent builds take significantly less time.

m

After you build the full system image once, you can rebuild an individual Soong module or service bundle APEX without repackaging the entire image:

m <module_name>

A targeted module build writes only that module's artifact under $OUT without regenerating super.img or the partition images booted by Cuttlefish. To test the change, stage or push the rebuilt artifact onto the running VM (for example, with sdv_update_manager_client on sdv_core_cf or adb install --staged for updatable APEXes on sdv_ivi_cf), or run m to repackage the partition images. For more information, see Fast service bundle updates during development.

Build outputs appear in $OUT_DIR (out/ by default, with target partition images in $OUT). If you build multiple VM targets from the same source checkout, such as sdv_core_cf and sdv_ivi_cf, switching lunch targets in a shared out/ directory regenerates the Soong build graph on each switch. To keep incremental builds fast across VMs, open a separate terminal for each VM and re-export its OUT_DIR whenever you open a new shell before initializing the build environment:

# Terminal 1 (SDV Core VM)
export OUT_DIR=out_sdv
source build/envsetup.sh
lunch sdv_core_cf-aosp_current-userdebug
# Terminal 2 (SDV IVI VM)
export OUT_DIR=out_ivi
source build/envsetup.sh
lunch sdv_ivi_cf-aosp_current-userdebug

Test your build using Cuttlefish

After you build AAOS SDV, test your build using Cuttlefish.

  1. To start Cuttlefish with your build:

    cvd create

    Cuttlefish runs using your built target (sdv_core_cf-aosp_current-userdebug). After Cuttlefish has booted, this message is displayed:

    VIRTUAL_DEVICE_BOOT_COMPLETED
    Virtual device booted successfully
  2. Run adb to connect to Cuttlefish.

  3. Run adb devices to verify that your build is running. A result similar to this is displayed:

    List of devices attached
    0.0.0.0:6520 device
  4. Run cvd stop to shut down the device. Because cvd stop stops the VM immediately without a guest OS shutdown, run adb reboot first if you need to flush recent guest writes (such as staged APEX checkpoints) before stopping the device.

  5. To restart a stopped device while preserving its guest disk overlay and /data state (including staged service bundle APEX updates), run the start command that matches how you created the instance: cvd start for cvd create, or sdv-cf start --instance_name=instance1 for sdv-cf create --instance_name=instance1 (which replays the SDV bootconfig arguments). To restart a running device cleanly in place, run adb reboot. Running cvd create or sdv-cf create launches a new instance group from the baseline partition images rather than resetting a stopped instance in place; to discard guest overlays and start clean, remove a stopped instance with cvd remove before running cvd create (or stop a running instance with cvd stop --clear_instance_dirs and resume it with the matching start command). For more information, see Cuttlefish: Restart and reset.

To run multiple instances of Cuttlefish with different builds, see Cuttlefish: multi-tenancy.

Troubleshoot

This section explains how to troubleshoot errors that might occur during downloading, building, or running of AAOS SDV.

RBE errors

If you encounter any Remote Build Execution (RBE) errors, remove definitions of USE_RBE and ENABLE_RBE_BOOTSTRAP from .bashrc or .zshrc

cvd: VM manager crosvm isn't supported on this machine

If Cuttlefish reports that the VM manager crosvm isn't supported on your machine, run the following command to install Cuttlefish:

sudo apt install cuttlefish-common

cvd not found

If you receive a cvd not found error:

  1. Set up your build again.
  2. Continue with Choose a target.

Cuttlefish crash loops

If Cuttlefish enters a crash loop:

  1. To stop all Cuttlefish instances, run cvd stop.
  2. Run cvd start (or sdv-cf start --instance_name=instance1) to resume the existing instance. If corrupted guest disk state caused the crash loop, remove the stopped instance with cvd remove before running cvd create (or sdv-cf create --instance_name=instance1), or stop a running instance directly with cvd stop --clear_instance_dirs in the previous step and resume it with cvd start (or sdv-cf start --instance_name=instance1). For more information, see Test your build using Cuttlefish.