hikey{,960}: Enable system-as-root and verity.

Add a build option TARGET_ANDROID_VERITY which can be set to anything
but the empty string to enable dm-android-verity. This option is
introduced because the UEFI bootloader for hikey and hikey960 has a bug
where it incorrectly rejects boot.img files with no ramdisk (see
https://bugs.96boards.org/show_bug.cgi?id=757).

This change *will* work on a hikey960 with the non-UEFI bootloader
installed.

Test: local
Bug: 72722987
Bug: 111829702
Change-Id: I75d0941866d9196e78e7c2943cdf05d35beb1879
Signed-off-by: Alistair Strachan <astrachan@google.com>
diff --git a/hikey/BoardConfig.mk b/hikey/BoardConfig.mk
index c76ad35..31a25ef 100644
--- a/hikey/BoardConfig.mk
+++ b/hikey/BoardConfig.mk
@@ -12,8 +12,17 @@
 BOARD_KERNEL_CMDLINE := console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime
 endif
 
-#Enable dtb fstab for treble
+ifneq ($(TARGET_ANDROID_VERITY),)
+# Enable dtb fstab for treble, with verity and system-as-root
+# NOTE: Disabled by default until b/111829702 is fixed
+BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab_v2
+BOARD_KERNEL_CMDLINE += rootwait ro init=/init root=/dev/dm-0
+BOARD_KERNEL_CMDLINE += dm=\"system none ro,0 1 android-verity 179:9\"
+BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
+else
+# Enable dtb fstab for treble
 BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab
+endif
 
 ifneq ($(TARGET_SENSOR_MEZZANINE),)
 BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_$(TARGET_SENSOR_MEZZANINE)
diff --git a/hikey960/BoardConfig.mk b/hikey960/BoardConfig.mk
index 09a1ed7..730d5f5 100644
--- a/hikey960/BoardConfig.mk
+++ b/hikey960/BoardConfig.mk
@@ -11,8 +11,17 @@
 BOARD_KERNEL_CMDLINE := androidboot.hardware=hikey960 console=ttyFIQ0 androidboot.console=ttyFIQ0
 BOARD_KERNEL_CMDLINE += firmware_class.path=/vendor/firmware loglevel=15 efi=noruntime
 
-#Enable dtb fstab for treble
+ifneq ($(TARGET_ANDROID_VERITY),)
+# Enable dtb fstab for treble, with verity and system-as-root
+# NOTE: Disabled by default until b/111829702 is fixed
+BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab_v2
+BOARD_KERNEL_CMDLINE += rootwait ro init=/init root=/dev/dm-0
+BOARD_KERNEL_CMDLINE += dm=\"system none ro,0 1 android-verity 8:58\"
+BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
+else
+# Enable dtb fstab for treble
 BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab
+endif
 
 ifneq ($(TARGET_SENSOR_MEZZANINE),)
 BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_$(TARGET_SENSOR_MEZZANINE)