The vast majority of the AOSP tree (like frameworks/ and system/) contains generic, device-agnostic code written by Google. However, to make Android actually boot on a specific piece of physical hardware (like a Google Pixel or a Samsung Galaxy), you need custom drivers, configurations, and the Linux kernel.
These highly specific components are strictly isolated into three dedicated directories to maintain the purity of the generic framework.
The device/ Directory
This directory contains the open-source configuration files required to build a specific phone, tablet, or development board. It acts as the "glue" that tells the build system exactly what to compile.
It is typically structured by manufacturer, then by device codename (e.g., device/google/coral/ for the Pixel 4 XL).
A typical device folder contains:
BoardConfig.mk: Defines absolute low-level hardware constants (e.g., "This device uses an ARM64 CPU", "The system partition is exactly 2GB in size", "The kernel address is 0x80000000").device.mk: A list of which generic AOSP apps and modules should be included in this specific build.- Overlay Files: XML files that override default AOSP framework variables (e.g., disabling a software navigation bar because the device has physical hardware buttons).
# Sourcing the environment will automatically discover the device configuration files
source build/envsetup.sh
# The lunch menu populates its list by reading device/*/vendorsetup.sh
lunch aosp_coral-userdebug
The vendor/ Directory
While the device/ directory contains open-source configurations, the vendor/ directory contains the closed-source, highly proprietary code.
Silicon manufacturers (like Qualcomm, MediaTek, or Broadcom) spend billions developing their hardware, and they usually refuse to release their driver source code. Instead, they provide pre-compiled binary files (known as "proprietary blobs").
- Proprietary Blobs (
.sofiles): The compiled drivers for the GPU, Wi-Fi modem, and Camera Image Signal Processor (ISP). - Vendor HAL Implementations: The proprietary code that fulfills the open-source HAL interfaces defined in the
hardware/directory.
When you compile AOSP, the build system silently copies these proprietary blobs directly into the final vendor.img output file.
The kernel/ Directory
As discussed in earlier modules, Android relies heavily on the Linux kernel.
Historically, the kernel source code for a specific device was placed directly inside the AOSP tree in the kernel/ directory. The AOSP build system would cross-compile the Linux kernel, package it, and insert it into the boot.img automatically.
The Modern GKI Shift In modern Android development (Android 12+), Google mandates the Generic Kernel Image (GKI).
- The kernel is no longer compiled inline with the rest of the AOSP tree.
- Instead, developers download a pre-compiled kernel binary directly from Google and place it in the
device/directory. - Vendor-specific kernel drivers are compiled separately as Loadable Kernel Modules (
.kofiles) and loaded dynamically at boot time.
Understanding the complex relationship between device/ (open-source config), vendor/ (closed-source blobs), and the kernel is the absolute foundation of "device bring-up" engineering.