Android Automotive OS 14 on a Raspberry Pi 4

Volodymyr Kozhemiakin
Make Android
Published in
5 min readJan 21, 2024

This story is about building and flashing Raspberry Pi 4 with built image of AOSP 14.

AAOS generated by leonardo.ai

As an Android developer I mostly worked on higher levels of Android: Application, sometimes Framework and Native libraries. At these levels we could work freely on Emulator. But the lower levels require the use of real hardware.

As we know, the main difference in workflow between the emulator and a real device occurs at the lower levels of the stack (HAL, Kernel, and Drivers), where the emulator simulates the hardware while a real device interacts with actual hardware components. At the higher levels (Application and Framework), the workflows are quite similar.

For working with hardware outside of work (company hardware boards), I found a hardware board that can be used for educational purposes.

Here are the list of hardware boards that can use for AOSP development:
DragonBoard 845c, Qualcomm Robotics Board RB5, HiKey 960, VIM3, TinkerBoard, Raspberry PI. Also, we could consider Pixel Phones as Development Platforms for Android Automotive.

In my opinion, the most suitable for hardware-based AOSP development with a large support community and lower price is the Raspberry PI 4.

Here are the main sections of this story:

  1. Download AOSP
  2. AOSP Build
  3. Creating RPi Boot Image
  4. Creating Bootable SD Card
  5. Flashing Raspberry Pi 4 with SD Card

Prerequisites

Before we do this, we need the following environment:

  • A 64 bit linux build machine with more than 16GB RAM and 400GB storage [requirements]. I used Ubuntu 22.04.3 OS with RAM 64Gb and 16 cores 2.5 GHz.
  • Raspberry Pi 4 any model.
Raspberry Pi 4
  • Touchscreen display or Monitor (in this case use mouse). I used Touchscreen display 15.6'' that was bought on aliexpress.
Touchscreen display 15.6'’
  • At least 16GB SD Card for flashing the image. SD card with low speed can affect on working firmware, so the speed should be at least 12.5 MB/s.

Download AOSP

Before start Downloading AOSP the linux machine should be established a build environment [doc].

More likely, it require installation of additional packages:

sudo apt-get install bc coreutils dosfstools e2fsprogs fdisk kpartx mtools ninja-build pkg-config python3-pip
sudo pip3 install meson mako jinja2 ply pyyaml dataclasses

Once machine set up, install Source control tools in order to download source code (AOSP), in my case it is repo [doc].

Download the source code [doc]. I used instruction from github. Use build commands from github to be sure that it is updated.

Initialize repo:

repo init -u https://android.googlesource.com/platform/manifest -b android-14.0.0_r20
curl -o .repo/local_manifests/manifest_brcm_rpi.xml -L https://raw.githubusercontent.com/raspberry-vanilla/android_local_manifest/android-14.0/manifest_brcm_rpi.xml --create-dirs

Sync source code:

repo sync

When repo sync done successfully it can be build.

AOSP Build

Setup Android build environment, run script:

. build/envsetup.sh

choose car userdebug build for Raspberry pi 4

lunch aosp_rpi4_car-userdebug

and build boot, system, and vendor images for the Raspberry Pi device.

make bootimage systemimage vendorimage

Here is explanation for these images.

  • The boot image is a specific package that contains the kernel and RAMDisk, which is necessary for the device’s boot process.
  • The system image contains the Android system files, including the framework, libraries, and system apps. It is mounted as the /system partition on the device.
  • The vendor image includes the hardware-specific binaries and libraries needed for the device to function. These files are part of the /vendor partition on the device.

During build it could some error appears, it might be lack of installed packages on Linux machine, so read log error and install. Example:

sudo apt-get install flex

once it build finished make flashable image for the device.

Creating RPi Boot Image

Run script that located on root folder of source code:

./rpi4-mkimg.sh

When this script is done, it should be image created

Done, created .../out/target/product/rpi4/RaspberryVanillaAOSP14–20240117-rpi4.img!

Creating Bootable SD Card

Insert SD card in Linux machine, use BalenaEtcher or Raspberry Pi Imager for flashing image on SD card.

Select the built image located in out/target/product/rpi4/RaspberryVanillaAOSP14–202401170-rpi4.img and specify SD card and Flash it.

balenaEtcher

Flashing Raspberry Pi 4 with SD Card

Insert SD Card into Raspberry Pi, connect power supply and wait until it flashed. It usually takes 1–2 min.

In order to works touchscreen display properly it requires to connect:

  • Power supply 5V 3A (Type-C).
  • HDMI cable (micro-HDMI — mini-HDMI)
  • Type-C cable for touchscreen (Type-C — USB A)

Finally, it flashed, connected and works.

Android Automotive OS 14 on a Raspberry Pi 4 with touchscreen display and computer mouse

I ran into two main problems:

  • First, my Linux machine didn’t have all necessary packages for building AOSP. I fixed this by installing the missing packages that I’ve mentioned above.
  • Second, after creating the SD card’s partitions and flashing the images, the Android Automotive OS wouldn’t boot on my Raspberry Pi. I solved this by using the rpi4-mkimg.sh script to make a single image.

Links that was helpful:

  1. Device specific configuration to build AOSP Android 14 for Raspberry Pi 4 and Raspberry Pi 5. https://github.com/raspberry-vanilla/android_local_manifest/tree/android-14.0
  2. Building Automotive AOSP 13 for Raspberry Pi 4: A Step-by-Step Guide https://medium.com/@subin.bsuresh27/building-automotive-aosp-13-for-raspberry-pi-4-a-step-by-step-guide-6f40bd6ba789
  3. Android Automotive OS 13 on a Raspberry Pi 4 https://www.snappautomotive.io/blog/android-automotive-os-13-on-a-raspberry-pi-4
  4. Using reference boards https://source.android.com/docs/setup/create/devices#845cdragonboard

--

--

Volodymyr Kozhemiakin
Make Android

Android Engineer | Mobile | Automotive | Enterprise | AOSP | Applications, Android Framework, System Services, HAL, Kernel | C/C++ | Java | Kotlin