bkerler / mtkclient

MTK reverse engineering and flash tool
GNU General Public License v3.0
2.7k stars 528 forks source link

[question] recreate stock partition table #630

Closed sss123next closed 3 months ago

sss123next commented 1 year ago

is it possible to recreate stock partition table via mtkclient ? for some reason sp flash tools do not want work with my device, but mtkclient works

i am stuck in situation where i can't do anything inside super partition, but super partition is visible and readable by system....

i mean, i can flash super.img and system is working, but i cant write to any partitions inside super partition. so i guess something is wrong with partition position and/or flags.

stock firmware does have scatter file with some information about partition table which probably can be used to recreate partition table....

fastboot getvar all
(bootloader) cpu-abi:arm64-v8a
(bootloader) snapshot-update-status:none
(bootloader) super-partition-name:super
(bootloader) is-logical:preloader_raw_b:no
(bootloader) is-logical:preloader_raw_a:no
(bootloader) is-logical:preloader_ufs_b:no
(bootloader) is-logical:preloader_ufs_a:no
(bootloader) is-logical:preloader_emmc_b:no
(bootloader) is-logical:preloader_emmc_a:no
(bootloader) is-logical:sda:no
(bootloader) is-logical:lk_a:no
(bootloader) is-logical:md_udc:no
(bootloader) is-logical:tee_b:no
(bootloader) is-logical:cam_vpu2_a:no
(bootloader) is-logical:boot_para:no
(bootloader) is-logical:ffu:no
(bootloader) is-logical:boot_b:no
(bootloader) is-logical:frp:no
(bootloader) is-logical:protect1:no
(bootloader) is-logical:para:no
(bootloader) is-logical:spmfw_a:no
(bootloader) is-logical:boot_a:no
(bootloader) is-logical:lk_b:no
(bootloader) is-logical:expdb:no
(bootloader) is-logical:otp:no
(bootloader) is-logical:tee_a:no
(bootloader) is-logical:dtbo_b:no
(bootloader) is-logical:blk1:no
(bootloader) is-logical:vendor_boot_a:no
(bootloader) is-logical:spmfw_b:no
(bootloader) is-logical:sspm_b:no
(bootloader) is-logical:protect2:no
(bootloader) is-logical:nvdata:no
(bootloader) is-logical:metadata:no
(bootloader) is-logical:scp_b:no
(bootloader) is-logical:seccfg:no
(bootloader) is-logical:persist:no
(bootloader) is-logical:cam_vpu2_b:no
(bootloader) is-logical:misc:no
(bootloader) is-logical:super:no
(bootloader) is-logical:gsort:no
(bootloader) is-logical:cam_vpu3_a:no
(bootloader) is-logical:md1img_a:no
(bootloader) is-logical:flashinfo:no
(bootloader) is-logical:gz_a:no
(bootloader) is-logical:audio_dsp_b:no
(bootloader) is-logical:vbmeta_system_b:no
(bootloader) is-logical:logo:no
(bootloader) is-logical:sdb:no
(bootloader) is-logical:dtbo_a:no
(bootloader) is-logical:scp_a:no
(bootloader) is-logical:vendor_boot_b:no
(bootloader) is-logical:vbmeta_vendor_b:no
(bootloader) is-logical:md1img_b:no
(bootloader) is-logical:cam_vpu1_b:no
(bootloader) is-logical:sec1:no
(bootloader) is-logical:sspm_a:no
(bootloader) is-logical:vbmeta_system_a:no
(bootloader) is-logical:efuse:no
(bootloader) is-logical:vbmeta_a:no
(bootloader) is-logical:nvcfg:no
(bootloader) is-logical:gz_b:no
(bootloader) is-logical:vbmeta_b:no
(bootloader) is-logical:rescue:no
(bootloader) is-logical:sdc:no
(bootloader) is-logical:audio_dsp_a:no
(bootloader) is-logical:cust:no
(bootloader) is-logical:cam_vpu3_b:no
(bootloader) is-logical:proinfo:no
(bootloader) is-logical:cam_vpu1_a:no
(bootloader) is-logical:countrycode:no
(bootloader) is-logical:userdata:no
(bootloader) is-logical:vbmeta_vendor_a:no
(bootloader) is-logical:nvram:no
(bootloader) is-logical:product_a:yes
(bootloader) is-logical:product_b:yes
(bootloader) is-logical:system_a:yes
(bootloader) is-logical:system_b:yes
(bootloader) is-logical:vendor_a:yes
(bootloader) is-logical:vendor_b:yes
(bootloader) battery-voltage:4428
(bootloader) treble-enabled:true
(bootloader) is-userspace:yes
(bootloader) max-fetch-size:0x10000000
(bootloader) partition-size:preloader_raw_b:0x3FF000
(bootloader) partition-size:preloader_raw_a:0x3FF000
(bootloader) partition-size:lk_a:0x400000
(bootloader) partition-size:md_udc:0x169A000
(bootloader) partition-size:tee_b:0x500000
(bootloader) partition-size:cam_vpu2_a:0xF00000
(bootloader) partition-size:boot_para:0x1A00000
(bootloader) partition-size:ffu:0x800000
(bootloader) partition-size:boot_b:0x4000000
(bootloader) partition-size:frp:0x100000
(bootloader) partition-size:protect1:0x800000
(bootloader) partition-size:para:0x80000
(bootloader) partition-size:spmfw_a:0x100000
(bootloader) partition-size:boot_a:0x4000000
(bootloader) partition-size:lk_b:0x400000
(bootloader) partition-size:expdb:0x1400000
(bootloader) partition-size:otp:0x3000000
(bootloader) partition-size:tee_a:0x500000
(bootloader) partition-size:dtbo_b:0x800000
(bootloader) partition-size:blk1:0x800000
(bootloader) partition-size:vendor_boot_a:0x4000000
(bootloader) partition-size:spmfw_b:0x100000
(bootloader) partition-size:sspm_b:0x100000
(bootloader) partition-size:protect2:0x800000
(bootloader) partition-size:nvdata:0x4000000
(bootloader) partition-size:metadata:0x2000000
(bootloader) partition-size:scp_b:0x600000
(bootloader) partition-size:seccfg:0x800000
(bootloader) partition-size:persist:0x315E000
(bootloader) partition-size:cam_vpu2_b:0xF00000
(bootloader) partition-size:misc:0x80000
(bootloader) partition-size:super:0x206D00000
(bootloader) partition-size:gsort:0x1000000
(bootloader) partition-size:cam_vpu3_a:0xF00000
(bootloader) partition-size:md1img_a:0x9600000
(bootloader) partition-size:flashinfo:0x1000000
(bootloader) partition-size:gz_a:0x2000000
(bootloader) partition-size:audio_dsp_b:0x400000
(bootloader) partition-size:vbmeta_system_b:0x800000
(bootloader) partition-size:logo:0x880000
(bootloader) partition-size:dtbo_a:0x800000
(bootloader) partition-size:scp_a:0x600000
(bootloader) partition-size:vendor_boot_b:0x4000000
(bootloader) partition-size:vbmeta_vendor_b:0x800000
(bootloader) partition-size:md1img_b:0x9600000
(bootloader) partition-size:cam_vpu1_b:0xF00000
(bootloader) partition-size:sec1:0x200000
(bootloader) partition-size:sspm_a:0x100000
(bootloader) partition-size:vbmeta_system_a:0x800000
(bootloader) partition-size:efuse:0x80000
(bootloader) partition-size:vbmeta_a:0x800000
(bootloader) partition-size:nvcfg:0x2000000
(bootloader) partition-size:gz_b:0x2000000
(bootloader) partition-size:vbmeta_b:0x800000
(bootloader) partition-size:rescue:0x8000000
(bootloader) partition-size:sdc:0x1DCB000000
(bootloader) partition-size:audio_dsp_a:0x400000
(bootloader) partition-size:cust:0x40000000
(bootloader) partition-size:cam_vpu3_b:0xF00000
(bootloader) partition-size:proinfo:0x300000
(bootloader) partition-size:cam_vpu1_a:0xF00000
(bootloader) partition-size:countrycode:0x200000
(bootloader) partition-size:userdata:0x1B1B800000
(bootloader) partition-size:vbmeta_vendor_a:0x800000
(bootloader) partition-size:nvram:0x4000000
(bootloader) partition-size:product_a:0x6D0E0000
(bootloader) partition-size:product_b:0x0
(bootloader) partition-size:system_a:0xE54CF000
(bootloader) partition-size:system_b:0x3024A000
(bootloader) partition-size:vendor_a:0x6109F000
(bootloader) partition-size:vendor_b:0x0
(bootloader) version-vndk:32
(bootloader) partition-type:preloader_raw_b:raw
(bootloader) partition-type:preloader_raw_a:raw
(bootloader) partition-type:preloader_ufs_b:raw
(bootloader) partition-type:preloader_ufs_a:raw
(bootloader) partition-type:preloader_emmc_b:raw
(bootloader) partition-type:preloader_emmc_a:raw
(bootloader) partition-type:sda:raw
(bootloader) partition-type:lk_a:raw
(bootloader) partition-type:md_udc:raw
(bootloader) partition-type:tee_b:raw
(bootloader) partition-type:cam_vpu2_a:raw
(bootloader) partition-type:boot_para:raw
(bootloader) partition-type:ffu:raw
(bootloader) partition-type:boot_b:raw
(bootloader) partition-type:frp:raw
(bootloader) partition-type:protect1:raw
(bootloader) partition-type:para:raw
(bootloader) partition-type:spmfw_a:raw
(bootloader) partition-type:boot_a:raw
(bootloader) partition-type:lk_b:raw
(bootloader) partition-type:expdb:raw
(bootloader) partition-type:otp:raw
(bootloader) partition-type:tee_a:raw
(bootloader) partition-type:dtbo_b:raw
(bootloader) partition-type:blk1:raw
(bootloader) partition-type:vendor_boot_a:raw
(bootloader) partition-type:spmfw_b:raw
(bootloader) partition-type:sspm_b:raw
(bootloader) partition-type:protect2:raw
(bootloader) partition-type:nvdata:raw
(bootloader) partition-type:metadata:raw
(bootloader) partition-type:scp_b:raw
(bootloader) partition-type:seccfg:raw
(bootloader) partition-type:persist:raw
(bootloader) partition-type:cam_vpu2_b:raw
(bootloader) partition-type:misc:raw
(bootloader) partition-type:super:raw
(bootloader) partition-type:gsort:raw
(bootloader) partition-type:cam_vpu3_a:raw
(bootloader) partition-type:md1img_a:raw
(bootloader) partition-type:flashinfo:raw
(bootloader) partition-type:gz_a:raw
(bootloader) partition-type:audio_dsp_b:raw
(bootloader) partition-type:vbmeta_system_b:raw
(bootloader) partition-type:logo:raw
(bootloader) partition-type:sdb:raw
(bootloader) partition-type:dtbo_a:raw
(bootloader) partition-type:scp_a:raw
(bootloader) partition-type:vendor_boot_b:raw
(bootloader) partition-type:vbmeta_vendor_b:raw
(bootloader) partition-type:md1img_b:raw
(bootloader) partition-type:cam_vpu1_b:raw
(bootloader) partition-type:sec1:raw
(bootloader) partition-type:sspm_a:raw
(bootloader) partition-type:vbmeta_system_a:raw
(bootloader) partition-type:efuse:raw
(bootloader) partition-type:vbmeta_a:raw
(bootloader) partition-type:nvcfg:raw
(bootloader) partition-type:gz_b:raw
(bootloader) partition-type:vbmeta_b:raw
(bootloader) partition-type:rescue:raw
(bootloader) partition-type:sdc:raw
(bootloader) partition-type:audio_dsp_a:raw
(bootloader) partition-type:cust:raw
(bootloader) partition-type:cam_vpu3_b:raw
(bootloader) partition-type:proinfo:raw
(bootloader) partition-type:cam_vpu1_a:raw
(bootloader) partition-type:countrycode:raw
(bootloader) partition-type:userdata:raw
(bootloader) partition-type:vbmeta_vendor_a:raw
(bootloader) partition-type:nvram:raw
(bootloader) partition-type:product_a:raw
(bootloader) partition-type:product_b:raw
(bootloader) partition-type:system_a:raw
(bootloader) partition-type:system_b:raw
(bootloader) partition-type:vendor_a:raw
(bootloader) partition-type:vendor_b:raw
(bootloader) has-slot:preloader_raw:yes
(bootloader) has-slot:preloader_ufs:yes
(bootloader) has-slot:preloader_emmc:yes
(bootloader) has-slot:sda:no
(bootloader) has-slot:lk:yes
(bootloader) has-slot:md_udc:no
(bootloader) has-slot:tee:yes
(bootloader) has-slot:cam_vpu2:yes
(bootloader) has-slot:boot_para:no
(bootloader) has-slot:ffu:no
(bootloader) has-slot:boot:yes
(bootloader) has-slot:frp:no
(bootloader) has-slot:protect1:no
(bootloader) has-slot:para:no
(bootloader) has-slot:spmfw:yes
(bootloader) has-slot:expdb:no
(bootloader) has-slot:otp:no
(bootloader) has-slot:dtbo:yes
(bootloader) has-slot:blk1:no
(bootloader) has-slot:vendor_boot:yes
(bootloader) has-slot:sspm:yes
(bootloader) has-slot:protect2:no
(bootloader) has-slot:nvdata:no
(bootloader) has-slot:metadata:no
(bootloader) has-slot:scp:yes
(bootloader) has-slot:seccfg:no
(bootloader) has-slot:persist:no
(bootloader) has-slot:misc:no
(bootloader) has-slot:super:no
(bootloader) has-slot:gsort:no
(bootloader) has-slot:cam_vpu3:yes
(bootloader) has-slot:md1img:yes
(bootloader) has-slot:flashinfo:no
(bootloader) has-slot:gz:yes
(bootloader) has-slot:audio_dsp:yes
(bootloader) has-slot:vbmeta_system:yes
(bootloader) has-slot:logo:no
(bootloader) has-slot:sdb:no
(bootloader) has-slot:vbmeta_vendor:yes
(bootloader) has-slot:cam_vpu1:yes
(bootloader) has-slot:sec1:no
(bootloader) has-slot:efuse:no
(bootloader) has-slot:vbmeta:yes
(bootloader) has-slot:nvcfg:no
(bootloader) has-slot:rescue:no
(bootloader) has-slot:sdc:no
(bootloader) has-slot:cust:no
(bootloader) has-slot:proinfo:no
(bootloader) has-slot:countrycode:no
(bootloader) has-slot:userdata:no
(bootloader) has-slot:nvram:no
(bootloader) has-slot:product:yes
(bootloader) has-slot:system:yes
(bootloader) has-slot:vendor:yes
(bootloader) security-patch-level:2099-12-31
(bootloader) vendor-fingerprint:Redmi/fox_rosemary/rosemary:99.87.36/SP2A.220405.004/root10251600:eng/test-keys
(bootloader) hw-revision:0
(bootloader) current-slot:b
(bootloader) product:rosemary
(bootloader) version-os:99.87.36
(bootloader) first-api-level:30
(bootloader) slot-count:2
(bootloader) max-download-size:0x10000000
(bootloader) version:0.4
(bootloader) version-baseband:
(bootloader) secure:no
(bootloader) dynamic-partition:true
(bootloader) system-fingerprint:Redmi/fox_rosemary/rosemary:99.87.36/SP2A.220405.004/root10251600:eng/test-keys
(bootloader) version-bootloader:unknown
(bootloader) unlocked:yes
all: 
Finished. Total time: 0.554s
fastboot delete-logical-partition product
Deleting 'product'                                 FAILED (remote: 'Failed to write partition table')
fastboot: error: Command failed
astboot flash system_a TrebleDroid-A13-20230105-treble_arm64_bvN
Invalid sparse file format at header magic
Resizing 'system_a'                                FAILED (remote: 'Failed to write partition table')
fastboot: error: Command failed

