History log of /external/avb/examples/uefi/uefi_avb_boot.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
d9c76c765496aab9b4495083b9c5c8a254eeb754 11-Jan-2017 David Zeuthen <zeuthen@google.com> Add sample UEFI bootloader using libavb and libavb_ab.

This currently isn't integrated into the Android build system and
currently there are no lunch targets using it. There are plans for
doing it but it's a lot of work and somewhat low on the list of
priorities!

The main point of this work is to serve as an example of how libavb is
integrated into a bootloader.

Here's the output from running the UEFI app in qemu:

$ qemu-system-x86_64 -enable-kvm -bios ~/OVMF.fd /ssd/android/aosp/out/target/product/uefi_x86_64/full-disk-image.img -nographic

[...]

Boot Failed. EFI DVD/CDROM
Boot Failed. EFI Floppy
Boot Failed. EFI Floppy 1
UEFI AVB-based bootloader
read_is_device_unlocked() ops returned that device is UNLOCKED
avb_ab_flow() returned OK
slot_suffix: _b
cmdline: dm="1 vroot none ro 1,0 2080496 verity 1 PARTUUID=3a36aa10-487f-4041-b826-0e1464bf4030 PARTUUID=3a36aa10-487f-4041-b826-0e1464bf4030 4096 4096 260062 260062 sha1 85fb4b1b987772a318431121bdb8e49d9d2ec012 d44a49abaf298a12e8dc65f11c5f7c4647f82a6b 1 ignore_zero_blocks" root=0xfd00 androidboot.vbmeta.device=PARTUUID=8280e851-a528-4e08-8ba1-0fec0e71f385 androidboot.slot_suffix=_b androidboot.vbmeta.device_state=unlocked androidboot.vbmeta.hash_alg=sha256 androidboot.vbmeta.size=3200 androidboot.vbmeta.digest=5fac3fed3da9af7946732150417bcea02ebae095dd387f76252aaf0bd48f9aad
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 4.4.10+ (zeuthen@luna.cam.corp.google.com) (gcc version 4.9.x 20150123 (prerelease) (GCC) ) #3 SMP Tue Jan 10 17:56:25 EST 2017
[ 0.000000] Command line: rootfstype=ext4 init=/init console=ttyS0,115200 androidboot.console=ttyS0 androidboot.hardware=uefi_x86_64 enforcing=0 androidboot.selinux=permissive androidboot.debuggable=1 buildvariant=eng dm="1 vroot none ro 1,0 2080496 verity 1 PARTUUID=3a36aa10-487f-4041-b826-0e1464bf4030 PARTUUID=3a36aa10-487f-4041-b826-0e1464bf4030 4096 4096 260062 260062 sha1 85fb4b1b987772a318431121bdb8e49d9d2ec012 d44a49abaf298a12e8dc65f11c5f7c4647f82a6b 1 ignore_zero_blocks" root=0xfd00 androidboot.vbmeta.device=PARTUUID=8280e851-a528-4e08-8ba1-0fec0e71f385 androidboot.slot_suffix=_b androidboot.vbmeta.device_state=unlocked androidboot.vbmeta.hash_alg=sha256 androidboot.vbmeta.size=3200 androidboot.vbmeta.digest=5fac3fed3da9af7946732150417bcea02ebae095dd387f76252aaf0bd48f9aad skip_initramfs

[...]

with a disk image that looks like the following:

$ gdisk -l /ssd/android/aosp/out/target/product/uefi_x86_64/full-disk-image.img
GPT fdisk (gdisk) version 0.8.8

Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /ssd/android/aosp/out/target/product/uefi_x86_64/full-disk-image.img: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): DE89968C-68DC-400C-9022-D52EB1E25ABF
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 8-sector boundaries
Total free space is 13 sectors (6.5 KiB)

Number Start (sector) End (sector) Size Code Name
1 40 524327 256.0 MiB EF00 EFI
2 524328 526375 1024.0 KiB FFFF vbmeta_a
3 526376 528423 1024.0 KiB FFFF vbmeta_b
4 528424 593959 32.0 MiB FFFF boot_a
5 593960 659495 32.0 MiB FFFF boot_b
6 659496 2756647 1024.0 MiB FFFF system_a
7 2756648 4853799 1024.0 MiB FFFF system_b
8 4853800 4855847 1024.0 KiB FFFF misc
9 4855848 8388567 1.7 GiB FFFF userdata

I have plans (not in the near future) for creating a CL to add a lunch
target to build full-disk-image.img as above, including putting the
avb_bootloader.efi binary in the EFI partition. This could be used for
AVB integration tests which could run on pre-submit etc.

This is partly based on work done by Kevin Chavez during his summer
2016 internship working on A/B and UEFI for Brillo - thanks Kevin!

Bug: None
Test: All unit tests pass.
Test: Boots in qemu and works as expected.

Change-Id: I71884927b7c53c3769af370bb500f985402ed653
/external/avb/examples/uefi/uefi_avb_boot.c