Hovatek Forum MOBILE Android [Please help] Need Help for OTA update after Root on Ulefone with Mediatek device
Can't login? Please, reset your password.
Hovatek is recruiting! Apply Now


[Please help] Need Help for OTA update after Root on Ulefone with Mediatek device

[Please help] Need Help for OTA update after Root on Ulefone with Mediatek device

Harlock1978
Harlock1978
Harlock1978
Enthusiastic Member
11
12-06-2021, 11:24 AM
#1



I have an Ulefone Armor 11 5G with a Mediatek MT6873, unlocked bootloader and Magisk installed.
Now I receive the info for an OTA update, obviously it was not working, so I flashed back the original vbmeta.img and boot.img, but again it says that the partition doesn't match.
I downloaded the OTA packages and extracted the updater-script:

Code:

getprop("ro.product.device") == "Armor_11_5G" || abort("E3004: This package is for \"Armor_11_5G\" devices; this is a \"" + getprop("ro.product.device") + "\".");
ui_print("Source: Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys");
ui_print("Target: Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys");
ui_print("Verifying current system...");
getprop("ro.build.fingerprint") == "Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys" ||
    getprop("ro.build.fingerprint") == "Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys" ||
    abort("E3001: Package expects build fingerprint of Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys or Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys; this device has " + getprop("ro.build.fingerprint") + ".");
patch_partition_check("EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a",
                      "EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a") ||
    abort("E3005: \"EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a\" or \"EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a\" has unexpected contents.");
apply_patch_space(56631296) || abort("E3006: Not enough free space on /cache to apply patches.");
patch_partition_check("EMMC:/dev/block/by-name/md1img:66856432:5521bd20270f93c39a09be3cbd530b9297c959b7",
                      "EMMC:/dev/block/by-name/md1img:66794448:86f1fe5a143a19caf7339b05bf06f139021a4bfe") ||
    abort("E3005: \"EMMC:/dev/block/by-name/md1img:66856432:5521bd20270f93c39a09be3cbd530b9297c959b7\" or \"EMMC:/dev/block/by-name/md1img:66794448:86f1fe5a143a19caf7339b05bf06f139021a4bfe\" has unexpected contents.");
