Android Upgrades, Custom ROMs (LineageOS), & Kernels

Android A/B Slots Deep Dive: Flashing Firmware & Custom ROMs with Advanced Fastboot

Google AdSense Native Placement - Horizontal Top-Post banner

Introduction: The Evolution of Android Updates with A/B Slots

The Android ecosystem is constantly evolving, and one of the most significant architectural changes in recent years is the implementation of A/B (seamless) system updates. Introduced with Android 7.0 Nougat, A/B partitioning revolutionized how devices receive updates, aiming for a smoother, safer, and less disruptive user experience. This deep dive will explore the intricacies of A/B slots, how they impact traditional flashing methods, and how to leverage advanced Fastboot commands to manage firmware and install custom ROMs like LineageOS on A/B-enabled devices.

Before A/B, updating an Android device meant booting into recovery mode, applying an update package, and then waiting for the device to optimize apps. This process was time-consuming and carried the risk of bricking the device if the update failed. A/B partitioning mitigates these risks by maintaining two complete sets of system partitions (Slot A and Slot B), allowing updates to be applied in the background to the inactive slot. When the update is complete, a simple reboot switches to the newly updated slot, providing a near-instantaneous upgrade experience.

Understanding A/B Partitioning

At its core, an A/B-partitioned device has redundant system-critical partitions. Instead of a single system partition, you have system_a and system_b. The same applies to other key partitions such as boot, vendor, dtbo, vbmeta, product, and system_ext. The device keeps track of which slot is currently active (booted from) and which is inactive.

How to Check for A/B Support

You can easily determine if your device uses A/B partitioning through a few methods:

  1. Using ADB Shell: With your device booted into Android and USB debugging enabled:
    adb shell getprop ro.boot.slot_suffix

    If it returns _a or _b, your device uses A/B slots. If it returns nothing or an error, it likely does not.

  2. Using Fastboot: While in Fastboot mode:
    fastboot getvar all

    Look for variables like current-slot or partitions explicitly named with `_a` and `_b` suffixes.

Setting Up Your Environment for Advanced Flashing

To begin, ensure you have the necessary tools and your device is prepared:

  1. Platform-Tools: Download and install the latest ADB and Fastboot platform-tools from the official Android Developers website. Add the directory to your system’s PATH for easy access.
  2. USB Debugging & OEM Unlocking: On your device, enable Developer Options (Settings > About phone > Tap Build number 7 times). Then, within Developer Options, enable ‘USB debugging’ and ‘OEM unlocking’.
  3. Unlock Bootloader: This step is crucial for flashing custom firmware. Be aware that unlocking the bootloader will factory reset your device and void your warranty. In Fastboot mode, use:
    fastboot flashing unlock

    Follow the on-screen prompts on your device.

Advanced Fastboot Commands for A/B Devices

With A/B devices, Fastboot gains additional capabilities and nuances you must understand:

  • fastboot devices: Verifies your device is connected and recognized in Fastboot mode.
  • fastboot getvar current-slot: Displays the currently active slot (e.g., current-slot:a).
  • fastboot set_active [slot]: Explicitly sets the active slot. For example, fastboot set_active b will make slot B active for the next boot. This is critical for recovery from failed updates or switching between different system installations.
  • fastboot flash [partition] [file.img]: This standard command will flash the image to the currently active slot’s version of that partition. For instance, if slot A is active, fastboot flash boot boot.img flashes to boot_a.
  • fastboot flash [partition]_[slot] [file.img]: Allows you to target a specific slot, regardless of which one is active. Example: fastboot flash boot_b boot.img. This is less commonly used for full system components, but useful for targeted modifications.
  • fastboot update [rom.zip]: This command is often used with factory images (or custom ROMs packaged specifically for it). It intelligently handles A/B updates, writing to the inactive slot, and setting it active.
  • fastboot reboot bootloader: Reboots the device back into Fastboot mode.

Flashing Factory Firmware Images on A/B Devices

