Flashable firmware zip generator for the Oneplus 3T

I have recently switched to a Oneplus 3T after my older phone suffered a series of unfortunate accidents.

I have to say I'm very happy with the experience so far. Excellent build quality, performance, battery and the warranty is not voided by using non-oficial ROMs.

After verifying that everything worked fine with the stock ROM I immediately switched to LineageOS, the successor of CyanogenMod.

The issue with this ROM is that they don't ship the firmware blobs themselves. So every time a newer version of the firmware is needed, one needs to flash the stock upgrade, wiping all existing data in the process.

To avoid having to wipe clean my device with a factory image every time I want to upgrade my firmware I wrote a small script to generate a flashable zip from Oneplus' official OxygenOS ROM images which you can download here.

Keep on reading if you are interested in my upgrade routine/checklist.

My upgrade checklist

Whenever is time for a firmware upgrade, I take the following steps:

First, put everything to download

It's a couple of GB, so it may take a while depending on your internet connection:

  1. Official ROM to extract the firmware from the official download site.
  2. TeamWin's latest recovery from here.
  3. Latest version of LineageOS for the Oneplus 3/3T.
  4. Latest version of Magisk.
  5. Update Tingle.

Update TWRP:

Reboot into fastboot mode:

adb reboot bootloader

Wait for the phone to enter fastboot mode and:

fastboot flash recovery twrp-3.1.0-1-oneplus3t.img

Upgrade the firmware blobs

Extract the latest firmware from the stock ROM (the extraction script can be downloaded here).

./generate-flashable-firmware-zip.sh ~/OnePlus3TOxygen_28_OTA_023_all_1704261914_d02c3ec6319f4439.zip

Reboot the phone in recovery mode and start sideload, then

adb sideload firmware-OnePlus3TOxygen_28_OTA_023_all_1704261914_d02c3ec6319f4439.zip

Update LineageOS

Enable sideload again and:

adb sideload lineage-14.1-20170504-nightly-oneplus3-signed.zip

Disable the initial setup wizard to prevent a crash loop that I haven't bothered debugging:

adb shell mount /system
adb shell mv /system/priv-app/LineageSetupWizard/LineageSetupWizard.apk /system/priv-app/LineageSetupWizard/LineageSetupWizard.apk.bak

Flash latest Magisk

This needs to be done every time a ROM update is flashed as Magisk modifications to the boot image will be lost.

While still on recovery, enable sideload yet again and:

adb sideload Magisk-v12.0.zip

Don't reboot just yet!

Use Tingle to enable signature faking

This last step is needed for microG's google services to work properly.

adb shell mount /system
cd tingle

And select option 1 from the menu.

adb reboot