FORUMS
Remove All Ads from XDA

[GUIDE] Unlock/Flash/Root for the Pixel 2 (walleye)

12,721 posts
Thanks Meter: 42,764
 
By nathanchance, Recognized Developer / Recognized Contributor on 9th November 2017, 03:16 AM
Post Reply Email Thread
Introduction

Hello everyone, this is a guide to assist you with customizing your Pixel 2! I will be going over installing fastboot and adb, unlocking your bootloader, how to flash the factory images for clean flashes and upgrades, and how to root. Please feel free to ask any questions if you need clarification. Enjoy!

This information has been distilled from Google's official factory image site and the Magisk thread.


Installing fastboot and adb

Thankfully, Google has provided just adb, fastboot, and systrace as a simple zip file, making this process super easy. You MUST be on at LEAST 26.0.2 for the commands in this guide to work. When in doubt, grab the latest copy and install them using the following instructions.

Windows:
  1. Unzip the folder somewhere on your hard drive.
  2. Go to the folder containing the adb and fastboot files and type "cmd" in the path bar at the top.
  3. A command prompt should open with the current folder showing on the prompt.
  4. Type the following commands:
    Code:
    adb --version
    fastboot --version
    You should see some information appear. If that is the case, you were successful!


Mac/Linux:
  1. Unzip the folder somewhere on your hard drive.
  2. Navigate to that folder with your terminal.
  3. Run the following commands:
    Code:
    sudo install adb /usr/local/bin
    sudo install fastboot /usr/local/bin
  4. Type the following commands:
    Code:
    adb --version
    fastboot --version
    You should see the version information, along with telling you they are installed to /usr/local/bin. If so, you were successful!



Unlocking the bootloader

WARNING: This WILL wipe your entire phone. Please make copies or backups of any important data. This can also go wrong rendering your device inoperable. Proceed with caution.
  1. On your phone, open Settings, navigate to "System" then "About phone", and tap on the build number 7 times.
  2. Go one menu up, click on "Developer options", and turn on USB debugging and OEM unlocking.
  3. In your terminal, type the following command:
    Code:
    adb reboot bootloader
  4. Run the following command:
    Code:
    fastboot flashing unlock
  5. Follow the prompts on your device then reboot!


Flashing factory images

NOTE #1: You CANNOT downgrade factory images. Google has prevented users from doing so to keep them safe from vulernabilities that were patched. You should only upgrade or reinstall the current image.

NOTE #2: If you have mounted /system as rw at any point (like in TWRP), you must upgrade using the factory image method. OTAs will fail because they cannot verify the integrity of the disk since its verity data has been changed.

NOTE #3: Flashing the factory images requires an unlocked bootloader. Flashing the OTA zips does not (but if anything goes wrong, you may not be able to recover without an RMA).

Updating to a new release (factory image):
  1. Download the latest factory image from Google's website.
  2. Reboot into the bootloader:
    Code:
    adb reboot bootloader
  3. Unzip the factory image.
  4. Inside you will see a bootloader image, a radio image, an image zip file, and a couple of flash scripts.
  5. If you are on Windows, open the "flash-all.bat" file in a text editor. If you are on Mac or Linux, open the "flash-all.sh" instead.
  6. Remove the "-w" flag before the fastboot command towards the end of the file. This will prevent fastboot from formatting your device.
  7. Run the flash all script! Open a command prompt, navigate to the folder with the script, and run one of the following commands:
    Windows:
    Code:
    flash-all
    Mac/Linux:
    Code:
    ./flash-all.sh
  8. Reboot once it is finished!

Updating to a new release (OTA zip):
  1. Download the latest OTA zip from Google's website
  2. Reboot into recovery:
    Code:
    adb reboot recovery
  3. Hold down the power button and push volume up
  4. Select "Apply update from ADB"
  5. Run the following command from the folder containing the OTA zip:
    Code:
    adb sideload <zip_name>.zip
  6. Reboot once it is finished!

Clean flashing a factory image (wipe everything):
  1. Download the latest factory image from Google's website
  2. Reboot into the bootloader:
    Code:
    adb reboot bootloader
  3. Unzip the factory image.
  4. Run the flash all script! Open a command prompt, navigate to the folder with the script, and run one of the following commands:
    Windows:
    Code:
    flash-all
    Mac/Linux:
    Code:
    ./flash-all.sh
  5. Reboot once it is finished!



