Building Automotive AOSP 13 for Raspberry Pi 4: A Step-by-Step Guide

Subin B Suresh
3 min readDec 31, 2023

--

Ready to unleash the power of Android 13 on your Raspberry Pi 4? Buckle up, tinkerers, developers, and Android enthusiasts! 🚀

This guide will walk you through the intricate process of building Automotive AOSP 13 from scratch for your Raspberry Pi 4. It’s a rewarding journey, requiring careful preparation, meticulous execution, and a dash of adventurous spirit. But the payoff? A fully functional Android Automotive 13 system running on your favorite single-board computer, pushing the boundaries of what’s possible on the Pi.

Note : While the core steps of building AOSP remain largely the same as for other devices, you’ll encounter some exciting Raspberry Pi-specific adjustments along the way. Think of it as a familiar culinary recipe with a dash of secret Raspberry Pi ingredients!

Ready to dive in? We’ll break down the process into five key sections:

  1. AOSP Repo Sync: Fetching the Android Open Source Project source code.
  2. RPI Kernel Sync & Build: Compiling a Raspberry Pi-compatible kernel.
  3. AOSP Build: Crafting the Android system itself.
  4. Creating RPi Boot Image: Preparing the boot sequence for your Pi.
  5. Creating Bootable SD Card: Flashing your masterpiece onto an SD card.

So, gather your tools, summon your tech-savvy, and let’s embark on this Android adventure!

Remember: This is an advanced process, requiring understanding of Linux commands and troubleshooting skills. But fear not, the guide will break down each step in detail, and the online community is full of helpful resources and fellow adventurers.

Now let’s see the hardware and software requirements that are needed for the whole process:

  • Raspberry Pi 4: Any model (B, 4B, 400), i used one with 8GB RAM.
  • Display/Monitor: Touchscreen is optional if you can use the mouse.
  • 16GB SD Card: Storage for flashing the built AOSP, into Raspberry pi.
  • 64 bit linux build machine with atleast 16GB RAM and 400GB storage.

Alright, let’s discuss the topic in detail and it is important to follow the same order of procedure

Prerequisite

Follow the steps from Android documentation to make the machine suitable for building AOSP

Create a directory for AOSP and do the steps inside it

AOSP Repo Sync

  • Repo Init : I am using android-13.0.0_r75 branch
repo init -u https://android.googlesource.com/platform/manifest -b android-13.0.0_r75
  • Dowloading necessary Raspberry Pi kernels
curl -o .repo/local_manifests/manifest_brcm_rpi4.xml -L https://raw.githubusercontent.com/raspberry-vanilla/android_local_manifest/android-13.0/manifest_brcm_rpi4.xml --create-dirs
  • Repo sync
repo sync

RPI Kernel Sync & Build

Create a directory outside AOSP directory for RPI kernal build, then do the following:

  • Repo Init
repo init -u https://android.googlesource.com/kernel/manifest -b common-android13-5.15-lts
  • Download kernal manifest
curl --create-dirs -L -o .repo/local_manifests/manifest_brcm_rpi4.xml -O -L https://raw.githubusercontent.com/raspberry-vanilla/android_kernel_manifest/android-13.0/manifest_brcm_rpi4.xml
  • Repo Sync
repo sync
  • Build the kernal
BUILD_CONFIG=common/build.config.rpi4 build/build.sh

Compiled kernel Image, dtbs, and overlays can be found in out/common/arch/arm64/boot directory.

Copy all files in the above-mentioned location and replace existing files in device/brcm/rpi4-kernel directory of the AOSP source tree to include them in Android 13 build.

AOSP Build

  • Setting up the environment
. build/envsetup.sh
  • Setting build flavor
lunch aosp_rpi4_car-userdebug
  • Build AOSP 13
make bootimage systemimage vendorimage

Creating RPi Boot Image

  • Create a complete image that can be directly flashed to an SD card.
./rpi4-mkimg.sh

Image will be availabe in out/target/product/rpi4/

Creating Bootable SD Card

We use a tool called raspberry pi imager to flash the image onto our SD card.

  • Download the imager, install and launch it.
  • Configure flashing options:

Device: Choose “Raspberry Pi 4” to ensure compatibility with your hardware.

Operating System: Select the custom Android Automotive 13 image you’ve generated, located in the out/target/product/rpi4 directory.

Storage: Choose the SD card you intend to use for flashing, ensuring it has sufficient capacity.

  • Click next and wipe data when prompted.
  • After successful flash, it can be plugged in to Raspberry pi board and booted.

Congratulations! 🎉 Your Raspberry Pi 4 is now equipped with Android 13 Automotive, and this guide has empowered you to navigate the intricacies of platform development. Embrace the journey, armed with Linux commands and a dash of adventurous spirit, as you witness your Raspberry Pi transform into a robust Android Automotive platform. May your coding endeavors be filled with innovation and success on this exciting path! Happy coding! 🌟

--

--