apply_patch_space(66856432) || abort("E3006: Not enough free space on /cache to apply patches.");
if (range_sha1(map_partition("system"), "24,1,153,169,180,196,197,208,32770,32865,98306,98401,163842,163937,229378,229473,294914,295009,360480,360491,389561,390752,396945,397037,397038") == "656b63aa2bc44a7f7d7bf43bf9543f2efa3b3786" || block_image_verify(map_partition("system"), package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat")) then
ui_print("Verified system image...");
else
check_first_block(map_partition("system"));
ifelse (block_image_recover(map_partition("system"), "24,1,153,169,180,196,197,208,32770,32865,98306,98401,163842,163937,229378,229473,294914,295009,360480,360491,389561,390752,396945,397037,397038") && block_image_verify(map_partition("system"), package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat"), ui_print("system recovered successfully."), abort("E1004: system partition fails to recover"));
endif;
if (range_sha1(map_partition("vendor"), "62,1,75,612,618,635,636,657,900,1003,1005,1027,1028,3054,3055,14771,15407,16890,16902,16903,16905,16939,16990,17071,17072,17464,17465,17676,17677,17767,17914,27263,27769,27963,27964,28426,28427,29633,29647,29993,29994,30275,30939,31133,31134,32768,32770,32804,32844,49027,49109,51061,51062,53969,98306,98340,131101,131103,139062,139494,141707,141751,141752") == "34846d8a2c7977538dadd1efb5d91f9966e9063e" || block_image_verify(map_partition("vendor"), package_extract_file("vendor.transfer.list"), "vendor.new.dat", "vendor.patch.dat")) then
ui_print("Verified vendor image...");
else
check_first_block(map_partition("vendor"));
ifelse (block_image_recover(map_partition("vendor"), "62,1,75,612,618,635,636,657,900,1003,1005,1027,1028,3054,3055,14771,15407,16890,16902,16903,16905,16939,16990,17071,17072,17464,17465,17676,17677,17767,17914,27263,27769,27963,27964,28426,28427,29633,29647,29993,29994,30275,30939,31133,31134,32768,32770,32804,32844,49027,49109,51061,51062,53969,98306,98340,131101,131103,139062,139494,141707,141751,141752") && block_image_verify(map_partition("vendor"), package_extract_file("vendor.transfer.list"), "vendor.new.dat", "vendor.patch.dat"), ui_print("vendor recovered successfully."), abort("E2004: vendor partition fails to recover"));
endif;
if (range_sha1(map_partition("product"), "352,1,110,5400,5404,8920,8921,13665,13669,16029,16032,18403,18404,25978,25979,27629,27633,31435,31436,32768,32770,32864,32870,38451,38452,39987,39991,42358,42798,42806,42807,48833,48837,53149,53150,53167,53171,53175,53176,53540,53544,54051,54052,54064,54068,54072,54073,60966,60967,61368,61372,62361,62362,62386,62390,62394,62395,62825,62829,62840,62841,64225,64229,64238,64239,65536,65542,67890,67891,68448,68450,69131,69132,69139,69143,71742,71743,78908,78909,86959,86963,89303,89304,98304,98306,98400,98406,100737,100738,101368,101372,111609,111610,111616,111617,119066,119067,125174,125178,130798,130799,130805,130808,130835,130839,130843,130844,130896,130900,130905,130906,130948,130952,130956,130957,131035,131039,131045,131046,131050,131054,131058,131059,131072,131078,140822,140826,140832,140833,152040,152041,159105,159109,163840,163842,163936,163942,164963,164964,165345,165349,165359,165360,180526,180530,180534,180537,180541,180542,185942,185946,190096,190097,196608,196614,206493,206494,208761,208765,209526,209529,210295,210296,215527,215528,216770,216774,220759,220760,227143,227144,229376,229378,229472,229478,234350,234354,240108,240111,245871,245876,250032,250034,250042,250043,250044,250045,250063,250064,250065,250066,250072,250073,250111,250115,250120,250123,250128,250129,250340,250341,250433,250436,250536,250538,250541,250542,250545,250546,250549,250550,250553,250554,250557,250558,250561,250562,250565,250566,250571,250572,250577,250578,250583,250584,250607,250608,250628,250629,250635,250636,250656,250657,250673,250674,250680,250681,250698,250699,250705,250706,250725,250726,250741,250742,250747,250748,250766,250767,250773,250774,250794,250795,250811,250812,250815,250816,250819,250820,250823,250824,250827,250828,250831,250832,250835,250836,250840,250841,250845,250846,250850,250851,250858,251115,251410,251414,251424,251425,251805,251809,251819,251820,255667,255668,255986,255990,256071,256072,257390,257394,257431,257432,257456,257460,257464,257465,258997,259003,259032,259033,262144,262150,263001,263005,263089,263090,279472,279473,285921,285923,288682,288686,288732,288736,289137,289140,289545,289546,289717,289721,289728,289729,289769,289773,289778,289779,289915,289919,289927,289928,291176,291180,291209,291210,292259,292263,292272,292273,292337,292341,292345,294914,295008,327681,327686,360449,360454,386405,387571,393713,393805,393806") == "52984c63abc36a83819c139fa911df1f51ce3922" || block_image_verify(map_partition("product"), package_extract_file("product.transfer.list"), "product.new.dat", "product.patch.dat")) then
ui_print("Verified product image...");
else
ifelse (block_image_recover(map_partition("product"), "352,1,110,5400,5404,8920,8921,13665,13669,16029,16032,18403,18404,25978,25979,27629,27633,31435,31436,32768,32770,32864,32870,38451,38452,39987,39991,42358,42798,42806,42807,48833,48837,53149,53150,53167,53171,53175,53176,53540,53544,54051,54052,54064,54068,54072,54073,60966,60967,61368,61372,62361,62362,62386,62390,62394,62395,62825,62829,62840,62841,64225,64229,64238,64239,65536,65542,67890,67891,68448,68450,69131,69132,69139,69143,71742,71743,78908,78909,86959,86963,89303,89304,98304,98306,98400,98406,100737,100738,101368,101372,111609,111610,111616,111617,119066,119067,125174,125178,130798,130799,130805,130808,130835,130839,130843,130844,130896,130900,130905,130906,130948,130952,130956,130957,131035,131039,131045,131046,131050,131054,131058,131059,131072,131078,140822,140826,140832,140833,152040,152041,159105,159109,163840,163842,163936,163942,164963,164964,165345,165349,165359,165360,180526,180530,180534,180537,180541,180542,185942,185946,190096,190097,196608,196614,206493,206494,208761,208765,209526,209529,210295,210296,215527,215528,216770,216774,220759,220760,227143,227144,229376,229378,229472,229478,234350,234354,240108,240111,245871,245876,250032,250034,250042,250043,250044,250045,250063,250064,250065,250066,250072,250073,250111,250115,250120,250123,250128,250129,250340,250341,250433,250436,250536,250538,250541,250542,250545,250546,250549,250550,250553,250554,250557,250558,250561,250562,250565,250566,250571,250572,250577,250578,250583,250584,250607,250608,250628,250629,250635,250636,250656,250657,250673,250674,250680,250681,250698,250699,250705,250706,250725,250726,250741,250742,250747,250748,250766,250767,250773,250774,250794,250795,250811,250812,250815,250816,250819,250820,250823,250824,250827,250828,250831,250832,250835,250836,250840,250841,250845,250846,250850,250851,250858,251115,251410,251414,251424,251425,251805,251809,251819,251820,255667,255668,255986,255990,256071,256072,257390,257394,257431,257432,257456,257460,257464,257465,258997,259003,259032,259033,262144,262150,263001,263005,263089,263090,279472,279473,285921,285923,288682,288686,288732,288736,289137,289140,289545,289546,289717,289721,289728,289729,289769,289773,289778,289779,289915,289919,289927,289928,291176,291180,291209,291210,292259,292263,292272,292273,292337,292341,292345,294914,295008,327681,327686,360449,360454,386405,387571,393713,393805,393806") && block_image_verify(map_partition("product"), package_extract_file("product.transfer.list"), "product.new.dat", "product.patch.dat"), ui_print("product recovered successfully."), abort("E2004: product partition fails to recover"));
endif;

# ---- start making changes here ----


# --- Start patching dynamic partitions ---


# Update dynamic partition metadata

assert(update_dynamic_partitions(package_extract_file("dynamic_partitions_op_list")));

# Patch partition product

ui_print("Patching product image after verification.");
block_image_update(map_partition("product"), package_extract_file("product.transfer.list"), "product.new.dat", "product.patch.dat") ||
  abort("E2001: Failed to update product image.");

# Patch partition vendor

ui_print("Patching vendor image after verification.");
show_progress(0.100000, 0);
block_image_update(map_partition("vendor"), package_extract_file("vendor.transfer.list"), "vendor.new.dat", "vendor.patch.dat") ||
  abort("E2001: Failed to update vendor image.");

# Patch partition system

ui_print("Patching system image after verification.");
show_progress(0.800000, 0);
block_image_update(map_partition("system"), package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat") ||
  abort("E1001: Failed to update system image.");

# --- End patching dynamic partitions ---

ui_print("Patching boot image...");
show_progress(0.100000, 10);
patch_partition("EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a",
                "EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a",
                package_extract_file("boot.img.p")) ||
    abort("E3008: Failed to apply patch to EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a");
show_mtupdate_stage("/cache/recovery/last_mtupdate_stage");
ifelse (
less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "1") ,
(
ui_print("start to update general image");
package_extract_file("pi_img.img", "/dev/block/by-name/pi_img");
package_extract_file("cam_vpu3.img", "/dev/block/by-name/cam_vpu3");
package_extract_file("dtbo.img", "/dev/block/by-name/dtbo");
package_extract_file("vbmeta_system.img", "/dev/block/by-name/vbmeta_system");
package_extract_file("vbmeta_vendor.img", "/dev/block/by-name/vbmeta_vendor");
package_extract_file("cam_vpu2.img", "/dev/block/by-name/cam_vpu2");
package_extract_file("cam_vpu1.img", "/dev/block/by-name/cam_vpu1");
ui_print("Patching md1img image...");
show_progress(0.100000, 10);
patch_partition("EMMC:/dev/block/by-name/md1img:66856432:5521bd20270f93c39a09be3cbd530b9297c959b7",
                "EMMC:/dev/block/by-name/md1img:66794448:86f1fe5a143a19caf7339b05bf06f139021a4bfe",
                package_extract_file("patch/md1img.img.p")) ||
    abort("E3008: Failed to apply patch to EMMC:/dev/block/by-name/md1img:66794448:86f1fe5a143a19caf7339b05bf06f139021a4bfe");
package_extract_file("spmfw.img", "/dev/block/by-name/spmfw");
set_mtupdate_stage("/cache/recovery/last_mtupdate_stage", "1");
),
ui_print("general images are already updated");
);
ifelse (
less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "3") ,
(
if less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "2") then

ui_print("start to update alt loader image");
package_extract_file("sspm.img", "/dev/block/by-name/sspm_2");
package_extract_file("tee.img", "/dev/block/by-name/tee2");
package_extract_file("scp.img", "/dev/block/by-name/scp2");
package_extract_file("mcupm.img", "/dev/block/by-name/mcupm_2");
package_extract_file("lk.img", "/dev/block/by-name/lk2");
package_extract_file("dpm.img", "/dev/block/by-name/dpm_2");
set_mtupdate_stage("/cache/recovery/last_mtupdate_stage", "2");
endif;

switch_active("sspm_1", "sspm_2");
switch_active("tee1", "tee2");
switch_active("scp1", "scp2");
switch_active("mcupm_1", "mcupm_2");
switch_active("lk", "lk2");
switch_active("dpm_1", "dpm_2");
set_mtupdate_stage("/cache/recovery/last_mtupdate_stage", "3");
),
ui_print("alt loder images are already updated");
);
ifelse (
less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "5") ,
(
if less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "4") then

ui_print("start to update main loader image");
package_extract_file("sspm.img", "/dev/block/by-name/sspm_1");
package_extract_file("tee.img", "/dev/block/by-name/tee1");
package_extract_file("scp.img", "/dev/block/by-name/scp1");
package_extract_file("mcupm.img", "/dev/block/by-name/mcupm_1");
package_extract_file("lk.img", "/dev/block/by-name/lk");
package_extract_file("dpm.img", "/dev/block/by-name/dpm_1");
set_mtupdate_stage("/cache/recovery/last_mtupdate_stage", "4");
endif;

switch_active("sspm_2", "sspm_1");
switch_active("tee2", "tee1");
switch_active("scp2", "scp1");
switch_active("mcupm_2", "mcupm_1");
switch_active("lk2", "lk");
switch_active("dpm_2", "dpm_1");
),
ui_print("main loader images are already updated");
);
delete("/cache/recovery/last_mtupdate_stage");
package_extract_file("vbmeta.img", "/dev/block/by-name/vbmeta");
post_ota_action();
set_progress(1.000000);

