Skip to content

Boot chain

The XP8800 uses the standard Qualcomm SDM630 boot flow. The primary boot loader (PBL) in mask ROM starts the XBL/UEFI firmware. The XBL/UEFI firmware then starts the Android Boot Loader (ABL).

The ABL is an AArch64 UEFI application. It loads an Android boot.img or a UEFI payload that can start.

Stages

flowchart TB
  PBL["PBL (mask ROM)<br/>Qualcomm primary boot loader"]
  XBL["XBL / UEFI firmware<br/>+ TZ, RPM, hyp, devcfg, pmic, cmnlib"]
  ABL["abl_a — Android Boot Loader<br/>AArch64 UEFI app (LinuxLoader.efi)"]
  AVB{"Bootloader unlocked?"}
  SKIP["Skip AVB boot verification"]
  ENFORCE["Enforce verified boot / dm-verity"]
  BOOTIMG["Android boot.img<br/>gzip kernel + appended DTB"]
  UBOOT["U-Boot (payload in boot.img)<br/>simplefb, storage, USB, extlinux/EFI"]
  LINUX["Linux arm64<br/>+ sdm630-sonim-xp8.dtb + initramfs"]

  PBL --> XBL --> ABL --> AVB
  AVB -->|yes| SKIP
  AVB -->|no| ENFORCE
  SKIP --> BOOTIMG --> UBOOT --> LINUX
  ENFORCE --> BOOTIMG

ABL is UEFI, not a raw ELF

The abl_a partition on disk is an ELF32 ARM container. But the real boot loader in it is a PE32+ EFI application for AArch64. An EFI Firmware Volume with an LZMA payload holds it. The PE debug path shows where it comes from:

.../out/target/product/XP8812/obj/ABL_OBJ/Build/DEBUG_CLANG35/AARCH64/
QcomModulePkg/Application/LinuxLoader/LinuxLoader/DEBUG/LinuxLoader.dll

Consequences:

  • The ABL is a UEFI LinuxLoader, and it reads an Android boot.img. It can also start UEFI payloads such as U-Boot.
  • There is no dtbo partition. Put the device tree directly after the gzip-compressed kernel in the boot.img. Do not put it in its own partition.
  • When the bootloader is unlocked, the ABL records “Device is unlocked, Skipping boot verification”. It then makes AVB less strict.

Android boot-image format

Field Value
Header Android boot header v0
Page size 4096 bytes
Kernel offset 0x00008000
Ramdisk offset 0x01000000
Tags offset 0x00000100
Kernel gzip Image.gz (ARM64)
Appended The DTB catalog. The last DTB is dtb_101.dtb for the board.

Usually, you make a custom boot image for this device as follows:

u-boot-nodtb.bin.gz ++ sdm630-sonim-xp8.dtb → boot.img

Use an empty ramdisk, 4096-byte pages, and the kernel offset above. These values agree with the stock boot.img header.

Installing a custom boot loader

During bring-up, a usual safe procedure is to chainload a custom boot loader in RAM first. Write it to boot_a only after it boots reliably.

fastboot boot of a small (~640 KiB) U-Boot image operates on this platform. Reports say that multi-megabyte TWRP images hang while the host sends them.

Slot behaviour and recovery

  • The active slot at the inspection was _a.
  • A new slot starts with retry count 7. After some boots that do not succeed, the bootloader marks the slot as unbootable and stops in fastboot. On an unlocked bootloader, fastboot set_active a recovers the phone.
  • Keep abl_b and boot_b stock. The stock ABL on _b has no flash and no set_active. A change to _b can brick the phone.
  • If abl_a is corrupt, or XBL does not accept it, XBL does not use abl_b. Write the stock abl_a again with EDL.

Fastboot hygiene

Query one variable in each command (getvar unlocked, getvar current-slot).

WARNING: DO NOT RUN getvar all. IT CAN RETURN unknown command OR STOP THE USB ENDPOINT.

After a fastboot write, wait (bytes / 15_000_000) + 5 seconds before the next command. The ABL sends its acknowledgment immediately. But it continues to write to the eMMC at 15 MB/s (approximately).