Links on Techsbyte may earn us a commission. Learn more.

How To Port TWRP To A/B Partitioned Devices (MediaTek)

Are you looking for TWRP porting guide to port TWRP to your A/B partitioned Android device? Then, this post is for you. In this comprehensive guide, I’ll show you how to port TWRP to A/B devices that do not have a recovery partition.

In a previous guide, I shared the steps to port TWRP recovery to MediaTek Android devices but we only covered A-only and A/B partitioned devices with a recovery partition. Users with A/B devices that do not have a recovery partition could not take advantage of the guide to port a custom recovery for their devices due to not having a recovery image file to work with. In this guide, however, I’ll show you how to port TWRP without a recovery image file.

Before we dive into the TWRP porting guide for A/B partitioned devices without a recovery partition, let’s answer the question, what is an A/B partitioned?

What Is an A/B Partition Partitioned Device?

A/B devices are devices with two sets of partitions referred to as slots (slots A and Slot B). The Android system runs from the active slot (say slot A for instance is the active slot) while the second slot (Slot B) remains inactive and not accessed by the running system during normal operation. This allows Android users to perform OTA updates without having to worry about running into a system crash or the OS update bricking their device.

When an OTA update is downloaded, the Android system installs the new update on the inactive slot. The inactive slot also contains a copy of the current OS installed on the active slot, so when the update has been installed, the Android system swaps to the inactive slot to boot the latest firmware/OS. This makes slot A become the inactive slot and B the active slot.

Let’s assume the Android systems fail to boot the new update in slot B, normally you’d expect that your device run into a boot loop or worst-case scenario, fails to boot as is common with single partitioned devices. For dual-partitioned devices, however, the Android system will roll back to the active slot that does not have a booting problem so that you can continue to use your device.

I’ll assume you already understand A/B partitions and skips some details to keep this guide as short as possible. To learn more about the Android partition selection click here.

TWRP Porting Guide For A/B Partitioned Device

For this tutorial, we’ll be making use of a popular Android image unpack and repack tool called Carliv Image Kitchen (CIK) to port TWRP custom recovery. Similar to the Android Image Kitchen tool, you can easily unpack and repack your device boot and the recovery image (boot.img and recovery.img) with this tool.

You can get your device stock boot.img and recovery.img file from your device’s official firmware. You can extract your stock firmware from your device using the smartphone flash tool or simply search for your device’s stock ROM online, download it and copy the files from it.

Also, knowing the type of CPU and chipset your device uses, whether it’s a 32bit or 64bit CPU increases your chances of booting your port TWRP. This will help you to identify the base (port TWRP) recovery that you need to download to port for your device. If you don’t know your device’s CPU information, then, download and install the Device info: System & CPU Info app from the Google play store to get it.

Once the app is installed, open it and navigate to the CPU tab, there you will find your device CPU information including the type of CPU your device uses. You can also use the app to get other information like a display, camera, sensor, battery, memory, network, and more about your device.

TWRP Porting Prerequisites:

  • Carliv Image Kitchen | Download Here
  • TWRP Port recovery image file | Download Here
  • Stock recovery image file (32bit/64bit) | Get it from your device firmware

You can also check if your device has the official TWRP recovery support or that of its variants from the links below. If you can’t find your device on the list, jump to the step-by-step guide below to port TWRP recovery for your device.

Steps To Port TWRP For MediaTek Android Devices

  1. After you must have downloaded the carliv image kitchen tool, port recovery, and firmware file, they would be in compressed format (archive). You need to extract the contents of each other the file you downloaded.
  2. Open the CIK folder after extracting and you find the tool components. By default, the folder will contain two sub-folders (bin and script) with a carliv.bat executable script.How To Port TWRP To A/B Partitioned Devices (MediaTek)
  3. Double-click on the carliv.bat file to run the CIK script. An interactive command window will pop up and a new folder named “input” will be created in the CIK folder.How To Port TWRP To A/B Partitioned Devices (MediaTek)
  4. Copy the port TWRP and your stock boot.img file into the input folder.
  5. Now, open the CIK command prompt window, type I, and hit enter to list the image files in the command window.How To Port TWRP To A/B Partitioned Devices (MediaTek)
  6. We need to unpack the port TWRP and stock boot image file. Select an image file using the number assigned to it. In my case, I have boot.img as 1 and twrp.img as 2. It doesn’t matter which one you choose first. So, I’m going to type 1 and hit enter.How To Port TWRP To A/B Partitioned Devices (MediaTek)
  7. On the next screen, you can now extract the image file following the on-screen instruction. To extract the selected image, type 1 and wait for the unpacking process to complete. How To Port TWRP To A/B Partitioned Devices (MediaTek)
  8. After unpacking the first image file, type I again to return to the image list screen and select the second image, and unpack it.
  9. Once you’re done unpacking the boot.img and twrp.img, minimize the command window, and return to the CIK folder. You should now have two additional subfolders named after the image files you unpacked (boot and twrp folder).
  10. Open both folders (boot and twrp) side by side, in the twrp folder, delete all the files in it excluding the ramdisk folder. In the boot folder, copy all the files excluding the ramdisk folder and paste in the twrp folder.
  11. In the boot folder, open the ramdisk folder, scroll to the bottom and copy prop.default file and replace it with the one in the twrp ramdisk folder.
  12. Next, open the system folder in the boot folder, open the etc folder and copy ueventd.rc file and replace with the one in the twrp system → etc folder.
  13. Once, you’re done, you can close all folders. Open the CIK command Window again, go to the imaage list and select the twrp image.
  14. Type 2 to repack the twrp image file (folder) and wait for the process to finish.How To Port TWRP To A/B Partitioned Devices (MediaTek)
  15. In the CIK folder, you should now have an output folder containing the newly ported twrp image fileHow To Port TWRP To A/B Partitioned Devices (MediaTek).
  16. Copy the ported TWRP and flash it on your device.

