Enable dynamic partitions

This enables dynamic partitions build, which applies next changes:
 - building "super.img", which should be flashed to "super" partition;
   it contains system and vendor logical partitions
 - building boot.img with normal ramdisk; system won't be mounted as
   root anymore (it will be mounted to /system), as system partition
   is now logical partitions inside of super partition
 - building recovery.img, as we can't use boot.img to store recovery
   ramdisk anymore; we can't get away without recovery at all, because
   flashing logical partitions is only possible from fastbootd mode,
   which should be done on recovery boot
 - fstab is changed to mount system and vendor as logical partitions
 - early mounting should be removed from dts file, as system and vendor
   are logical and can't be mounted that easy; it's done from fstab
   now, when booting the ramdisk

Bootloader should be accommodated for this change, by replacing
"system" and "vendor" partitions with a single "super" partition. Also,
"skip_initramfs" param shouldn't be passed to kernel anymore, as we are
using ramdisk again.

In kernel we should remove dra7xx-android-fstab.dtsi file (so called
"dtb fstab", see [1] for details).

As super.img will be generated, one can flash it instead of system.img
and vendor.img, from bootloader's fastboot mode:

    $ fastboot flash super super.img

If it's needed to only update system or vendor partition, one can reboot
to recovery mode, enter "Android Fastboot" (fastbootd), and flash
logical partitions from there, like this:

    $ fastboot flash system_a system.img

[1] https://source.android.com/devices/architecture/kernel/mounting-partitions-early#fstab-entries

Change-Id: I83a2cff34ece945cae7689c6248bb7f1800cdac2
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
diff --git a/BoardConfig.mk b/BoardConfig.mk
index af7c3a2..2f03a28 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -41,10 +41,18 @@
 
 USE_CAMERA_STUB := true
 
-BOARD_BOOTIMAGE_PARTITION_SIZE     := 20971520   # 20 MiB
-BOARD_USERDATAIMAGE_PARTITION_SIZE := 1879048192 # 1792MB
-BOARD_SYSTEMIMAGE_PARTITION_SIZE   := 1073741824 # 1024MB
-BOARD_VENDORIMAGE_PARTITION_SIZE   := 268435456  # 256MB
+BOARD_BOOTIMAGE_PARTITION_SIZE := 20971520 # 20 MiB
+BOARD_RECOVERYIMAGE_PARTITION_SIZE := 67108864 # 64 MiB
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 961658368 # ~917 MiB
+
+BOARD_SUPER_PARTITION_SIZE := 2684354560 # 2560 MiB
+BOARD_SUPER_PARTITION_GROUPS := group_oem
+# In case when A/B is enabled and we have only one group:
+# size_group = (size_super - 1 MiB) / 2
+BOARD_GROUP_OEM_SIZE := 1341652992 # 1279.5 MiB
+BOARD_GROUP_OEM_PARTITION_LIST := system vendor
+BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT := true
+BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE := true
 
 TARGET_USERIMAGES_USE_EXT4 := true
 BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
@@ -53,11 +61,7 @@
 TARGET_BOARD_PLATFORM := am57x
 TARGET_COPY_OUT_VENDOR := vendor
 
-TARGET_NO_RECOVERY := true
 TARGET_RECOVERY_FSTAB := device/ti/beagle_x15/$(TARGET_FSTAB)
-BOARD_USES_RECOVERY_AS_BOOT := true
-BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
-
 TARGET_RECOVERY_PIXEL_FORMAT := "BGRA_8888"
 TARGET_RECOVERY_UI_LIB := librecovery_ui_beagle_x15
 TARGET_RELEASETOOLS_EXTENSIONS := device/ti/beagle_x15
diff --git a/device.mk b/device.mk
index b473121..b7f1dc1 100644
--- a/device.mk
+++ b/device.mk
@@ -148,6 +148,7 @@
 	device/ti/beagle_x15/init.beagle_x15board.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.beagle_x15board.rc \
 	device/ti/beagle_x15/init.beagle_x15board.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.beagle_x15board.usb.rc \
 	device/ti/beagle_x15/ueventd.beagle_x15board.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc \
+	device/ti/beagle_x15/$(TARGET_FSTAB):$(TARGET_COPY_OUT_RAMDISK)/fstab.beagle_x15board \
 	device/ti/beagle_x15/$(TARGET_FSTAB):$(TARGET_COPY_OUT_VENDOR)/etc/fstab.beagle_x15board \
 	frameworks/native/data/etc/android.hardware.ethernet.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.ethernet.xml \
 
