[General Topics] beardwhiskers:
The Blu Vivo XL4 phone was first introduced in December 2018, and I bought mine in summer of 2019. It is my daily driver. The original Blu stock ROM is Android 8.1 Oreo, last updated October 2019, with no additional support from Blu. I wanted to upgrade the OS, keep the phone encrypted (best security), and minimize Google bloatware. After researching XDA threads for many days, I chose to try the AOSP GSI (Generic System Image) treble ROMs from PHHusson. Each GSI included either pico or nano GApps, as well as SuperSU rooting. I ultimately selected AOSP 10 (Quack) as my daily driver, after trying AOSP 8.1, AOSP 9, and AOSP 11. Here is my attempt at a comprehensive summary...

Blu Vivo XL4 Phone Specs:

MediaTek Helio P22 (12nm MT6762 chipset)

Arch 64, 8 cores, 4 x 2 GHz, 4 x 1.5 GHz)

PowerVR GE8320 GPU

ARM64, A-only, Treble Yes

3 GB RAM

32 GB ROM internal storage memory

6.2" screen, 720x1520 pixels, 271 ppi, 19:9 aspect ratio

Device not locked to a specific cellphone carrier

2 SIM slots, where 2nd slot accepts a micro SD card (mine is 512 GB)

Rear 13 Mp camera, and 2 Mp depth camera

Front 13 Mp camera (selfie), F2.0 aperture

Fingerprint Reader on rear side

Headphone jack (3.5 mm) and internal speaker, with DTS sound

Micro USB v2.0

4000 mAh non-removable Li-Po battery

WiFi 2.4 GHz / 5 GHz (a/b/g/n)

Bluetooth 4.1

4G LTE (1/2/3/4/5/7/8/12/13/17/28/66)

3G (850/900/1700/1900/2100)

GSM Quad band

Credits and Useful Research Links:

1) PHHusson -- outstanding software development of the AOSP GSI ROMs; I used AOSP 8.1 v.32 (p. 8), AOSP 9 v. 123 (p. 6), AOSP 10 v. 222 (p. 5), and AOSP 11 v.313 (p. 2) from his GitHub site of phhusson/treble_experimentations:

AOSP 10 v.222 on page 5

Releases · phhusson/treble_experimentations

Notes about tinkering with Android Project Treble. Contribute to phhusson/treble_experimentations development by creating an account on GitHub.

github.com

2) mrmazak -- very helpful guide to Blu Vivo XL4 custom ROM development work in 2018 and 2019, as well as the best TWRP recovery to use from the TWRP team, and a copy of the stock Blu ROM for emergency reinstalls if/when needed.

XDA guide: Initial Blu Vivo XL4 guide to development

https://xdaforums.com/t/guide-blu-vivo-xl4-vivo-xi-vivo-xi.3877294/

Necessary files: mrmazak helpful page of files

Downloads for : -Android- Generic Device/Other | AndroidFileHost.com | Download GApps, Roms, Kernels, Themes, Firmware and more. Free file hosting for all Android developers.

Download GApps, Roms, Kernels, Themes, Firmware, and more. Free file hosting for all Android developers.

androidfilehost.com

a) Best TWRP -- TWRP-3.2.3-1020-OMFG-mod_b6-device-name-vivo-wipe-misc.img

b) Blu Stock ROM -- BLU_V0350WW_V8.1.04.01_GENERIC_T0701.zip

3) TWRP team -- for the outstanding work creating the custom TWRP recovery above

4) Zackptg5 -- for the necessary DM-Verity disable script. I chose to keep forced encryption (established when rebooting to System after final ROM and zip flashing work).

XDA Guide: Development of the DM-Verity disable script

[Deprecated] Universal DM-Verity, ForceEncrypt, Disk Quota Disabler [11/2/2020]

Hi all! For the past couple of months, I've been looking into making a more universal solution to disable dm-verity and forceencrypt. Needing to take different zips, modify them for different devices, and then cross your fingers when you switch...

xdaforums.com

Page with file link: DM-Verity disable script from 11/2/2020

Zackptg5 - Android