That’s it, you’ve successfully ported TWRP recovery for your Android device.

How To Flash TWRP On A/B Devices Using ADB & Fastboot

Note: Your device bootloader should already be unlocked before attempting to flash any file in fastboot mode. Your device will not run into any issues if it is not unlocked and you tried flashing in fastboot, the operation will not execute. You also need to disable dm_verity by flashing an empty vbmeta.img file so that you don’t run tin bootloops after flashing your device.

1. First off, install ADB and Fastboot drivers on your PC.

2. Enable developer options on your device, to do that go to about phone on your device and scroll to find your device build number, and once found tap on it continuously until you see you’re now a developer.

3. Now, go back to the settings app list and find the system option, tap on it and you’ll now see the developers option.

3. In the developer option, enable OEM unlocking and USB debugging.

4. Now download and install Minimal ADB and Fastboot tools on your PC.

5. Once, you’ve installed ADB and Fastboot tool on your PC, launch it and connect your device.

6. Now, enter the following commands below.

adb devices

You should get a prompt on your phone’s screen to grant access permission, and accept the permission.

7. Now, we’ll reboot the device bootloader using the below command.

adb reboot bootloader

8. Once your device reboots into the bootloader, you now have to unlock your bootloader using the command below.

fastboot oem unlock

If the above command fails, then try the second unlock command below.

fastboot flashing unlock

Step 9. Now, when the unlock process is done, reboot your device using the command.

fastboot reboot

Wait for your device to boot. On boot, you’ll notice an orange state warning on your screen that your device is now insecure blah blah blah. You don’t have to panic, your device is ok.

You’ve successfully unlocked your device bootloader. Now, you can proceed to install TWRP on your device.

Steps To Flash TWRP On Your Android Device Using ADB

  1. Copy the newly ported recovery.img (TWRP) and the empty vbmeta.img file you downloaded earlier into the ADB and Fastboot folder.
  2. Copy your stock boot.img file to your device’s internal storage.
  3. Now, right-click on an empty space in the ADB and Fastboot folder and select the open windows command prompt here from the context menu.
  4. Connect your device to the PC and enter the command adb reboot bootloader to reboot your device in bootloader mode.
  5. Flash the empty vbmeta.img file using the command fastboot flash --disable-verity --disable-verification vbmeta vbmeta.img to disable Dm_verity.
  6. In bootloader mode, enter the command fastboot flash boot twrp.img to flash the newly ported TWRP recovery.
  7. After flashing TWRP successfully, use fastboot boot twrp.img to boot into the recovery or fastboot reboot recovery.

You have now successfully installed TWRP on your A/B MediaTek Android device.

That’s it on how to port TWRP to A/B partitioned MediaTek Android devices. If you find the guide helpful, share the post with friends, and don’t forget to follow us on YouTube.

4 Comments
  1. Thanks immensely for your good work! The guide works for me perfectly. I came across this when it became imperative for me to install twrp recovery on my device to enable me flash a file to boot up gsi rom, but I couldn’t find any. But with this, I was able to port twrp recovery that works flawlessly on my device. Once again, than you.

  2. hi, i have a LG k61 without recovery partition, i was to try this metod but the links to download redirects always to the other guide (even in the same guide) and i can get the TWRP Port recovery image file. same with the CIK, but i managed to download from github.
    alto this part is confusing:
    “TWRP Porting Prerequisites:

    Carliv Image Kitchen | Download Here
    TWRP Port recovery image file | Download Here
    Stock recovery image file (32bit/64bit) | Get it from your device firmware”
    since this is a guide for devices with NO RECOVERY so no stock recovery to get, besides then you name the boot.img file.
    waiting for responses, ill follow you in yt.

Leave A Reply

Please enter your comment!
Please enter your name here

Popular