but:

fastboot flash super super.img
Sending sparse 'super' 1/31 (261412 KB)            OKAY [ 20.108s]
Writing 'super'                                    OKAY [  1.094s]
Sending sparse 'super' 2/31 (261495 KB)            OKAY [ 28.334s]
Writing 'super'                                    OKAY [  1.137s]
Sending sparse 'super' 3/31 (262133 KB)            OKAY [ 13.695s]
Writing 'super'                                    OKAY [  1.096s]
Sending sparse 'super' 4/31 (260397 KB)            OKAY [ 13.912s]
Writing 'super'                                    OKAY [  1.125s]
Sending sparse 'super' 5/31 (260927 KB)            OKAY [ 15.611s]
Writing 'super'                                    OKAY [  1.016s]
Sending sparse 'super' 6/31 (261594 KB)            OKAY [ 12.314s]
Writing 'super'                                    OKAY [  1.090s]
Sending sparse 'super' 7/31 (235039 KB)            OKAY [  8.581s]
Writing 'super'                                    OKAY [  1.060s]
Sending sparse 'super' 8/31 (240032 KB)            OKAY [ 12.916s]
Writing 'super'                                    OKAY [  1.061s]
Sending sparse 'super' 9/31 (251521 KB)            OKAY [ 24.343s]
Writing 'super'                                    OKAY [  1.046s]
Sending sparse 'super' 10/31 (261562 KB)           OKAY [ 21.422s]
Writing 'super'                                    OKAY [  1.073s]
Sending sparse 'super' 11/31 (262072 KB)           OKAY [ 18.726s]
Writing 'super'                                    OKAY [  1.131s]
Sending sparse 'super' 12/31 (260456 KB)           OKAY [ 14.660s]
Writing 'super'                                    OKAY [  1.140s]
Sending sparse 'super' 13/31 (255832 KB)           OKAY [ 13.703s]
Writing 'super'                                    OKAY [  1.092s]
Sending sparse 'super' 14/31 (261996 KB)           OKAY [ 10.599s]
Writing 'super'                                    OKAY [  1.160s]
Sending sparse 'super' 15/31 (261604 KB)           OKAY [ 11.179s]
Writing 'super'                                    OKAY [  1.062s]
Sending sparse 'super' 16/31 (262096 KB)           OKAY [ 15.375s]
Writing 'super'                                    OKAY [  1.138s]
Sending sparse 'super' 17/31 (261817 KB)           OKAY [ 18.533s]
Writing 'super'                                    OKAY [  1.075s]
Sending sparse 'super' 18/31 (260455 KB)           OKAY [ 14.259s]
Writing 'super'                                    OKAY [  1.097s]
Sending sparse 'super' 19/31 (259920 KB)           OKAY [ 17.185s]
Writing 'super'                                    OKAY [  1.105s]
Sending sparse 'super' 20/31 (262060 KB)           OKAY [ 25.223s]
Writing 'super'                                    OKAY [  1.091s]
Sending sparse 'super' 21/31 (255459 KB)           OKAY [ 11.430s]
Writing 'super'                                    OKAY [  1.142s]
Sending sparse 'super' 22/31 (258705 KB)           OKAY [ 12.735s]
Writing 'super'                                    OKAY [  1.155s]
Sending sparse 'super' 23/31 (253121 KB)           OKAY [  9.441s]
Writing 'super'                                    OKAY [  1.047s]
Sending sparse 'super' 24/31 (247357 KB)           OKAY [ 11.475s]
Writing 'super'                                    OKAY [  1.057s]
Sending sparse 'super' 25/31 (229896 KB)           OKAY [ 10.453s]
Writing 'super'                                    OKAY [  0.927s]
Sending sparse 'super' 26/31 (262128 KB)           OKAY [ 12.468s]
Writing 'super'                                    OKAY [  1.091s]
Sending sparse 'super' 27/31 (262128 KB)           OKAY [ 12.554s]
Writing 'super'                                    OKAY [  1.147s]
Sending sparse 'super' 28/31 (262137 KB)           OKAY [ 12.300s]
Writing 'super'                                    OKAY [  1.080s]
Sending sparse 'super' 29/31 (260625 KB)           OKAY [ 11.909s]
Writing 'super'                                    OKAY [  1.123s]
Sending sparse 'super' 30/31 (262000 KB)           OKAY [  7.745s]
Writing 'super'                                    OKAY [  1.139s]
Sending sparse 'super' 31/31 (142616 KB)           OKAY [  4.542s]
Writing 'super'                                    OKAY [  0.661s]
Finished. Total time: 523.939s
github-actions[bot] commented 3 months ago

Stale issue message