and I think that the problem is here:

Code:

patch_partition_check("EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a",
                      "EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a") ||
    abort("E3005: \"EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a\" or \"EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a\" has unexpected contents.");
apply_patch_space(56631296) || abort("E3006: Not enough free space on /cache to apply patches.");

So I decide to remove that part from the script and change

Code:

ui_print("Patching boot image...");
show_progress(0.100000, 10);
patch_partition("EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a",
"EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a",
package_extract_file("boot.img.p")) ||
abort("E3008: Failed to apply patch to EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a");
show_mtupdate_stage("/cache/recovery/last_mtupdate_stage");
ifelse (
less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "1") ,

with

Code:

ui_print("Start to update boot image...");
show_progress(0.100000, 10);
package_extract_file("boot.img", "/dev/block/by-name/boot");
show_mtupdate_stage("/cache/recovery/last_mtupdate_stage");
ifelse (
less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "1") ,

Should it work?

The second problem is that the OTA package is signed with SIgnApk and so I think the recovery will not let me load my package even with adb sideload.
Is it possible to remove this check from the recovery or transfer the signature from a package to another with the help of an Hexeditor?

TIA
Harlock1978
Harlock1978
Harlock1978
Enthusiastic Member
11
12-06-2021, 01:57 PM
#2
I have an Ulefone Armor 11 5G with a Mediatek MT6873, unlocked bootloader and Magisk installed.
Now I receive the info for an OTA update, obviously it was not working, so I flashed back the original vbmeta.img and boot.img, but again it says that the partition doesn't match.
I downloaded the OTA packages and extracted the updater-script:

Code:

getprop("ro.product.device") == "Armor_11_5G" || abort("E3004: This package is for \"Armor_11_5G\" devices; this is a \"" + getprop("ro.product.device") + "\".");
ui_print("Source: Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys");
ui_print("Target: Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys");
ui_print("Verifying current system...");
getprop("ro.build.fingerprint") == "Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys" ||
    getprop("ro.build.fingerprint") == "Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys" ||
    abort("E3001: Package expects build fingerprint of Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys or Ulefone/Armor_11_5G_EEA/Armor_11_5G:10/QP1A.190711.020/1608088743:user/release-keys; this device has " + getprop("ro.build.fingerprint") + ".");
patch_partition_check("EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a",
                      "EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a") ||
    abort("E3005: \"EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a\" or \"EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a\" has unexpected contents.");
apply_patch_space(56631296) || abort("E3006: Not enough free space on /cache to apply patches.");
patch_partition_check("EMMC:/dev/block/by-name/md1img:66856432:5521bd20270f93c39a09be3cbd530b9297c959b7",
                      "EMMC:/dev/block/by-name/md1img:66794448:86f1fe5a143a19caf7339b05bf06f139021a4bfe") ||
    abort("E3005: \"EMMC:/dev/block/by-name/md1img:66856432:5521bd20270f93c39a09be3cbd530b9297c959b7\" or \"EMMC:/dev/block/by-name/md1img:66794448:86f1fe5a143a19caf7339b05bf06f139021a4bfe\" has unexpected contents.");