zackptg5.com

Rename the script, by adding "en" in front of "ForceEncrypt" in the filename; if you delete "ForceEncrypt" from the filename, the script still defaults to disable forced encryption; also, this script has to be on "/external_SD" or the Internal Drive; if you try to ADB sideload it, a temp file copy is created on the Internal Drive with a different name; "enForceEncrypt" needs to be in the filename to tell the script to keep encryption during the System Reboot after flashing the ROM and zips...

5) jonaaa -- for a thread posting which helps in flashing back to stock ROM or any other time a hardware device driver in "/vendor" partition is messed up (like my camera, after a mistake early on...)

XDA thread post #196: Sequence of flashing and reboot to recovery

https://xdaforums.com/t/share-recovery-official-twrp-3-2-3-for-redmi-6a.3866971/page-10

The key extra steps are to Install images for Stock Vendor and Boot and reboot to recovery before Install of the Stock System image and reboot to recovery, followed by the Install of the DM-Verity Disable script zipfile -> then Reboot System

AOSP ROM install comparisons (before adding at least 2 GB of my apps):

ROM | GAPPs | Encrypt | RAM | Storage Memory | Not Working

Blu Stock 8.1 | Full | Yes | 1.7 GB | 11.4 GB | N/A

PHH AOSP 8.1 | Pico | Yes | 1.5 GB | 8.6 GB | FM radio, Bluetooth

PHH AOSP 9 | Pico | Yes | 1.4 GB | 7.7 GB | FM radio

PHH AOSP 10 | Nano | Yes | 1.7 GB | 8.3 GB | FM radio

PHH AOSP 11 | Nano | Yes -> Unstable, loops on wallpaper select and on lock screen

Notes for above table:

(1) Storage memory quoted for Android setup is also after uninstalling extra games and apps from the Amazon Galactic Empire, as well as disabling or uninstalling Opera, YouTube, and Chrome (when part of the ROM -- not Pico GApps)

(2) The PHH AOSP 9, 10, and 11 ROMs have user selectable MediaTek workarounds to enable Bluetooth, initially unselected; Go To:

Settings -> Phh Treble Settings -> Misc features -> Bluetooth workarounds -> Mediatek

(3) The PHH AOSP 10 ROM didn't include an Email app and the old Android stock music app didn't work -> I installed replacement apps from F-Droid. Also, Nano GApps package was included in this OS kernel, and with additional automatic Play Store installs of Chrome, Message, and Phone. I uninstalled Chrome.

