Manage boot time

The boot process is a chain of actions starting from the boot ROM, followed by the bootloader, kernel, Init, Zygote, and system server (bold indicates Android-specific boot process). In the automotive-specific boot process, early services such as rearview camera (RVC) must start during the kernel boot.

Order Component Android Android Automotive
1 Boot ROM Loads the first stage of the boot loader into internal RAM.
2 Bootloader Inits memories, verifies for security, and loads kernel.
3 Kernel Sets up interrupt controllers, memory protection, caches, and scheduling; launches user space processes. Rearview camera (RVC) process starts early in kernel boot. After the process is up, GPIO from VMCU triggers RVC to show on display.
4 Init process Parses init.rc scripts, mounts file systems, launches Zygote, launches system process. Vehicle HAL (VHAL) starts during init phase as part of core services. Can be moved to earlier states depending on ServiceManager; requires removing dependencies on shared libraries (such as init).
5 Zygote Sets up Java Runtime and init memory for Android objects.
6 System server First Java component in the system, starts core Android services. CarService starts after all system services are started.

Optimize boot time

To improve boot time in your system, use the following guidelines:

  • Kernel. Load only the modules in use and initialize only the hardware components in use.

  • init.rc

    • Watch for blocking operations (service compared to command invocation).
    • Start only what is used.
    • Setting correct priority for services.
  • Zygote. Class preloading optimization (specify the list of classes to load).

  • Package Manager

  • System server. Start only the system services that are used.

For help with optimization, Google provides the following tools:

  • Use packages/services/Car/tools/bootanalyze/bootanalyze.py to analyze logcat and dmesg logs.

  • Use packages/services/Car/tools/bootio/ to record I/O for processes during the boot. You must compile the kernel with specific flags (refer to the README.md file).

Start services early

In the boot sequence, some services might start before Android starts to boot.

Rearview camera

The rearview camera (RVC) should be handled in the kernel. The VMCU notifies the native kernel process when the vehicle shifts into Reverse, after which the native kernel process displays the RVC image onto the display. The vehicle HAL can control the RVC using hardware/libhardware/include/hardware/vehicle_camera.h.

Vehicle HAL (VHAL)

Some systems might need to read and buffer CAN data (for example, vehicle speed, gear status) during the early stages of the boot sequence while waiting for the user-space service to start (which occurs later in the boot sequence). This scenario requires VNS and the HAL and CAN controllers to start very early, typically within a few seconds.

  • Systems that can quickly mount /system can simply launch service manager then VNS early.

  • System that can't quickly mount /system must move both service manager and VNS to the kernel boot image and link all dependent libraries statically.