Skip to content

Instantly share code, notes, and snippets.

@tobadia
Last active May 16, 2024 14:34
Show Gist options
  • Save tobadia/5146f639dd2a10fa9e2054dc6146862f to your computer and use it in GitHub Desktop.
Save tobadia/5146f639dd2a10fa9e2054dc6146862f to your computer and use it in GitHub Desktop.
# Here I will keep a reminder of the steps to full wipe a OnePlus One device running CyanogenOS/CyanogenMod
# This is especially interesting on encrypted devices where I suspect partitions might get crippled over time
# Note: this guide assumes that you are already running the latest CyanogenOS version at the beginning (currently ZNH2KAS2X1).
# If not, dirty-upgrade to the latest version by flashing the update zip file from recovery and start from there.
# I will also assume that the current directory is the one where all the downloads are stored
# Step 0 : necessary stuff
# (http://forum.xda-developers.com/oneplus-one/general/official-cm11s-roms-ota-updates-t2906746)
# - CyanogenOS 13.1.1 (ZNH2KAS2X1) flashable zip (https://www.androidfilehost.com/?fid=24591000424953697) [cm-13.1.1-ZNH2KAS2X1-bacon-signed.zip]
# - CyanogenOS 13.1.1 (ZNH2KAS2X1) fastboot files to extract stock recovery (https://www.androidfilehost.com/?fid=24591000424953703) [cm-13.1.1-ZNH2KAS2X1-bacon-signed-fastboot.zip]
# - TWRP with encryption fix (https://www.androidfilehost.com/?fid=24521665358595401) [TWRP-3.0.2-0-bacon-with-decryption-cm13-AtAM1.img]
# - Cyanogen original root enabler (http://kernel.boeffla.de/bacon/boeffla-kernel-cms/cm13.1s_download/Test/) [COS13.1-enable-internal-superuser-bacon.zip]
# - Boeffla Kernel 5.2-beta7 or newer (http://kernel.boeffla.de/bacon/boeffla-kernel-cms/cm13.1s_download/Test/) [boeffla-kernel-5.2-beta7-COS13.1-bacon-anykernel.recovery.zip]
# - Boeffla Config App APK (http://kernel.boeffla.de/bcv2)
# Step 1 : backup all the things!
# Enter plane mode to avoid receiving SMS or calls.
# Run a FULL TB backup.
# Copy all relevant content of /sdcard/ to your computer (DCIM, Download, Pictures, TitaniumBackup...)
# Step 2 : restore original recovery (proper handling of partitions and filesystem)
# First, extract cm-13.1.1-ZNH2KAS2X1-bacon-signed-fastboot.zip
adb reboot bootloader
fastboot flash recovery cm-13.1.1-ZNH2KAS2X1-bacon-signed-fastboot/recovery.img
fastboot reboot
# Step 3 : reset to factory default
# Settings > Backup and reset > Factory data reset > Reset phone
# The phone should reboot and show an android with "Erasing". Can take a while (2+ hours on mine)...
# This is the only way to rewrite partitions and get rid of encryption.
# Step 4 : Use TWRP to erase content of all partitions (DOUBLE CHECK FOR BACKUP OF INTERNAL STORAGE !!)
# Ignore the factory setup, enable developper mode and ADB.
adb reboot bootloader
fastboot flash recovery TWRP-3.0.2-0-bacon-with-decryption-cm13-AtAM1.img
fastboot reboot
adb reboot recovery
# Wipe > Advanced wipe > Dalvik, Cache, System, Data, Internal Storage
# Can take a while (minutes to 1+ hour)
adb push cm-13.1.1-ZNH2KAS2X1-bacon-signed.zip /sdcard/
# Install > cm-13.1.1-ZNH2KAS2X1-bacon-signed.zip
# You now have a clean, factory system installed. It *shouldn't* alter TWRP: reboot to bootloader and restore original recovery.
fastboot flash recovery cm-13.1.1-ZNH2KAS2X1-bacon-signed-fastboot/recovery.img
# Step 5 : set up phone as new and encrypt
# Run the factory setup by *not* restoring the phone using Google option, but rather "Set the phone as new" (below the list of Gdrive backups).
# Enable developper mode and ADB.
# Settings > Security > Encrypt
# The phone reboots and does its magic...
# The phone boots with a factory-fresh system, encrypted.
# Step 6 : Restore TWRP, enable root, custom kernel
adb reboot bootloader
fastboot flash recovery TWRP-3.0.2-0-bacon-with-decryption-cm13-AtAM1.img
fastboot reboot
adb reboot recovery
adb push /sdcard/COS13.1-enable-internal-superuser-bacon.zip
adb push /sdcard/boeffla-kernel-5.2-beta7-COS13.1-bacon-anykernel.recovery.zip
# Install > COS13.1-enable-internal-superuser-bacon.zip and boeffla-kernel-5.2-beta7-COS13.1-bacon-anykernel.recovery.zip
# Reboot > System
# Settings > Developper options > Root access > Applications and ADB
# Install Boeffla APK app.
# Step 7 : Restore all necessary internal storage data that was backuped to your computer
# Step 8 : Reinstall all necessary apps from the Play Store "My apps" section
# Step 9 : Restore all necessary apps data using TB
# Step 10: Profit!!
@Ketouem
Copy link

Ketouem commented Oct 22, 2016

Slight typos at lines 57 & 58

adb push /sdcard/COS13.1-enable-internal-superuser-bacon.zip
adb push /sdcard/boeffla-kernel-5.2-beta7-COS13.1-bacon-anykernel.recovery.zip

to

adb push COS13.1-enable-internal-superuser-bacon.zip /sdcard/
adb push boeffla-kernel-5.2-beta7-COS13.1-bacon-anykernel.recovery.zip /sdcard/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment