How To Guide [GUIDE] Pixel 5a "barbet": Unlock Bootloader, Update, Root, Pass SafetyNet

Search This thread

V0latyle

Forum Moderator
Staff member
Just in case sharing a tip for a situation I have encountered multiple times while building and testing TWRP boot.img,
This will happen if you try to boot any broken(corrupted) unbootable boot.img.
Fastboot sends the image to device and bootloader reports with unsupported. You reboot and phone goes straight to recovery with 2 options - try again or wipe data. You can't boot to Android keeping data any more despite the fact that you didn't flash anything and boot_a/b partitions are still good. In that case the only way out is to do "fastboot boot <known good boot.img>" and then do normal reboot with no lost of data.
Hope this never happens, but now you know if it does...
TWRP hasn't been updated to work with Android 12 yet. Nor has this been a concern in tis context. Please don't post solutions to problems that are not relevant here, as they can be confusing to some users.

But yes, in all circumstances, if there is a problem with the patched boot image, the user can always reflash the factory boot image.
 

nijel8

Senior Member
Dec 24, 2011
2,423
5,646
All over US
Google Pixel 5a
TWRP hasn't been updated to work with Android 12 yet. Nor has this been a concern in tis context. Please don't post solutions to problems that are not relevant here, as they can be confusing to some users.

But yes, in all circumstances, if there is a problem with the patched boot image, the user can always reflash the factory boot image.
TWRP works just fine with Android 12 and what I posted can happen to everyone patching the boot.img... You should know better files get corrupted all the time...
And I am not even tallking about flashing... Just booting bad boot.img puts the phone in wipe-data state.
 
Last edited:

V0latyle

Forum Moderator
Staff member
TWRP works just fine with Android 12 and what I posted can happen to everyone patching the boot.img... You should know better files get corrupted all the time...
And I am not even tallking about flashing... Just booting bad boot.img puts the phone in wipe-data state.
Not always, the bootloader will generally reject the boot image altogether, due to dm-verity.

TWRP does not work with Android 12 on the 765G platforms. It won't decrypt data, and in my case on the Pixel 5, gets stuck at the TWRP loading screen.
 
So I am trying to install the latest update using the OTA option (already on Android 12 using the same process), but the system update screen keeps tells me that it can't install the update (message says "Installation problem"). I'm currently plugged up and the battery is over 50% charged. Anyone encounter this before?
 

V0latyle

Forum Moderator
Staff member
So I am trying to install the latest update using the OTA option (already on Android 12 using the same process), but the system update screen keeps tells me that it can't install the update (message says "Installation problem"). I'm currently plugged up and the battery is over 50% charged. Anyone encounter this before?
Yes, sometimes this occurs on rooted devices. Keep trying, or use a different method.
 

Jeroen1000

Senior Member
Jul 26, 2012
123
21
@V0latyle Maybe I am doing it wrong on my 5a but I end up on the same SW-version as before my upgrade. I may assume wrongly here your instructions can also be applied to the Pixel 5a. Can you please offer your insights?:)

Device is on 12.0.0 (SQ1A.211205.008, Dec 2021) and going to 12.0.0 (SQ1A.220105.002, Jan 2022)
2022-01-13_18-34-00.jpg

@Oswald Boelcke Apologies for posting in the wrong forum. I had (obviously) not checked there was a similar topic here. It does appear @V0latyle answer got lost: I got an e-mail that he replied but the reply cannot be found
 
Last edited:

V0latyle

Forum Moderator
Staff member
@V0latyle Maybe I am doing it wrong on my 5a but I end up on the same SW-version as before my upgrade. I may assume wrongly here your instructions can also be applied to the Pixel 5a. Can you please offer your insights?:)

Device is on 12.0.0 (SQ1A.211205.008, Dec 2021) and going to 12.0.0 (SQ1A.220105.002, Jan 2022)
View attachment 5507707
I replied then remembered we were in the wrong forum so I deleted my reply.

Nothing actually appears wrong with your commands.