apply_patch_space(66856432) || abort("E3006: Not enough free space on /cache to apply patches.");
if (range_sha1(map_partition("system"), "24,1,153,169,180,196,197,208,32770,32865,98306,98401,163842,163937,229378,229473,294914,295009,360480,360491,389561,390752,396945,397037,397038") == "656b63aa2bc44a7f7d7bf43bf9543f2efa3b3786" || block_image_verify(map_partition("system"), package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat")) then
ui_print("Verified system image...");
else
check_first_block(map_partition("system"));
ifelse (block_image_recover(map_partition("system"), "24,1,153,169,180,196,197,208,32770,32865,98306,98401,163842,163937,229378,229473,294914,295009,360480,360491,389561,390752,396945,397037,397038") && block_image_verify(map_partition("system"), package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat"), ui_print("system recovered successfully."), abort("E1004: system partition fails to recover"));
endif;
if (range_sha1(map_partition("vendor"), "62,1,75,612,618,635,636,657,900,1003,1005,1027,1028,3054,3055,14771,15407,16890,16902,16903,16905,16939,16990,17071,17072,17464,17465,17676,17677,17767,17914,27263,27769,27963,27964,28426,28427,29633,29647,29993,29994,30275,30939,31133,31134,32768,32770,32804,32844,49027,49109,51061,51062,53969,98306,98340,131101,131103,139062,139494,141707,141751,141752") == "34846d8a2c7977538dadd1efb5d91f9966e9063e" || block_image_verify(map_partition("vendor"), package_extract_file("vendor.transfer.list"), "vendor.new.dat", "vendor.patch.dat")) then
ui_print("Verified vendor image...");
else
check_first_block(map_partition("vendor"));
ifelse (block_image_recover(map_partition("vendor"), "62,1,75,612,618,635,636,657,900,1003,1005,1027,1028,3054,3055,14771,15407,16890,16902,16903,16905,16939,16990,17071,17072,17464,17465,17676,17677,17767,17914,27263,27769,27963,27964,28426,28427,29633,29647,29993,29994,30275,30939,31133,31134,32768,32770,32804,32844,49027,49109,51061,51062,53969,98306,98340,131101,131103,139062,139494,141707,141751,141752") && block_image_verify(map_partition("vendor"), package_extract_file("vendor.transfer.list"), "vendor.new.dat", "vendor.patch.dat"), ui_print("vendor recovered successfully."), abort("E2004: vendor partition fails to recover"));
endif;
if (range_sha1(map_partition("product"), "352,1,110,5400,5404,8920,8921,13665,13669,16029,16032,18403,18404,25978,25979,27629,27633,31435,31436,32768,32770,32864,32870,38451,38452,39987,39991,42358,42798,42806,42807,48833,48837,53149,53150,53167,53171,53175,53176,53540,53544,54051,54052,54064,54068,54072,54073,60966,60967,61368,61372,62361,62362,62386,62390,62394,62395,62825,62829,62840,62841,64225,64229,64238,64239,65536,65542,67890,67891,68448,68450,69131,69132,69139,69143,71742,71743,78908,78909,86959,86963,89303,89304,98304,98306,98400,98406,100737,100738,101368,101372,111609,111610,111616,111617,119066,119067,125174,125178,130798,130799,130805,130808,130835,130839,130843,130844,130896,130900,130905,130906,130948,130952,130956,130957,131035,131039,131045,131046,131050,131054,131058,131059,131072,131078,140822,140826,140832,140833,152040,152041,159105,159109,163840,163842,163936,163942,164963,164964,165345,165349,165359,165360,180526,180530,180534,180537,180541,180542,185942,185946,190096,190097,196608,196614,206493,206494,208761,208765,209526,209529,210295,210296,215527,215528,216770,216774,220759,220760,227143,227144,229376,229378,229472,229478,234350,234354,240108,240111,245871,245876,250032,250034,250042,250043,250044,250045,250063,250064,250065,250066,250072,250073,250111,250115,250120,250123,250128,250129,250340,250341,250433,250436,250536,250538,250541,250542,250545,250546,250549,250550,250553,250554,250557,250558,250561,250562,250565,250566,250571,250572,250577,250578,250583,250584,250607,250608,250628,250629,250635,250636,250656,250657,250673,250674,250680,250681,250698,250699,250705,250706,250725,250726,250741,250742,250747,250748,250766,250767,250773,250774,250794,250795,250811,250812,250815,250816,250819,250820,250823,250824,250827,250828,250831,250832,250835,250836,250840,250841,250845,250846,250850,250851,250858,251115,251410,251414,251424,251425,251805,251809,251819,251820,255667,255668,255986,255990,256071,256072,257390,257394,257431,257432,257456,257460,257464,257465,258997,259003,259032,259033,262144,262150,263001,263005,263089,263090,279472,279473,285921,285923,288682,288686,288732,288736,289137,289140,289545,289546,289717,289721,289728,289729,289769,289773,289778,289779,289915,289919,289927,289928,291176,291180,291209,291210,292259,292263,292272,292273,292337,292341,292345,294914,295008,327681,327686,360449,360454,386405,387571,393713,393805,393806") == "52984c63abc36a83819c139fa911df1f51ce3922" || block_image_verify(map_partition("product"), package_extract_file("product.transfer.list"), "product.new.dat", "product.patch.dat")) then
ui_print("Verified product image...");
else
ifelse (block_image_recover(map_partition("product"), "352,1,110,5400,5404,8920,8921,13665,13669,16029,16032,18403,18404,25978,25979,27629,27633,31435,31436,32768,32770,32864,32870,38451,38452,39987,39991,42358,42798,42806,42807,48833,48837,53149,53150,53167,53171,53175,53176,53540,53544,54051,54052,54064,54068,54072,54073,60966,60967,61368,61372,62361,62362,62386,62390,62394,62395,62825,62829,62840,62841,64225,64229,64238,64239,65536,65542,67890,67891,68448,68450,69131,69132,69139,69143,71742,71743,78908,78909,86959,86963,89303,89304,98304,98306,98400,98406,100737,100738,101368,101372,111609,111610,111616,111617,119066,119067,125174,125178,130798,130799,130805,130808,130835,130839,130843,130844,130896,130900,130905,130906,130948,130952,130956,130957,131035,131039,131045,131046,131050,131054,131058,131059,131072,131078,140822,140826,140832,140833,152040,152041,159105,159109,163840,163842,163936,163942,164963,164964,165345,165349,165359,165360,180526,180530,180534,180537,180541,180542,185942,185946,190096,190097,196608,196614,206493,206494,208761,208765,209526,209529,210295,210296,215527,215528,216770,216774,220759,220760,227143,227144,229376,229378,229472,229478,234350,234354,240108,240111,245871,245876,250032,250034,250042,250043,250044,250045,250063,250064,250065,250066,250072,250073,250111,250115,250120,250123,250128,250129,250340,250341,250433,250436,250536,250538,250541,250542,250545,250546,250549,250550,250553,250554,250557,250558,250561,250562,250565,250566,250571,250572,250577,250578,250583,250584,250607,250608,250628,250629,250635,250636,250656,250657,250673,250674,250680,250681,250698,250699,250705,250706,250725,250726,250741,250742,250747,250748,250766,250767,250773,250774,250794,250795,250811,250812,250815,250816,250819,250820,250823,250824,250827,250828,250831,250832,250835,250836,250840,250841,250845,250846,250850,250851,250858,251115,251410,251414,251424,251425,251805,251809,251819,251820,255667,255668,255986,255990,256071,256072,257390,257394,257431,257432,257456,257460,257464,257465,258997,259003,259032,259033,262144,262150,263001,263005,263089,263090,279472,279473,285921,285923,288682,288686,288732,288736,289137,289140,289545,289546,289717,289721,289728,289729,289769,289773,289778,289779,289915,289919,289927,289928,291176,291180,291209,291210,292259,292263,292272,292273,292337,292341,292345,294914,295008,327681,327686,360449,360454,386405,387571,393713,393805,393806") && block_image_verify(map_partition("product"), package_extract_file("product.transfer.list"), "product.new.dat", "product.patch.dat"), ui_print("product recovered successfully."), abort("E2004: product partition fails to recover"));
endif;

# ---- start making changes here ----


# --- Start patching dynamic partitions ---


# Update dynamic partition metadata

assert(update_dynamic_partitions(package_extract_file("dynamic_partitions_op_list")));

# Patch partition product

ui_print("Patching product image after verification.");
block_image_update(map_partition("product"), package_extract_file("product.transfer.list"), "product.new.dat", "product.patch.dat") ||
  abort("E2001: Failed to update product image.");

# Patch partition vendor

ui_print("Patching vendor image after verification.");
show_progress(0.100000, 0);
block_image_update(map_partition("vendor"), package_extract_file("vendor.transfer.list"), "vendor.new.dat", "vendor.patch.dat") ||
  abort("E2001: Failed to update vendor image.");

# Patch partition system

ui_print("Patching system image after verification.");
show_progress(0.800000, 0);
block_image_update(map_partition("system"), package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat") ||
  abort("E1001: Failed to update system image.");

# --- End patching dynamic partitions ---

ui_print("Patching boot image...");
show_progress(0.100000, 10);
patch_partition("EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a",
                "EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a",
                package_extract_file("boot.img.p")) ||
    abort("E3008: Failed to apply patch to EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a");
show_mtupdate_stage("/cache/recovery/last_mtupdate_stage");
ifelse (
less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "1") ,
(
ui_print("start to update general image");
package_extract_file("pi_img.img", "/dev/block/by-name/pi_img");
package_extract_file("cam_vpu3.img", "/dev/block/by-name/cam_vpu3");
package_extract_file("dtbo.img", "/dev/block/by-name/dtbo");
package_extract_file("vbmeta_system.img", "/dev/block/by-name/vbmeta_system");
package_extract_file("vbmeta_vendor.img", "/dev/block/by-name/vbmeta_vendor");
package_extract_file("cam_vpu2.img", "/dev/block/by-name/cam_vpu2");
package_extract_file("cam_vpu1.img", "/dev/block/by-name/cam_vpu1");
ui_print("Patching md1img image...");
show_progress(0.100000, 10);
patch_partition("EMMC:/dev/block/by-name/md1img:66856432:5521bd20270f93c39a09be3cbd530b9297c959b7",
                "EMMC:/dev/block/by-name/md1img:66794448:86f1fe5a143a19caf7339b05bf06f139021a4bfe",
                package_extract_file("patch/md1img.img.p")) ||
    abort("E3008: Failed to apply patch to EMMC:/dev/block/by-name/md1img:66794448:86f1fe5a143a19caf7339b05bf06f139021a4bfe");
package_extract_file("spmfw.img", "/dev/block/by-name/spmfw");
set_mtupdate_stage("/cache/recovery/last_mtupdate_stage", "1");
),
ui_print("general images are already updated");
);
ifelse (
less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "3") ,
(
if less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "2") then

ui_print("start to update alt loader image");
package_extract_file("sspm.img", "/dev/block/by-name/sspm_2");
package_extract_file("tee.img", "/dev/block/by-name/tee2");
package_extract_file("scp.img", "/dev/block/by-name/scp2");
package_extract_file("mcupm.img", "/dev/block/by-name/mcupm_2");
package_extract_file("lk.img", "/dev/block/by-name/lk2");
package_extract_file("dpm.img", "/dev/block/by-name/dpm_2");
set_mtupdate_stage("/cache/recovery/last_mtupdate_stage", "2");
endif;

switch_active("sspm_1", "sspm_2");
switch_active("tee1", "tee2");
switch_active("scp1", "scp2");
switch_active("mcupm_1", "mcupm_2");
switch_active("lk", "lk2");
switch_active("dpm_1", "dpm_2");
set_mtupdate_stage("/cache/recovery/last_mtupdate_stage", "3");
),
ui_print("alt loder images are already updated");
);
ifelse (
less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "5") ,
(
if less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "4") then

ui_print("start to update main loader image");
package_extract_file("sspm.img", "/dev/block/by-name/sspm_1");
package_extract_file("tee.img", "/dev/block/by-name/tee1");
package_extract_file("scp.img", "/dev/block/by-name/scp1");
package_extract_file("mcupm.img", "/dev/block/by-name/mcupm_1");
package_extract_file("lk.img", "/dev/block/by-name/lk");
package_extract_file("dpm.img", "/dev/block/by-name/dpm_1");
set_mtupdate_stage("/cache/recovery/last_mtupdate_stage", "4");
endif;

switch_active("sspm_2", "sspm_1");
switch_active("tee2", "tee1");
switch_active("scp2", "scp1");
switch_active("mcupm_2", "mcupm_1");
switch_active("lk2", "lk");
switch_active("dpm_2", "dpm_1");
),
ui_print("main loader images are already updated");
);
delete("/cache/recovery/last_mtupdate_stage");
package_extract_file("vbmeta.img", "/dev/block/by-name/vbmeta");
post_ota_action();
set_progress(1.000000);

