README.avb2 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. Android Verified Boot 2.0
  2. This file contains information about the current support of Android Verified
  3. Boot 2.0 in U-boot
  4. 1. OVERVIEW
  5. ---------------------------------
  6. Verified Boot establishes a chain of trust from the bootloader to system images
  7. * Provides integrity checking for:
  8. - Android Boot image: Linux kernel + ramdisk. RAW hashing of the whole
  9. partition is done and the hash is compared with the one stored in
  10. the VBMeta image
  11. - system/vendor partitions: verifying root hash of dm-verity hashtrees.
  12. * Provides capabilities for rollback protection.
  13. Integrity of the bootloader (U-boot BLOB and environment) is out of scope.
  14. For additional details check:
  15. https://android.googlesource.com/platform/external/avb/+/master/README.md
  16. 2. AVB 2.0 U-BOOT SHELL COMMANDS
  17. -----------------------------------
  18. Provides CLI interface to invoke AVB 2.0 verification + misc. commands for
  19. different testing purposes:
  20. avb init <dev> - initialize avb 2.0 for <dev>
  21. avb verify - run verification process using hash data from vbmeta structure
  22. avb read_rb <num> - read rollback index at location <num>
  23. avb write_rb <num> <rb> - write rollback index <rb> to <num>
  24. avb is_unlocked - returns unlock status of the device
  25. avb get_uuid <partname> - read and print uuid of partition <partname>
  26. avb read_part <partname> <offset> <num> <addr> - read <num> bytes from
  27. partition <partname> to buffer <addr>
  28. avb write_part <partname> <offset> <num> <addr> - write <num> bytes to
  29. <partname> by <offset> using data from <addr>
  30. 3. PARTITIONS TAMPERING (EXAMPLE)
  31. -----------------------------------
  32. Boot or system/vendor (dm-verity metadata section) is tampered:
  33. => avb init 1
  34. => avb verify
  35. avb_slot_verify.c:175: ERROR: boot: Hash of data does not match digest in
  36. descriptor.
  37. Slot verification result: ERROR_IO
  38. Vbmeta partition is tampered:
  39. => avb init 1
  40. => avb verify
  41. avb_vbmeta_image.c:206: ERROR: Hash does not match!
  42. avb_slot_verify.c:388: ERROR: vbmeta: Error verifying vbmeta image:
  43. HASH_MISMATCH
  44. Slot verification result: ERROR_IO
  45. 4. ENABLE ON YOUR BOARD
  46. -----------------------------------
  47. The following options must be enabled:
  48. CONFIG_LIBAVB=y
  49. CONFIG_CMD_AVB=y
  50. Then add `avb verify` invocation to your android boot sequence of commands,
  51. e.g.:
  52. => avb_verify=avb init $mmcdev; avb verify;
  53. => if run avb_verify; then \
  54. echo AVB verification OK. Continue boot; \
  55. set bootargs $bootargs $avb_bootargs; \
  56. else \
  57. echo AVB verification failed; \
  58. exit; \
  59. fi; \
  60. => emmc_android_boot= \
  61. echo Trying to boot Android from eMMC ...; \
  62. ... \
  63. run avb_verify; \
  64. mmc read ${fdtaddr} ${fdt_start} ${fdt_size}; \
  65. mmc read ${loadaddr} ${boot_start} ${boot_size}; \
  66. bootm $loadaddr $loadaddr $fdtaddr; \
  67. To switch on automatic generation of vbmeta partition in AOSP build, add these
  68. lines to device configuration mk file:
  69. BOARD_AVB_ENABLE := true
  70. BOARD_AVB_ALGORITHM := SHA512_RSA4096
  71. BOARD_BOOTIMAGE_PARTITION_SIZE := <boot partition size>
  72. After flashing U-boot don't forget to update environment and write new
  73. partition table:
  74. => env default -f -a
  75. => setenv partitions $partitions_android
  76. => env save
  77. => gpt write mmc 1 $partitions_android