Rooting with Magisk

NOTE #4: This section assumes you are not going to install TWRP. If you are, skip to the next section and just flash the latest Magisk zip after installing TWRP.
  1. Download the Magisk zip from the official thread and install the manager from the zip.
  2. Grab a boot image to patch (either the one from the latest factory image or a custom kernel one) and push it to your device:
    Code:
    adb push <path_to_file> /sdcard/Download
  3. Open Magisk Manager and click the Install button.
  4. Click "Install" at the first prompt then choose "Patch Boot Image File". A file manager will pop up.
  5. Select the boot image you want to patch and let Magisk Manager patch it.
  6. Pull it off your device:
    Code:
    adb pull /sdcard/MagiskManager/patched_boot.img
  7. Reboot into the bootloader:
    Code:
    adb reboot bootloader
  8. Flash the boot image and reboot.
    Code:
    fastboot flash boot patched_boot.img
    fastboot reboot
  9. Open Magisk Manager and you should be rooted!


Installing TWRP

NOTE #5: If you just want to temporarily boot TWRP to flash Magisk and your custom kernel, you can just skip flashing the installer zip in this process.

NOTE #6: TWRP can be unstable at times given the way that security has been set up on this device (lack of decryption, failing to boot, etc).
  • Download both the TWRP image and zip installer from the official site.
  • Temporarily boot the TWRP image.
    Code:
    fastboot boot <path_to_twrp_image>
  • Flash the TWRP installer zip.
  • Reinstall Magisk and your custom kernel if you had them.
  • Reboot and profit!



Closing statements

If there are any procedures you would like to see added (like flashing a custom kernel or booting TWRP), I am happy to add them if requested. Also, when requesting help, please be as specific as possible where you get confused. I want this guide to be clear as possible.
The Following 55 Users Say Thank You to nathanchance For This Useful Post: [ View ]
 
 
9th November 2017, 03:16 AM |#2  
nathanchance's Avatar
OP Recognized Developer / Recognized Contributor
Flag Mesa, AZ
Thanks Meter: 42,764
 
More
Reserved
9th November 2017, 03:17 AM |#3  
nathanchance's Avatar
OP Recognized Developer / Recognized Contributor
Flag Mesa, AZ
Thanks Meter: 42,764
 
More
Reserved
9th November 2017, 06:19 AM |#4  
Junior Member
Thanks Meter: 0
 
More
Stuck on this step
Run the flash all script! Open a command prompt, navigate to the folder with the script, and run one of the following commands:

How do I navigate in command prompt? When I typed flash-all, it said it is not a internal command etc. When I dragged and dropped flash-all into the command prompt, it said C:\Users\W Balls\Downloads\SAMPWND_SYSTEMROOT_ADB_FILES>"C:\U sers\****** Jim\Downloads\walleye-opd1.170816.025-factory-4752baae\walleye-opd1.170816.025\flash-all.bat"
error: cannot load 'bootloader-walleye-mw8998-002.0059.00.img'
rebooting into bootloader...
OKAY [ 0.004s]
finished. total time: 0.004s
error: cannot load 'radio-walleye-g8998-00122-1708311414.img'
rebooting into bootloader...
OKAY [ 0.010s]
finished. total time: 0.015s
W/ ( 6448): Unable to open 'image-walleye-opd1.170816.025.zip': No such file or directory
error: failed to open zip file 'image-walleye-opd1.170816.025.zip': I/O Error
Press any key to exit...
9th November 2017, 09:58 AM |#5  
Member
Thanks Meter: 9
 
More
You are calling the flash-all.bat out of a differende directory (C:\Users\W Balls\Downloads\SAMPWND_SYSTEMROOT_ADB_FILES) therefore it can't find the system image files since they are located under C:\U sers\****** Jim\Downloads\walleye-opd1.170816.025-factory-4752baae\walleye-opd1.170816.025. Make sure you extract your image to that directory, open up a command promt and navigate to it with "cd C:\Users\W Balls\Downloads\SAMPWND_SYSTEMROOT_ADB_FILES" and call the flash-all.bat from there.