and I think that the problem is here:

Code:

patch_partition_check("EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a",
                      "EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a") ||
    abort("E3005: \"EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a\" or \"EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a\" has unexpected contents.");
apply_patch_space(56631296) || abort("E3006: Not enough free space on /cache to apply patches.");

So I decide to remove that part from the script and change

Code:

ui_print("Patching boot image...");
show_progress(0.100000, 10);
patch_partition("EMMC:/dev/block/by-name/boot:33554432:223ec34e2968174b6d3da29dac6f8a0bfcca5d0a",
"EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a",
package_extract_file("boot.img.p")) ||
abort("E3008: Failed to apply patch to EMMC:/dev/block/by-name/boot:33554432:4cecdfac1f170168f75e6d211bf6183bccc2c87a");
show_mtupdate_stage("/cache/recovery/last_mtupdate_stage");
ifelse (
less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "1") ,

with

Code:

ui_print("Start to update boot image...");
show_progress(0.100000, 10);
package_extract_file("boot.img", "/dev/block/by-name/boot");
show_mtupdate_stage("/cache/recovery/last_mtupdate_stage");
ifelse (
less_than_int(get_mtupdate_stage("/cache/recovery/last_mtupdate_stage"), "1") ,

Should it work?

The second problem is that the OTA package is signed with SIgnApk and so I think the recovery will not let me load my package even with adb sideload.
Is it possible to remove this check from the recovery or transfer the signature from a package to another with the help of an Hexeditor?

TIA
maxpayne
maxpayne
maxpayne
Contributor
2,873
14-06-2021, 07:39 AM
#3
(12-06-2021, 11:24 AM)Harlock1978 ....
Should it work?

The second problem is that the OTA package is signed with SIgnApk and so I think the recovery will not let me load my package even with adb sideload.
Is it possible to remove this check from the recovery or transfer the signature from a package to another with the help of an Hexeditor?

TIA

So far you're flashing the ota using stock recovery, any change you make would most likely cause it to fail unless you have the signing key they used. Maybe TWRP could
This post was last modified: 14-06-2021, 07:42 AM by maxpayne.
Users browsing this thread:
 1 Guest(s)
Users browsing this thread:
 1 Guest(s)
YtWhTl
live chat
whatsapp telegram instagram