Managing 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 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.

Optimizing 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/ 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 file).

Starting services early

In the boot sequence, some services may 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 may 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 cannot quickly mount /system must move both service manager and VNS to the kernel boot image and link all dependent libraries statically.