(4) I assume that PHH AOSP 11 ROM also includes Nano GApps package in the OS kernel install, like AOSP 10, but the instability issues happened late in Android Setup or immediately after (if I didn't set any wallpaper during Setup). So, I didn't get a chance to fully explore the GApps installed, but the look of the home screen appeared to be the same as it was for AOSP 10...

(5) The PHH AOSP 9 ROM was the most memory efficient and had the fastest bootup times. It also has the Bluetooth fix, making it better than the PHH AOSP 8.1 ROM

(6) The PHH AOSP 10 ROM has the Android 10 security improvements, like App scoping. It does have the longest bootup time. I read somewhere on the internet that a GTest of AOSP 7.1, 8.1, 9, and 10 showed AOSP 10 to have the fastest times on GPU intensive tasks and only slightly slower on CPU intensive tasks. It was overall the fastest of those 4, due to the quicker handling of graphics...

(7) I abandoned PHH AOSP 11 ROM after several tries. There must be some kind of hardware incompatibility, I'm guessing, with my Blu Vivo XL4

(8) All GSI ROMs used here are for ARM 64, and A-only. I used Treble Check app from Play Store to verify my phone's Treble compatibility and hardware characteristics, to select the proper GSI ROMs ("-arm64-aonly-gapps.img.xz"). The version of TWRP I used is very capable, with extra Advanced features, but it couldn't uncompress ".xz" image files. To uncompress, use 7-zip (free online) or WinZip 27 (35 US$ online). For the fastest and lowest risk option to flash the system GSI ROM, in TWRP -> Install -> Image File (from micro SD card mounted to "/external_sd"). Before reaching this point in the project, I used my Windows 10 PC with SD card reader slot and an SD adapter to install my micro SD card and quickly and reliably copy very large system image ROM files (1.56 - 2.38 GB each).

Initial Hacking (prior to GSI ROM flashing):

My music, pictures, and documents were on my external Micro SD card. There was nothing on the Internal drive I needed to backup, since I chose Clean Installs each time I flashed a new GSI ROM or went back to Stock ROM (a few times). So, unlike mrmazak, I chose not to use the complicated SPFlash Tool for a complete backup of my Stock ROM. I did create a backup in TWRP (during 1st time in TWRP) of every partition of Stock ROM except the user "Data" partition.

I enabled "USB Debugging" on my phone at the beginning. I installed "Universal ADB Driver.msi" on my Windows 10 PC, to have ADB and FastBoot command functions (from a command shell) when connecting my phone to my PC using the USB cable.

Once I had my phone in fastboot, I unlocked the bootloader ("fastboot oem unlock"). This performed a Factory Reset, wiping the "Data" partition files while unlocking the bootloader. I then installed TWRP in fastboot ("fastboot flash recovery twrp.img"), after creating a short filename copy of the long filename TWRP image above in the OP.

I then rebooted into TWRP for the first time ("fastboot oem reboot-recovery"). All subsequent flashing operations of Image files and the DM-Verity Disable Zip file were done from my micro SD card and not via ADB over USB (slow and possibly risky for big system image files).

Phone bootup details (after abandoning Stock ROM for the 1st time):

Once you unlock the phone's bootloader in fastboot above, you will always start every reboot with a brief 5 second Orange State message that says your device is unlocked and cannot be trusted. Ignore this message...

After you flash your 1st system ROM, you will always have a 2nd message screen on every reboot that gives a DM-Verity Error. It says your device is corrupted -- press Volume UP to boot to E10 mode or press Volume Down to Restart. It gives you 30 seconds to decide, before it Restarts. What you should remember here is that E10 will boot to either Fastboot or Recovery, depending on what reboot command you gave last (if using ADB or TWRP). The Restart option always chooses System Restart, to bootup Android OS.

If you ever get into a bind, without quick access to a USB-to-PC connection to give you the option of using ADB and Fastboot commands, you can press Power Button and Volume Up at the same time for 25 seconds or more. It will reboot to a little menu, where you can select to boot to either Recovery, Fastboot, or Normal (system). In this little menu, Volume UP scrolls down the list of 3 selections, while Volume Down selects the option you want...

DM-Verity is a Drive Mapper Verification during system bootup that cryptographically checks to see if any partitions have been changed. It will not allow you to bootup a custom system ROM, unless you use the DM-Verity Disable script Zip file above in this OP. Even if you restore your Stock ROM, it will detect a DM-Verity error somewhere and not let you bootup the system, unless you Disable DM-Verity...

Wait times during bootup:

1) Anytime your user "Data" partition is encrypted (as it is for Stock ROM or any custom ROM with GApps installed), you will have a 1 minute wait time to bootup Recovery into TWRP. An attempt to decrypt files on "Data" partition fails, followed by a request for unlock password (in Chinese for this version of TWRP). Click the "language" button and select English. Then click "Cancel" on the password. This will take you to the TWRP Main menu.

2) Sometimes, when you want to bootup to Recovery with TWRP, you will cycle twice through the DM-Verity Error message step (select E10 mode both times with Volume UP). If I remember correctly, this happens after flashing recovery with TWRP, after flashing a new system ROM, and anytime the "Data" partition is encrypted.

3) When choosing System Reboot after flashing a custom ROM and DM-Verity Disable zip, the "Android" sign before starting Android Setup takes 2 or 3 minutes of waiting...

4) When choosing System Reboot after reflashing Stock ROM and DM-Verity Disable zip, the Blu startup animation completes and holds at the end picture, while you wait up to 4 minutes to reach Android Setup.

5) For normal System bootup (after successfully completing Android Setup), it only takes less than a minute to bootup the OS.

