Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Android boot image

From ReverseEngineering.wiki
Format
Magic ANDROID! (boot), VNDRBOOT (vendor_boot)
Extensions .img
Endianness little
License Apache-2.0 (AOSP mkbootimg)
On this wiki Facts · Code · Notes · Topics

Android boot.img / recovery.img / vendor_boot.img: a header starting 'ANDROID!' (or 'VNDRBOOT') followed by page-aligned kernel, ramdisk and optional dtb, with header versions 0 to 4 changing the layout.

Overview

The boot partition holds a header, then the kernel (often a gzip/lz4 Image, see Platform:Linux kernel), a ramdisk (Format:Cpio newc (initramfs), usually gzip or lz4 compressed) and optionally a second stage, recovery DTBO and a Format:Flattened device tree bundle. Each part starts on a page boundary (header_version 0-2: page_size from the header, typically 2048 or 4096; version 3 and 4: fixed 4096). Some vendors prepend extra wrappers or append an AVB footer / signature, and Samsung and others use variants; unpack with AOSP unpack_bootimg.py.

boot_img_hdr v0 (offsets, little-endian)

Offset Field
0 magic ANDROID!
8 kernel_size
12 kernel_addr
16 ramdisk_size
20 ramdisk_addr
24 second_size
28 second_addr
32 tags_addr
36 page_size
40 header_version (0 in old images)
44 os_version: A[31:25] B[24:18] C[17:11] (year-2000)[10:4] month[3:0]
48 name[16]
64 cmdline[512]
576 id[8 u32] (SHA-1 style digest)
608 extra_cmdline[1024] (header ends at 1632)

v1 adds recovery_dtbo_size (u32, 1632), recovery_dtbo_offset (u64, 1636), header_size (u32, 1644). v2 adds dtb_size (u32, 1648) and dtb_addr (u64, 1652). Layout v0-2: header, kernel, ramdisk, second, recovery dtbo, dtb, each rounded up to page_size.

v3 and v4 (GKI era)

v3 boot header (4096 bytes on flash): magic 0, kernel_size 8, ramdisk_size 12, os_version 16, header_size 20, reserved[4] 24, header_version 40, cmdline[1536] at 44. v4 adds signature_size (u32 at 1580) and a boot signature after the ramdisk. Layout: header, kernel, ramdisk, signature, all 4096-aligned. Load addresses move to the new vendor_boot image.

vendor_boot header

v3 (2112 bytes): magic VNDRBOOT 0, header_version 8, page_size 12, kernel_addr 16, ramdisk_addr 20, vendor_ramdisk_size 24, cmdline[2048] 28, tags_addr 2076, name[16] 2080, header_size 2096, dtb_size 2100, dtb_addr (u64) 2104. Layout: header, vendor ramdisk, dtb (page_size aligned).

v4 (2128 bytes) adds vendor_ramdisk_table_size 2112, vendor_ramdisk_table_entry_num 2116, vendor_ramdisk_table_entry_size 2120, bootconfig_size 2124 and appends the ramdisk table and the bootconfig after the dtb. Table entry: ramdisk_size, ramdisk_offset (in the vendor ramdisk section), ramdisk_type (0 none, 1 platform, 2 recovery, 3 dlkm), name[32], board_id[16 u32]. The bootloader concatenates vendor ramdisk(s), then the generic ramdisk, then bootconfig (see Linux bootconfig) before starting the kernel.

Identification

Search for ANDROID! at offset 0 (sometimes after a vendor header; check the first 512 bytes). header_version at offset 40 distinguishes layouts, but in v3/v4 images the same offset holds header_version while page_size is absent. os_version 0 is common.

Sources: AOSP system/tools/mkbootimg include/bootimg/bootimg.h, unpack_bootimg.py.

See also Technique:Unpacking firmware update containers for the other containers around boot images (OTA payload, sparse, super).