Check out this for basic command line stuff https://www.digitalcitizen.life/comm...basic-commands

---------- Post added at 10:58 AM ---------- Previous post was at 10:56 AM ----------

I tried this and it seems the magisk manager isn't able to download magisk on its own at least on my device:

Code:
DownloadManager: [356] Stop requested with status HTTP_DATA_ERROR: Unable to resolve host "forum.xda-developers.com": No address associated with hostname
DownloadManager: [356] Finished with status WAITING_TO_RETRY
EDIT: Seems like DNS66 was blocking the download patching was scucessfull now.

This is weird, can't I make 2 posts in a row??
The Following User Says Thank You to drmason For This Useful Post: [ View ] Gift drmason Ad-Free
9th November 2017, 02:57 PM |#6  
Senior Member
Flag Oakland
Thanks Meter: 150
 
More
Anybody figure out a solution for flashing when on MacOs High Sierra? Platform tools 26.0 1 was a fix for high Sierra, yet 26.0.2 seemed to have lost that commit, so fastboot doesn't work at all. Wondering if it's safe to use 26.0.1 on the pixel 2
9th November 2017, 05:09 PM |#7  
Member
Flag Dallas
Thanks Meter: 6
 
More
Quote:
Originally Posted by nathanchance


Flashing factory images

First, thanks for putting this together. I've rooted using your method.

Regarding OTA updates: I've read that if we've rooted, we will need to un-root before we can receive an OTA update. Is this always true, or only if we've installed a custom recovery like TWRP? It would be really handy to have a guide on how to un-root, update, then re-root.

Related - let's say that for whatever reason, we have to flash an OTA update manually, rather than actually getting it OTA. Do we lose root by doing so?

Thanks!
9th November 2017, 05:32 PM |#8  
nathanchance's Avatar
OP Recognized Developer / Recognized Contributor
Flag Mesa, AZ
Thanks Meter: 42,764
 
More
Quote:
Originally Posted by JayBlack_686

First, thanks for putting this together. I've rooted using your method.

Regarding OTA updates: I've read that if we've rooted, we will need to un-root before we can receive an OTA update. Is this always true, or only if we've installed a custom recovery like TWRP? It would be really handy to have a guide on how to un-root, update, then re-root.

Related - let's say that for whatever reason, we have to flash an OTA update manually, rather than actually getting it OTA. Do we lose root by doing so?

Thanks!

Magisk's OTA section should clear up some of your doubts: https://github.com/topjohnwu/Magisk/...tallation-tips
The Following 5 Users Say Thank You to nathanchance For This Useful Post: [ View ]
9th November 2017, 07:24 PM |#9  
Member
Flag Dallas
Thanks Meter: 6
 
More
Quote:
Originally Posted by nathanchance

Magisk's OTA section should clear up some of your doubts: https://github.com/topjohnwu/Magisk/...tallation-tips

Looks really straightforward, thank you! Might be cool to point to it in the OP. I bet I'm not the only one who was only vaguely aware of the impact that rooting has on how we get OTAs. Then again, maybe everyone else wants to run custom ROMs.
9th November 2017, 08:57 PM |#10  
nathanchance's Avatar
OP Recognized Developer / Recognized Contributor
Flag Mesa, AZ
Thanks Meter: 42,764
 
More
Quote:
Originally Posted by JayBlack_686

Looks really straightforward, thank you! Might be cool to point to it in the OP. I bet I'm not the only one who was only vaguely aware of the impact that rooting has on how we get OTAs. Then again, maybe everyone else wants to run custom ROMs.

Good point, I'll add it here in a bit

Sent from my Pixel 2 XL using XDA Labs
The Following 2 Users Say Thank You to nathanchance For This Useful Post: [ View ]
9th November 2017, 11:08 PM |#11  
Junior Member
Thanks Meter: 3
 
More
OTA vs factory image
Howdy,
really appreciate @nathanchance for putting this together. Would you mind adding a few lines about the differences between OTA and factory images. As a layman i haven't got the foggiest idea which route to go and would appreciate some wisdom. Thanks!
The Following User Says Thank You to tango650 For This Useful Post: [ View ] Gift tango650 Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes