#!/usr/bin/env sh ## OnePlus One (64 GB) [2014] - ARMv7l (ARM / armhf / ARM 32-bit) ## Flash/Patch path: CM 11 (Android 4) -> OOS 2.1.4 (Android 5) -> CM 17.1 (Android 10) -> CM 18.1 (Android 11) + TWRP v3.6.2_9-0 + Magisk v27 ## ## When flashing OOS, it will put on latest (official) firmware as well as system and recovery ## This is why OOS ZIP is so large over LOS (as it only has system) ## Firmware = partitions? = bootloader/fastboot, bootanimation, radio, etc ## ## Device needs to have USB debugging mode enabled via developer options already ## Settings -> System -> About phone -> Build number: 7x taps ## Settings -> Search: "USB Debugging" -> Enable -> Always allow: RSA key fingerprint ## _Menu structure changes between Android 10 + 11_ ## ## If device bootloader is locked, when unlocking will reboot the device, breaking this script ## Re-run script (may need to re-enabled USB Debugging) ## ## Unable to install LOS & Magisk in the same session (hence the need to reboot in-between) ## ## Alt Flash/Patch path: ## Flash/Patch path: CM 11 (Android 4) -> CM 13.1.2 (Android 6) -> CM 17.1 (Android 10) -> CM 18.1 (Android 11) + TWRP v3.6.2_9-0 + Magisk v27 ## _Just don't get the firmware updates_ ## LOS: Can't jump too far ahead, and some versions require /data to be wiped before flashing can happen - which would be extra steps! ## ## Misc terms: ## - OOS recovery refers to bootloader as fastboot ## - OOS system refers to bootloader as bootloader ## ## ./$0 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## wait_device wait_device() { #set +x; while ! adb devices | grep -q recovery; do echo "[i] Waiting on the device to be in recovery mode"; sleep 2; done; set -x #set +x; while ! adb devices | grep -qw 'device$'; do echo "[i] Waiting for the first time install/setup wizard to be completed, and for USB debugging to be re-enable via developer options"; sleep 5; done; set -x #set +x; while ! adb devices | grep -qw 'device$'; do echo "[i] Waiting on device to be in system mode, with USB debugging enabled"; sleep 2; done; set -x ## Gets to be too verbose set +x; mode="${1:-recovery}" case "${mode}" in recovery) device="recovery" msg="[i] Waiting on the device to be in recovery mode"; i=2;; setup) device=device msg="[i] Waiting for the first time install/setup wizard to be completed, and for USB debugging to be re-enable via developer options"; i=5;; system) device=device msg="[i] Waiting on device to be in system mode"; i=2;; *) echo "[-] Unknown mode: ${mode}" >&2 && exit 1;; esac while ! adb devices | grep -q "${device}$"; do echo "${msg}" sleep "${i}"s done; ## Be verbose again set -x } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## Be verbose - show commands set -x ## Path may need altering ## REF: https://download.g0tmi1k.com/android/oneplusone-bacon/ cd ~/oneplusone-bacon/ ## Bootloader adb reboot bootloader fastboot oem device-info fastboot oem unlock # If device was previously locked, will reboot and break this script! #adb reboot bootloader # Solution to the above issue (or just re-run!) ## Stock ROM (CyanogenMod - CM) rm -rf cm/; mkdir -pv cm/ && cd cm/ && unzip ../cm-11.0-XNPH44S-bacon-signed-fastboot.zip fastboot flash modem NON-HLOS.bin fastboot flash sbl1 sbl1.mbn fastboot flash dbi sdi.mbn fastboot flash aboot emmc_appsboot.mbn fastboot flash rpm rpm.mbn fastboot flash tz tz.mbn fastboot flash LOGO logo.bin fastboot flash oppostanvbk static_nvbk.bin #fastboot flash recovery recovery.img # Will use TWRP later fastboot flash system system.img fastboot flash boot boot.img fastboot flash cache cache.img #fastboot flash userdata userdata.img # OnePlus One 16GB fastboot flash userdata userdata_64G.img # OnePlus One 64GB cd ../ && rm -rf cm/ ## Team Win Recovery Project (TWRP) fastboot flash recovery twrp-3.6.2_9-0-bacon.img # Need to have "disabled: updated recovery" via developer options when enabled fastboot boot twrp-3.6.2_9-0-bacon.img # Doesn't always work (may need to completely power off and boot into recovery - hold power & volume down, until on/vibrate) ## Vendor ROM (OxygenOS - OOS) + TWRP wait_device recovery ## Error: This package is for "OnePlus" devices; this is a "A0001". ## $ head -n 1 META-INF/com/google/android/updater-script: getprop("ro.build.product") == "OnePlus" || getprop("ro.build.product") == "ONE" || abort([...]) ### Fix #1 #adb shell 'twrp mount system; sleep 2s; twrp remountrw; sed -i "s_^ro.build.product=A0001_ro.build.product=OnePlus_" /system/build.prop' #adb reboot recovery # $ getprop ro.build.product #wait_device recovery #adb push OnePlus_Bacon_OxygenOS_201601190107.zip /sdcard/oos-2.1.4.zip; adb shell 'twrp install /sdcard/oos-2.1.4.zip' ## Fix #2 rm -rf oos/; mkdir -pv oos/ && cd oos/ cp -fv ../OnePlus_Bacon_OxygenOS_201601190107.zip oos-2.1.4.zip unzip -o oos-2.1.4.zip META-INF/com/google/android/updater-script sed -i '/^getprop/d' META-INF/com/google/android/updater-script zip --update "oos-2.1.4.zip" "META-INF/com/google/android/updater-script" adb push oos-2.1.4.zip /sdcard/oos-2.1.4.zip; adb shell 'twrp install /sdcard/oos-2.1.4.zip' # Will replace TWRP/recovery cd ../ && rm -rf oos/ ## Team Win Recovery Project (TWRP) ...again adb reboot bootloader # TWRP can't install IMG files from CLI (yet), otherwise could install itself from itself! fastboot flash recovery twrp-3.6.2_9-0-bacon.img # Re-flash TWRP, as OOS replaced theirs fastboot boot twrp-3.6.2_9-0-bacon.img # Workaround, as can't do: $ fastboot reboot recovery ## LineageOS (LOS) wait_device recovery #adb push cm-13.1.2-ZNH2KAS3P0-bacon-signed-8502142fdc.zip /sdcard/cm-13.1.2.zip; adb shell 'twrp install /sdcard/cm-13.1.2.zip' adb push lineage-17.1-20210325-nightly-bacon-signed.zip /sdcard/los-17.1.zip; adb shell 'twrp install /sdcard/los-17.1.zip' adb push lineage-18.1-20240306-nightly-bacon-signed.zip /sdcard/los-18.1.zip; adb shell 'twrp install /sdcard/los-18.1.zip' adb shell 'twrp wipe data' # Alt: adb shell 'twrp format data' adb reboot ## (Re-)Enable developer mode wait_device setup ## Magisk adb reboot recovery wait_device recovery adb push Magisk-v27.0.apk /sdcard/Magisk-27.apk; adb shell 'twrp install /sdcard/Magisk-27.apk' # v28.0 doesn't work with TWRP, but does work with: $ adb install Magisk-v28.0.apk #adb push lineage-18.1-20240306-nightly-bacon-signed.zip /sdcard/los.zip # In case TWRP needs it - LOS 18.1/Android 11 runs out of space on second flash, LOS 17.1/Android 10 is ok adb reboot ## Kali NetHunter ## REF: https://gitlab.com/kalilinux/nethunter/build-scripts/kali-nethunter-kernels/-/raw/main/devices.yml wait_device system #adb push *nethunter*oneplus1*.zip /sdcard/nh-11.zip #adb shell 'twrp install /sdcard/nh-11.zip' # Opt'ing to to install via Magisk instead adb shell 'su -c magisk --install-module /sdcard/nh-11.zip' # Needs Internet access to complete first time app launch of Magisk (aka update) then patch boot and finally reboot tp apply before this command fully work