@@ -188,3 +189,5 @@
 
 PRODUCT_PACKAGES_DEBUG += \
 	update_engine_client
+
+PRODUCT_USE_DYNAMIC_PARTITIONS := true
diff --git a/fstab.beagle_x15board_v4 b/fstab.beagle_x15board_v4
index 5e6549c..4b84959 100644
--- a/fstab.beagle_x15board_v4
+++ b/fstab.beagle_x15board_v4
@@ -4,11 +4,14 @@
 # specify 'check', and must come before any filesystems that do specify 'check'
 
 #<src>                                                                  <mnt_point>     <type>  <mnt_flags and options> <fs_mgr_flags>
-/dev/block/platform/44000000.ocp/480b4000.mmc/by-name/system            /               ext4    ro,barrier=1            wait,slotselect
+system                                                                  /system         ext4    ro,barrier=1            wait,slotselect,logical,first_stage_mount
+# Add all non-dynamic partitions except system, after this comment
 /dev/block/platform/44000000.ocp/480b4000.mmc/by-name/userdata          /data           ext4    noatime,nosuid,nodev    wait,check,quota
 /dev/block/platform/44000000.ocp/480b4000.mmc/by-name/recovery          /recovery       emmc    defaults                defaults
 /dev/block/platform/44000000.ocp/480b4000.mmc/by-name/boot              /boot           emmc    defaults                defaults
 /dev/block/platform/44000000.ocp/480b4000.mmc/by-name/misc              /misc           emmc    defaults                defaults
+# Add all dynamic partitions except system, after this comment
+vendor                                                                  /vendor         ext4    ro,barrier=1            wait,slotselect,logical,first_stage_mount
 # USB / SD card
 /devices/platform/44000000.ocp/488c0000.omap_dwc3_2/488d0000.usb*       auto            auto    defaults                voldmanaged=usb0:auto
 /devices/platform/44000000.ocp/48880000.omap_dwc3_1/48890000.usb*       auto            auto    defaults                voldmanaged=usb1:auto
diff --git a/fstab.beagle_x15board_v5 b/fstab.beagle_x15board_v5
index b3dd7d1..90c4bd6 100644
--- a/fstab.beagle_x15board_v5
+++ b/fstab.beagle_x15board_v5
@@ -4,11 +4,14 @@
 # specify 'check', and must come before any filesystems that do specify 'check'
 
 #<src>                                                                                                                                          <mnt_point>     <type>  <mnt_flags and options> <fs_mgr_flags>
-/dev/block/platform/44000000.ocp/48000000.interconnect/48000000.interconnect:segment@0/480b4000.target-module/480b4000.mmc/by-name/system       /               ext4    ro,barrier=1            wait,slotselect
+system                                                                                                                                          /system         ext4    ro,barrier=1            wait,slotselect,logical,first_stage_mount
+# Add all non-dynamic partitions except system, after this comment
 /dev/block/platform/44000000.ocp/48000000.interconnect/48000000.interconnect:segment@0/480b4000.target-module/480b4000.mmc/by-name/userdata     /data           ext4    noatime,nosuid,nodev    wait,check,quota
 /dev/block/platform/44000000.ocp/48000000.interconnect/48000000.interconnect:segment@0/480b4000.target-module/480b4000.mmc/by-name/recovery     /recovery       emmc    defaults                defaults
 /dev/block/platform/44000000.ocp/48000000.interconnect/48000000.interconnect:segment@0/480b4000.target-module/480b4000.mmc/by-name/boot         /boot           emmc    defaults                defaults
 /dev/block/platform/44000000.ocp/48000000.interconnect/48000000.interconnect:segment@0/480b4000.target-module/480b4000.mmc/by-name/misc         /misc           emmc    defaults                defaults
+# Add all dynamic partitions except system, after this comment
+vendor                                                                                                                                          /vendor         ext4    ro,barrier=1            wait,slotselect,logical,first_stage_mount
 # USB / SD card
 /devices/platform/48800000.interconnect/48800000.interconnect:segment@0/488c0000.target-module/488c0000.omap_dwc3_2/488d0000.usb*               auto            auto    defaults                voldmanaged=usb0:auto
 /devices/platform/48800000.interconnect/48800000.interconnect:segment@0/48880000.target-module/48880000.omap_dwc3_1/48890000.usb*               auto            auto    defaults                voldmanaged=usb1:auto