bkerler / edl

Inofficial Qualcomm Firehose / Sahara / Streaming / Diag Tools :)
GNU General Public License v3.0
1.62k stars 380 forks source link

Commands to flash imgs extracted from ops to restore OnePlus 6 as thrououghly as possible? #432

Open Espionage724 opened 1 year ago

Espionage724 commented 1 year ago

I have a OP6 and would like to flash images from packages named similar to enchilada_22_O.15_180810.ops, making sure that all images from the ops are written to all the device's A and B partitions, or at least A with wiped B partitions.

I've ran into a situation where I restored a 5.1.5 OOS packages via MsmDownloadTool and couldn't use wifi because it seems like MsmDownloadTool didn't flash what was needed to downgrade whatever controls wifi and it was left at a higher version than the Android version could use (couldn't scan for APs, wifi mac was 0s and wrong); OTAing to OOS 9 fixed wifi and presented my MAC. I want to avoid that and knowingly downgrade and flash every component of the restore package to be sure my phone is restored.

I don't want to break EDL mode somehow or wipe IMEI/MAC/device-specific identifiers, and it'd be neat to back those up even if they're on a particular partition?

I've downloaded OnePlus_6_OxygenOS_10.3.8.zip and extracted these files:

build_path.txt 
md5sum_pack.md5
rev_OverSeas_210121_0427_release_OTA-BLOCK_Signed_fp2101210427_cve2021-01-01_ufs_10.3.8
enchilada_22_J.50_210121.ops
MsmDownloadTool V4.0.exe

I did opscrypto.py decrypt on enchilada_22_J.50_210121.ops and extracted these files:

4j1ed.bin
4u1ea.bin
abl.elf
aop.mbn
apdp.mbn
boot.img
BTFM.bin
cmnlib64.mbn
cmnlib.mbn
config.bin
devcfg.mbn
dspso.bin
dtbo.img
dynamic_nvbk.bin
gpt_backup0.bin
gpt_backup1.bin
gpt_backup2.bin
gpt_backup3.bin
gpt_backup4.bin
gpt_backup5.bin
gpt_main0.bin
gpt_main1.bin
gpt_main2.bin
gpt_main3.bin
gpt_main4.bin
gpt_main5.bin
hyp.mbn
keymaster64.mbn
logfs_ufs_8mb.bin
logo.bin
micron128.bin
msadp.mbn
NON-HLOS.bin
odm.img
op1.img
op2.img
param.bin
persist.img
prog_firehose_ddr.elf
provision_hynix.xml
provision_micron.xml
provision_samsung.xml
provision_toshiba.xml
qupv3fw.elf
reserve1.bin
reserve2.bin
sec.dat
settings.xml
static_nvbk.bin
storsec.mbn
system.img
tz.mbn
userdata.img
vbmeta.img
vendor.img
xbl_config.elf
xbl.elf

This is where I'm not sure the best way to proceed. settings.xml seems to describe where images go and it seems like I can manually flash the images one-by-one to A and B partitions, but I wonder if I could just tell edl to reference the settings.xml and do everything?

chayleaf commented 10 months ago
with open('settings.xml', 'rt') as f:
    xml = f.read()
for intag, outtag, out in (('Program', 'data', 'rawprogram'), ('Patch', 'patches', 'patch')):
    for pr in xml.split(f'<{intag}')[1:]:
        num, data = pr.split('>', 1)
        lines = filter(lambda x: x, map(lambda x: x.strip(), data.split(f'</{intag}')[0].split('\n')))
        with open(f'{out}{num}.xml', 'wt') as f:
            print(f'<?xml version="1.0" ?>\n<{outtag}>', file=f)
            for line in lines:
                print(' ', line, file=f)
            print(f'</{outtag}>', file=f)

and then

edl qfil rawprogram0.xml patch0.xml .
edl qfil rawprogram1.xml patch1.xml .
edl qfil rawprogram2.xml patch2.xml .
edl qfil rawprogram3.xml patch3.xml .
edl qfil rawprogram4.xml patch4.xml .
edl qfil rawprogram5.xml patch5.xml .

worked for me

(edit: fixed as mentioned below)

dtql commented 9 months ago

Hi @chayleaf, I had to modify line 8 from: print('<?xml version="1.0" ?>\n<{outtag}>', file=f) to print(f'<?xml version="1.0" ?>\n<{outtag}>', file=f) for it to work properly. Thank you for sharing the instructions, it was very helpful for me to unbrick my phone :)

YongBinnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn commented 5 months ago

The script provided by @chayleaf works great! I suggest it to be added to the project.

NokoPlays commented 2 months ago

@chayleaf it worked but everytime i boot the device i get an invalid vip nvs error i don't know what that would mean but i was able to fix by going to the dialer and entering: *#268# and then going to nv parameters then backup dynamic nv/efs then restore nv/efs and then reboot the device and the error should be gone

also the device bootloader needs to be relocked manually if you want it to be locked again device i tried this on: oneplus 6t and i did flash the oneplus 6t firmware ofc

NokoPlays commented 2 months ago

also sorry for mentioning an issue by accident

YongBinnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn commented 2 months ago

@chayleaf it worked but everytime i boot the device i get an invalid vip nvs error i don't know what that would mean but i was able to fix by going to the dialer and entering: *#268# and then going to nv parameters then backup dynamic nv/efs then restore nv/efs and then reboot the device and the error should be gone

also the device bootloader needs to be relocked manually if you want it to be locked again device i tried this on: oneplus 6t and i did flash the oneplus 6t firmware ofc

I encountered the same problem

Espionage724 commented 2 months ago

but i was able to fix by going to the dialer and entering: *#268# and then going to nv parameters then backup dynamic nv/efs then restore nv/efs and then reboot the device and the error should be gone

I did a fresh restore of 10.3.8 and *#268# doesn't seem to do anything from the default OOS phone app. I get the NVBackupUI error on 10.3.8.

*#268# also didn't do anything from 11.1.2.2 but I don't get the NVBackupUI notification there after OTA'ing from 10.3.8. I recall some versions of OOS not working with certain dialer codes or something like the engineering mode not being available after a certain version. I'm downloading 5.1.11 now to try with that.

Espionage724 commented 2 months ago

*#268# works fine from 5.1.11!

Doing just RESTORE NV/EFS and rebooting wasn't enough (still had the NVBackupUI error). After that reboot I went back to NVBackupUI, did BACKUP DYNAMIC NV/EFS, then RESTORE NV/EFS, disconnected the phone's USB from my computer, powered the OP6 off and back on, and now all looks good! (no NVBackupUI error).

9.0.9 does not allow *#268# (OTA'd from 5.1.11/Android 8.1.0), so it seems like restoring with edl ideally requires a 5.1.11 or older MSM package in order to do the NV backup/restore to fix NVBackupUI errors. The update process with that is 5.1.11 (MSM/edl) -> 9.0.9 (OTA) -> 11.1.2.2 (OTA)

nvbackupui