Details specific to the TWRP recovery used in my installs:

1) The Mount menu has several additional, usually hidden, partitions you can mount, if you want to. This is for advanced users. You don't want to damage your "/nvdata" partition, since it has 1 or more files with your phone's IMEI information. Normally, you only need to mount System, Cache, as well as Dalvik and Data (if these 2 are not currently encrypted and hidden in the Mount menu). Sometimes, you need to mount Vendor (hardware device drivers), if the camera stops working and you need to reflash the Stock Vendor Image to make sure no device drivers are corrupted. When creating a TWRP Backup of my Stock ROM (during 1st time in TWRP), I mounted all partitions available in the list, above and including my external Micro SD card. When restoring from a TWRP backup of your Stock ROM, you can select all partitions to mount and then later in the Restore menu, you can select 1 or more mounted partitions to restore...

2) When flashing (Install) the DM-Verity Disable zip script, it will give an "/nvdata" partition mounting error. You can ignore this. There is an "fstab.mt6765" file where the DM-Verity command has been successfully removed by the script zip file. It's a minor partition mounting or unmounting glitch that triggers the error message in TWRP.

3) After rebooting to TWRP recovery, and selecting Mount -> Select Storage, the "/external_sd" partition for the Micro SD card sometimes shows 0 MB. Don't worry. In the Mount menu, mount that external Micro SD card, and it will next correctly show the free memory available when choosing Select Storage submenu...

4) After flashing (Install -> Image) a custom or GSI system ROM, do not select "Reboot System". You need to push the bottom middle button to return to the Main Menu. Then select "Reboot -> Recovery". Why? Because you still need to flash (Install -> Zip) the DM-Verity Disable script zip file, before "Reboot -> System"...

5) After flashing TWRP for the 1st time or after reflashing the Stock ROM, your next "Reboot -> System" will overwrite TWRP recovery with Stock recovery. To keep this from happening, while in TWRP and with System partition mounted, use TWRP "File Manager" (Advanced menu) to navigate to "/system/bin". Then rename "install-recovery.sh" to a different filename (I chose "install-recovery-stock.sh"). This only applies when you currently have a Stock ROM (initial or flashed) after rebooting to TWRP Recovery...

TWRP Flashing Install Sequence for GSI ROMs:

1) Main Menu -> Mount (System, Cache, Micro SD partitions; Data is encrypted and hidden initially) -> Select Storage (Micro SD card)

2) Main Menu -> Wipe -> Format Data (at bottom right) -> Type "yes" and Swipe Right (user "/data" partition is no longer encrypted or hidden, and is empty)

3) Main Menu -> Reboot -> Recovery

4) Mount (Dalvik, System, Cache, Data, Micro SD partitions; optional and rare for Vendor partition, if reflashing Stock Vendor Image to correct camera device drivers) -> Select Storage (Micro SD card)

5) Main Menu -> Wipe (Dalvik, System, Cache, Data; optional for Vendor)

6) Main Menu -> Reboot -> Recovery

7a -

optional

) Main Menu -> Install -> Image -> Stock Vendor Image file (on Micro SD card); then: Main Menu -> Reboot -> Recovery

7b) Main Menu -> Install -> Image -> GSI System Image file (on Micro SD card, which is a big file and takes time...)

8) Main Menu -> Reboot -> Recovery

9) Main Menu -> Install (Zip, the default) -> Disable_Dm-Verity_enForceEncrypt_11.02.2020.zip (on Micro SD card)

10) Main Menu -> Reboot -> System

During System reboot, at the DM-Verity Error startup screen, press Volume Down for Normal Restart; earlier reboots to TWRP recovery required pressing Volume UP to select E10 mode instead (as discussed earlier in this OP)...

Screenshots of my Blu Vivo XL4 (daily driver) with new PHH AOSP 10 GSI ROM install:

See the 3 attachments below (includes my additional app installs after Android Setup, but before I disabled Google Search)... I'm enjoying my new upgraded and rooted Blu Vivo XL4 phone, with PHH AOSP 10 GSI ROM...