Introduction
From header version 3 on, an Android boot image holds only the generic kernel and ramdisk; what the device's hardware needs is in a second partition, vendor_boot. Its image starts with the letters VNDRBOOT. The structures are in AOSP's bootimg.h, read as raw text (a copy is in samples/androidboot/sources; the descriptions are our own words). Two header versions exist, 3 and 4. All numbers are little-endian.
The loader loads the kernel and the DTB at their addresses, the vendor ramdisk at ramdisk_addr, the boot image's generic ramdisk straight after it and, in version 4, the bootconfig after that.
Layout of the file
Each part is padded to a multiple of the header's page_size, and the header itself takes (2112 + page_size − 1) / page_size pages in version 3 and (2128 + ...) in version 4. Version 3: header, vendor ramdisk, DTB. Version 4: header, vendor ramdisk section, DTB, vendor ramdisk table, bootconfig. The vendor ramdisk section of a version 4 image is several ramdisks one after another; its size in the header is the size of all of them.
The header
| Offset | Size | Version | Field | What it holds |
|---|---|---|---|---|
| 0 | 8 | 3 | magic | VNDRBOOT |
| 8 | 4 | 3 | header_version | 3 or 4. |
| 12 | 4 | 3 | page_size | The flash page size, chosen by the vendor. |
| 16 | 4 | 3 | kernel_addr | The physical load address of the kernel. |
| 20 | 4 | 3 | ramdisk_addr | Where the vendor ramdisk is loaded. |
| 24 | 4 | 3 | vendor_ramdisk_size | The vendor ramdisk (all of them, in version 4). |
| 28 | 2048 | 3 | cmdline | The vendor's part of the kernel command line, zero-ended. |
| 2076 | 4 | 3 | tags_addr | Where the loader prepares kernel tags, if needed. |
| 2080 | 16 | 3 | name | The product name, zero-ended. |
| 2096 | 4 | 3 | header_size | 2112 in version 3, 2128 in version 4. |
| 2100 | 4 | 3 | dtb_size | The device tree blob, in bytes. |
| 2104 | 8 | 3 | dtb_addr | Its physical load address. |
| 2112 | 4 | 4 | vendor_ramdisk_table_size | The size of the ramdisk table. |
| 2116 | 4 | 4 | vendor_ramdisk_table_entry_num | The number of entries. |
| 2120 | 4 | 4 | vendor_ramdisk_table_entry_size | The size of one entry (108 bytes in the AOSP structure). |
| 2124 | 4 | 4 | bootconfig_size | The bootconfig section, in bytes. |
The vendor ramdisk table (version 4)
One entry for each ramdisk in the vendor ramdisk section, so that a boot loader can load only the ones it needs.
| Offset | Size | Field | What it holds |
|---|---|---|---|
| 0 | 4 | ramdisk_size | This ramdisk's size. |
| 4 | 4 | ramdisk_offset | Where it starts inside the vendor ramdisk section. |
| 8 | 4 | ramdisk_type | 0 none (unspecified), 1 platform (always loaded), 2 recovery (loaded when booting recovery), 3 dlkm (dynamically loadable kernel modules). |
| 12 | 32 | ramdisk_name | The name, zero-ended and unique. |
| 44 | 64 | board_id | Sixteen 32-bit words naming the board, SoC or platform the ramdisk is for. The encoding is the hardware vendor's. |
The bootconfig (version 4)
The Boot Configuration parameters known when the image was built: text of key and value pairs. The loader places it after the generic ramdisk, followed by the bootconfig trailer, before it enters the kernel. The viewer shows its first characters as text.
What the viewer shows
The header field by field, the layout as nodes that tile the file (header, vendor ramdisk section with each ramdisk of the table as a node of its own, DTB, ramdisk table with each entry opened, bootconfig, and an AVB footer with its vbmeta image when there is one), and the checks: parts that run past the end of the file, ramdisks outside their section, an entry size under 108 and a header size field that differs from the structure. Ramdisks and the DTB open as files of their own.
The explorer calls a file a vendor boot image when it starts with VNDRBOOT, the version is 3 or 4 and the page size is a power of two of at least 512. The .img row asks for it by magic.
No real vendor_boot.img was found among public test data, so everything here rests on the header text and on images built to the layout (the numbers and offsets read back, the tiling and every error branch tested). That is why this page cannot be called complete.
Not described
Known, not yet covered
- Viewer: ramdisks are cpio archives, usually compressed; they open as files but have no cpio viewer.
- Reference: board_id encodings are vendor-defined and not described; the bootconfig's syntax and its trailer are not described beyond the text above.
- Viewer: a file with no extension is not recognised by name alone.
Unknown
- Reference: how real devices' vendor_boot images behave beyond the header text: no real image was available.
Links
Specifications
- bootimg.h – the header structures (AOSP, BSD licence)
- Vendor boot partitions – Android's documentation