Is your master root image from a previous release? If so, make sure you're using Direct Install in Magisk to patch the new boot image, then reboot.
 

Jeroen1000

Senior Member
Jul 26, 2012
123
21
I replied then remembered we were in the wrong forum so I deleted my reply.

Nothing actually appears wrong with your commands.

Is your master root image from a previous release? If so, make sure you're using Direct Install in Magisk to patch the new boot image, then reboot.
I'll try not to make it a habit posting in the wrong place.

So I got my phone and updated it to the 12.0.0 (SQ1A.211205.008, Dec 2021) SW. At this point it was _not_ rooted. Then I downloaded the factory image for SQ1A.211205.008. I patched boot.img and flashed that. tl;dr Bascially what your tutorial explains in the initial root section.

The only thing different I do is instead of rebooting to recovery, I did
Code:
adb.exe reboot sideload

So when I boot the master boot image using
Code:
fastboot boot <drag and drop master root.img here>
I did select direct instal in magisk. Nothing odds happens*. I am not sure I understand Magisk is patching the correct boot.img though. I even booted to the inactive slot to check the upgrade ended up there. But it didnt.


* believe my phone did reboot twice. That might be unexpected behaviour?
 

V0latyle

Forum Moderator
Staff member
I'll try not to make it a habit posting in the wrong place.