Restoring a device to factory settings or updating manually often involves flashing official factory images. These images typically contain a flash-all.sh (or `.bat`) script, which automates the process. Let’s look at the manual steps and what the script usually does:

  1. Download & Extract: Obtain the factory image for your specific device model and region (e.g., from Google Developers for Pixel devices). Extract the `.zip` file. You’ll find images like boot.img, dtbo.img, vbmeta.img, and often a `payload.bin` within an inner ZIP (e.g., `image–.zip`).
  2. Extract Payload.bin (if present): For modern A/B devices, the system, vendor, and product partitions are often stored within a `payload.bin` file (part of the `super` partition). You might need a tool like `payload-dumper-go` to extract individual `.img` files from `payload.bin` if you intend to flash them manually.
  3. Manual Flashing Sequence (Example):
    fastboot flash boot boot.img             # Flashes to current active slot's boot partitionfastboot flash dtbo dtbo.img             # Flashes to current active slot's dtbo partitionfastboot flash vbmeta vbmeta.img         # Flashes to current active slot's vbmeta partitionfastboot reboot fastboot               # Reboots into fastboot to ensure partitions are recognized# For system, vendor, product (dynamic partitions within 'super'):# If you extracted individual images from payload.bin:# fastboot flash system system.img       # Flashes system to current active slot# fastboot flash vendor vendor.img       # Flashes vendor to current active slot# ... and so on for other dynamic partitions.

    Alternatively, and more commonly for factory images:

    fastboot update image--.zip

    This command is smart enough to extract the necessary images from `payload.bin`, partition the `super` partition correctly, and flash everything to the inactive slot, then mark it active.

  4. Clear Userdata (Optional but Recommended): After flashing, it’s often wise to wipe user data:
    fastboot -w
  5. Reboot:
    fastboot reboot

Installing Custom ROMs (e.g., LineageOS) on A/B Devices

Flashing a custom ROM on an A/B device requires careful attention to the ROM’s specific instructions, as processes can vary. However, a common pattern involves these steps:

  1. Download ROM & GApps (if needed): Obtain the custom ROM `.zip` file (e.g., from LineageOS website) and a compatible GApps package if the ROM doesn’t include them.
  2. Ensure Correct Firmware: Many custom ROMs require a specific version of your device’s stock firmware (e.g., vendor, bootloader). Check the ROM’s installation guide for this critical detail. Flash any required firmware first using the methods described above.
  3. Boot into Custom Recovery: Flash a custom recovery (like TWRP for A/B or Lineage Recovery) to your device’s boot partition (or recovery partition if separate) in Fastboot mode.
    fastboot flash boot recovery.img

    Then, reboot into this recovery.

  4. Wipe Data: From recovery, perform a factory reset to wipe `data` and `cache`.
  5. Sideload the ROM: With the device in recovery mode, select ‘Apply update’ or ‘Apply from ADB’, then on your computer:
    adb sideload lineage-*-signed.zip

    The recovery will handle flashing the ROM to the inactive slot and setting it as active.

  6. Flash GApps & Magisk (Optional): If you need Google Apps or root access, sideload those packages *immediately after the ROM, before rebooting*, if your recovery supports it. For Magisk, you’d typically flash the custom ROM, boot it up, install the Magisk app, patch the `boot.img` via the app, and then flash the patched `boot.img` via Fastboot:
    fastboot flash boot magisk_patched.img
  7. Reboot System: After all installations are complete, reboot your device.

Troubleshooting Common A/B Flashing Issues

  • Incorrect Active Slot/Bootloop: If your device boots into an old system or enters a bootloop after flashing, you might be booting from the wrong slot. Boot back into Fastboot, check `fastboot getvar current-slot`, and try switching:
    fastboot set_active a # or bfastboot reboot
  • `fastboot: error: The partition is not a flashable partition`: This can occur if you’re trying to flash to a logical partition within `super` without `fastboot update` or if the partition name is incorrect. Ensure you’re using the correct partition names for your device and flashing method.
  • `Invalid sparse file format` / Corrupted `super` partition: This usually means a problem with how `super` was written or read. The most reliable fix is often to re-flash the entire factory image using the `fastboot update` command.
  • Vendor Incompatibility: Custom ROMs often depend on specific vendor firmware. Always ensure your device’s vendor partition matches the ROM’s requirements; flashing an outdated or incompatible vendor can lead to various issues.

Conclusion

Android A/B slots represent a significant leap forward in device update reliability and user experience. While they introduce a new layer of complexity to manual flashing, understanding the underlying mechanics and mastering advanced Fastboot commands empowers you to confidently manage your device’s firmware, recover from issues, and experiment with custom ROMs. Always proceed with caution, back up your data, and consult device-specific guides to ensure a smooth flashing journey.

Android Mobile Specs & Compare Directory

Are you researching mobile hardware properties, processor SoCs, GPU chipsets, or RAM configurations? Access our complete specs catalog to compare up to 5 devices side-by-side!

Compare Devices Specs →
Google AdSense Inline Placement - Content Footer banner