So I got my phone and updated it to the 12.0.0 (SQ1A.211205.008, Dec 2021. At this point it was _not_ rooted. Then I downloaded the factory image for SQ1A.211205.008. I patched boot.img and flashed that. tl;dr Bascially what your tutorial explains in the initial root section.

The only thing different I do is instead of rebooting to recovery, I did
Code:
adb.exe reboot sideload

So when I boot the master boot image using
Code:
fastboot boot <drag and drop master root.img here>
I did select direct install. Nothing odds happens. I am not sure I understand Magisk is patching the correct boot.img though. I even booted to the inactive slot to check the upgrade ended up there. But it didnt.
What happens when you boot to the inactive slot? Check the build number. I believe Magisk may be trying to patch the inactive slot. So, if one slot is "old" and the other slot is "new", just boot the "old" slot, which probably still has a patched boot image, and select Direct Install in Magisk.

Personally I just use the factory image method as it flashes both slots.
 

Jeroen1000

Senior Member
Jul 26, 2012
123
21
@V0latyle I booted to the inactive slot (see below) and it was on the very same version 12.0.0 (SQ1A.211205.008, Dec 2021). The full factory image comes with a Google warning I decided not to ignore "Note that it's typically easier and safer to sideload the full OTA image instead."

2022-01-13_18-34-00.jpg
 

V0latyle

Forum Moderator
Staff member
@V0latyle I booted to the inactive slot (see below) and it was on the very same version 12.0.0 (SQ1A.211205.008, Dec 2021). The full factory image comes with a Google warning I decided not to ignore "Note that it's typically easier and safer to sideload the full OTA image instead."

View attachment 5507739
I'm confused, are you trying to update to January?

Is either slot rooted?

The reason why OTA updates are generally "safer" is because they install to the inactive slot; if booting the inactive slot fails for whatever reason, the system will revert to the original slot.

More details here

Basically this is how it works:
  • Pixel devices have A/B slots
  • While system is running on slot A, it can download and install OTA update to Slot B, then command a reboot
  • If boot is successful, Slot B is set as active; the next OTA will be installed to Slot A
  • If boot is not successful, system reboots to Slot A (the non-updated slot) and the update can be attempted again.
The idea here is that the device has a degree of "self recovery" wherein it will revert to a usable state if the update fails for whatever reason. This works regardless of whether the bootloader is unlocked.

Flashing the factory image only works on an unlocked bootloader for two reasons:
  • Partitions are flashed directly from PC
  • Partition images cannot be verified for integrity and authenticity
ADB sideload basically works the same way as the seamless system update, just from recovery. The OTA image is checked against a known hash before it is flashed.

All that being said, it's pretty much moot for those of us with unlocked bootloaders, to a degree - if something goes wrong, it's most likely your own fault, and you have to fix it yourself - the device won't be able to fix it for you. For instance, if something goes wrong with the factory flash for whatever reason, you'll have to figure out why and ensure a subsequent flash is successful. Or, if you accidentally wipe data during the update, you're screwed - there is no way to recover user data once wiped. The OTA on the other hand never touches user data. The factory update in of itself doesn't either - the update process might, specifically the script included, as it incorporates the -w option by default to wipe data. So, if User Johnny Knucklehead skims over a few guides that aren't specific to his device, and decides to update by downloading the factory image and running the script without editing or learning the commands...then he'll have to start from scratch when things go wrong.
 

Jeroen1000

Senior Member
Jul 26, 2012
123
21
@V0latyle slot A is currently rooted. Hence, the phone is booting off slot A. Not sure about slot B. And yes, I am updating to January. A/B seems to work the same as it does on my OP7T judging from your excellent recap.

Anyway, I noticed some "suspicous" behaviour.

1. after the sideload procedure completes, I boot to bootloader and boot the master boot image.
2. The phone starts booting (displays the G with the progress bar animation below) and then...it reboots again as I get to see the warning screen (again) about having an unlocked boot loader.

Believe this would fall into the "If boot is not successful, system reboots to Slot A (the non-updated slot) and the update can be attempted again." catergory. So I am now assuming my Full OTA updates fail. As to why, I do not know.
 

V0latyle

Forum Moderator
Staff member
@V0latyle slot A is currently rooted. Hence, the phone is booting off slot A. Not sure about slot B. And yes, I am updating to January. A/B seems to work the same as it does on my OP7T judging from your excellent recap.
It's pretty much an Android standard now, almost all contemporary devices do it.
Anyway, I noticed some "suspicous" behaviour.

1. after the sideload procedure completes, I boot to bootloader and boot the master boot image.
2. The phone starts booting (displays the G with the progress bar animation below) and then...it reboots again as I get to see the warning screen (again) about having an unlocked boot loader.
I think what's going on here is you're immediately trying to boot the patched image instead of letting the update boot by itself. This is why:
Believe this would fall into the "If boot is not successful, system reboots to Slot A (the non-updated slot) and the update can be attempted again." catergory. So I am now assuming my Full OTA updates fail. As to why, I do not know.
You actually just said why without realizing it.

After the OTA is installed and the device attempts to boot the updated slot, the system checks to make sure everything was updated correctly. What's happening here is you're interrupting that process, and forcing the older boot image to boot, so when the system attempts boot, it sees a mismatch between the January system update and the older patched boot image. It then decides the update was not successful, marks that slot as "unsuccessful boot", and reboots to Slot A.

So, here's what you have to do:
  1. Sideload the OTA
  2. Reboot to system, do NOT interrupt the process, allow system to boot without root
  3. Allow update to complete (watch notifications, it'll say something about completing update)
  4. When update is complete, reboot to bootloader
  5. Boot patched image
  6. Direct Install in Magisk.
Let me know how that works out; if that's the ticket, I need to update my OTA instructions.

Failing that, I would say just download the January factory image and update that way, and manually patch the January boot image in Magisk.
 
Last edited:
  • Like
Reactions: Jeroen1000

Jeroen1000

Senior Member
Jul 26, 2012
123
21
@V0latyle Yes that did the trick indeed. Thank you! Guess there is no way escaping a full boot to let the update finish.
Did this behaviour change in Android 12 perhaps (maybe you wrote the insturctions for Android 11)?
 
  • Like
Reactions: V0latyle

V0latyle

Forum Moderator
Staff member
@V0latyle Yes that did the trick indeed. Thank you! Guess there is no way escaping a full boot to let the update finish.
Did this behaviour change in Android 12 perhaps (maybe you wrote the insturctions for Android 11)?
Nope, it's always been true of seamless system updates since at least Android 9. It must have slipped my mind when I was writing the guide. I'll update it soon.
 
  • Like
Reactions: kingofnice

V0latyle

Forum Moderator
Staff member

V0latyle

Forum Moderator
Staff member

CarinaPDX

Senior Member
Jun 30, 2013
277
92
Google Pixel 5a
Nothing else should be required. I personally don't update via OTA; I use the factory image. It's normal for the OTA to fail on a rooted device, although sometimes retrying it will succeed.

Uninstalling Magisk should not be necessary. I just updated my 5 and wife's 5a without changing anything - just updated using factory image, flashed patched boot image, and done.

For those who are wondering, this is how I updated my wife's 5a (and my Pixel 5):
  1. Download and extract the factory image
  2. Extract boot.img from the factory update image
  3. Copied boot.img to device, patched in Magisk, copied patched boot image back to update folder
  4. Reboot device to bootloader
  5. Apply update:
    Code:
    fastboot update device-image-buildnumber.zip
  6. Let device boot and finish update; reboot to bootloader
  7. Boot patched image:
    Code:
    fastboot boot magisk_patched-23016_xxxxx.img
  8. Open Magisk, tap Install, Direct Install, then reboot.
  9. Done.
You can potentially save a couple steps by using --skip-reboot when applying the update, then simply rebooting to bootloader and flashing the patched boot image.
As mentioned earlier, after flashing a factory image to get to 12 and installing Magisk all was well. But the OTA didn't complete the install for the January update, and even restoring images in Magisk didn't help. So now I need to update in another way. This recipe is clear but IIUC the data will be wiped (factory images have the -w switch in the shell script). Is it possible to do this but delete "-w" so as to not wipe my data? Or perhaps I should just flash the OTA? Thanks for the help.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 19
    If you are looking for my guide on a different Pixel, find it here:
    Update 4-28-22: While Magisk 24.0 has been updated for use with Android 12, many users are still having problems with patching the out of band OTA, so Canary 24306 is recommended.
    Discussion thread for migration to 24.0.

    DO NOT use any version of Magisk lower than Canary 23016 as it does not yet incorporate the necessary fixes for Android 12 and your device.


    WARNING: YOU AND YOU ALONE ARE RESPONSIBLE FOR ANYTHING THAT HAPPENS TO YOUR DEVICE. THIS GUIDE IS WRITTEN WITH THE EXPRESS ASSUMPTION THAT YOU ARE FAMILIAR WITH ADB, MAGISK, ANDROID, AND ROOT. IT IS YOUR RESPONSIBILITY TO ENSURE YOU KNOW WHAT YOU ARE DOING.

    Prerequisites:


    Android Source - Setting up a device for development


    1. Follow these instructions to enable Developer Options and USB Debugging.
    2. Enable OEM Unlocking. If this option is grayed out, unlocking the bootloader is not possible.
    3. Connect your device to your PC, and open a command window in your Platform Tools folder.
    4. Ensure ADB sees your device:
      Code:
      adb devices
      If you don't see a device, make sure USB Debugging is enabled, reconnect the USB cable, or try a different USB cable.
      If you see "unauthorized", you need to authorize the connection on your device.
      If you see the device without "unauthorized", you're good to go.
    5. Reboot to bootloader:
      Code:
      adb reboot bootloader
    6. Unlock bootloader: THIS WILL WIPE YOUR DEVICE!
      Code:
      fastboot flashing unlock
      Select Continue on the device screen.

    1. Install Magisk on your device.
    2. Download the factory zip for your build.
    3. Inside the factory zip is the update zip: "device-image-buildnumber.zip". Open this, and extract boot.img
    4. Copy boot.img to your device.
    5. Patch boot.img with Magisk: "Install" > "Select and Patch a File"
    6. Copy the patched image back to your PC. It will be named "magisk_patched-23xxx_xxxxx.img". Rename this to "master root.img" and retain it for future updates.
    7. Reboot your device to bootloader.
    8. Flash the patched image:
      Code:
      fastboot flash boot <drag and drop master root.img here>
    9. Reboot to Android. Open Magisk to confirm root - under Magisk at the top, you should see "Installed: <Magisk build number>

    1. Before you download the OTA, open Magisk, tap Uninstall, then Restore Images. If you have any Magisk modules that modify system, uninstall them now.
    2. Take the OTA update when prompted. To check for updates manually, go to Settings > System > System Update > Check for Update
    3. Allow the update to download and install. DO NOT REBOOT WHEN PROMPTED. Open Magisk, tap Install at the top, then Install to inactive slot. Magisk will then reboot your device.
    4. You should now be updated with root.

    1. Download the OTA.
    2. Reboot to recovery and sideload the OTA:
      Code:
      adb reboot sideload
      Once in recovery:
      Code:
      adb sideload ota.zip
    3. When the OTA completes, you will be in recovery mode. Select "Reboot to system now".
    4. Allow system to boot and wait for the update to complete. You must let the system do this before proceeding.
    5. Reboot to bootloader.
    6. Boot the master root image (See note 1):
      Code:
      fastboot boot <drag and drop master root.img here>
      Note: If you prefer, you can download the factory zip and manually patch the new boot image, then flash it after the update. Do not flash an older boot image after updating.
    7. Your device should boot with root. Open Magisk, tap Install, and select Direct Install.
    8. Reboot your device. You should now be updated with root.
    Note: You can use Payload Dumper to extract the contents of the OTA if you want to manually patch the new boot image. However, I will not cover that in this guide.

    Please note that the factory update process expects an updated bootloader and radio. If these are not up to date, the update will fail.
    1. Download the factory zip and extract the contents.
    2. Reboot to bootloader.
    3. Compare bootloader versions between phone screen and bootloader.img build number
      Code:
      fastboot flash bootloader <drag and drop new bootloader.img here>
      If bootloader is updated, reboot to bootloader.
    4. Compare baseband versions between phone screen and radio.img build number
      Code:
      fastboot flash radio <drag and drop radio.img here>
      If radio is updated, reboot to bootloader.
    5. Apply update:
      Code:
      fastboot update --skip-reboot image-codename-buildnumber.zip
      When the update completes, the device will be in fastbootd. Reboot to bootloader.
    6. Boot the master root image (See note 1):
      Code:
      fastboot boot <drag and drop master root.img here>
      Note: If you prefer, you can manually patch the new boot image, then flash it after the update. Do not flash an older boot image after updating.
    7. Your device should boot with root. Open Magisk, tap Install, and select Direct Install.
    8. Reboot your device. You should now be updated with root.
    Note: If you prefer, you can update using the flash-all script included in the factory zip. You will have to copy the script, bootloader image, radio image, and update zip into the Platform Tools folder; you will then have to edit the script to remove the -w option so it doesn't wipe your device.
    The scripted commands should look like this:
    Code:
    fastboot update bootloader <bootloader image name>
    fastboot reboot bootloader
    ping -n 5 127.0.0.1 > nul
    fastboot update radio <radio image name>
    fastboot reboot bootloader
    ping -n 5 127.0.0.1 > nul
    fastboot update  --skip-reboot --slot=all <image-device-buildnumber.zip>
    Once this completes, you can reboot to bootloader and either boot your master patched image, or if you patched the new image, flash it at this time.

    1. Follow the instructions on the Android Flash Tool to update your device. Make sure Lock Bootloader and Wipe Device are UNCHECKED.
    2. When the update completes, the device will be in fastbootd. Reboot to bootloader.
    3. Boot the master root image (See note 1):
      Code:
      fastboot boot <drag and drop master root.img here>
      Note: If you prefer, you can download the factory zip and manually patch the new boot image, then flash it after the update. Do not flash an older boot image after updating.
    4. Your device should boot with root. Open Magisk, tap Install, and select Direct Install.
    5. Reboot your device. You should now be updated with root.

    This is my configuration that is passing Safety Net. I will not provide instructions on how to accomplish this. Attempt at your own risk.

    Zygisk + DenyList enabled
    All subcomponents of these apps hidden under DenyList:
    • Google Play Store
    • GPay
    • Any banking/financial apps
    • Any DRM media apps
    Modules:
    To check SafetyNet status:
    I do not provide support for Magisk or modules. If you need help with Magisk, here is the Magisk General Support thread. For support specifically with Magisk v24+, see this thread.

    Points of note:
    • The boot image is NOT the bootloader image. Do not confuse the two - YOU are expected to know the difference. Flashing the wrong image to bootloader could brick your device.
    • While the Magisk app is used for patching the boot image, the app and the patch are separate. This is what you should see in Magisk for functioning root:
      screenshot_20211218-194517-png.5486339
    • "Installed" shows the version of patch in the boot image. If this says N/A, you do not have root access - the boot image is not patched, or you have a problem with Magisk.
    • "App" simply shows the version of the app itself.
    • If you do not have a patched master boot image, you will need to download the factory zip if you haven't already, extract the system update inside it, then patch boot.img.
    • If you prefer updating with the factory image, you can also extract and manually patch the boot image if desired.
    • Some Magisk modules, especially those that modify read only partitions like /system, may cause a boot loop after updating. As a general rule, disable these modules before updating. You are responsible for knowing what you have installed, and what modules to disable.


    Credits:
    Thanks to @ipdev , @kdrag0n , @Didgeridoohan , and last but not least, @topjohnwu for all their hard work!
    3
    Absolutely fantastic! Thanks for this thread and guide!

    As an aside, how is it I didn't know you can drag and drop to the command window? (This tip gets the hero of the day award in my book!)
    Makes things a whole lot easier, don't it?

    I try to stick with the KISS method. Keep It Simple, Stupid!

    Or...Keep it stupidly simple, whatever. :D
    2
    This is extremely old information from September 2020. Install to inactive slot has been re-implemented as of Magisk Canary 23017 {January 20, 2022).

    Please, check your information to ensure it's up to date before you post.
    2
    I'm currently using Magisk Canary build?
    May I Install Magisk Beta and also Magisk Stable build to the latest November 2021 build?
    I honestly don't know. I've used Magisk 22.1, 23.0, Canary 23001 through 23011, all have worked for me.

    The caveat is that Magisk 23010+ is Zygisk, which means that some legacy modules won't work anymore until they're updated - Universal SafetyNet Fix for example.
    Coming from the Pixel 3XL, which bricked out of the blue. I did every update on that phone, but never got to do 12 before the magical brick. I want to update this phone (5a, which I just realized is different than the 5?), but this seems to be missing quite a few steps. Shouldn't there be 4 different files added to your SDK folder and flashed, or has it completely changed, and I need to do more digging? Thanks.
    You don't have to add any files to your SDK folder, you can always drag and drop them into the command line window. We are only working with two files here: vbmeta.img and boot.img.
    Is there any way to do this after already updating? Or do I have to wait for the next update (I prefer flashing factory images).
    You can do this as many times as you want. The critical point to remember is that if you allow Android to boot after not disabling verity/verification, you will have to wipe the next time you disable it.
    I flashed the Nov factory image but forgot to disable the verified boot. Is there any way I can disable it so i can flash the magisk patched boot?
    Yes...but you're going to have to wipe data. Extract vbmeta.img, and reflash it:
    Code:
    fastboot flash vbmeta --disable-verity --disable-verification <drag and drop vbmeta.img here>
    Then, reboot your device. You will end up in Rescue Party, with the option to "Try again" or "Factory data reset". Choose the factory reset.

    The best way to make sure you don't have to wipe your data is to always use --disable-verity --disable-verification when updating via the factory image.
    2
    Followed directions for recommended Android Flash Tool and everything worked flawlessly. If you've already rooted your phone once then you have somewhat of an idea of what you're doing. Just read everything twice and follow the directions. Thank you OP for such a clear path to update and root!