fix resize for FS >16MB (#19880)

This commit is contained in:
Jason2866 2023-10-30 18:07:24 +01:00 committed by GitHub
parent 444f4fcd62
commit fdef240ea4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -113,9 +113,12 @@ def patch_partitions_bin(size_string):
binary_data = file.read(0xb0)
import hashlib
bin_list = list(binary_data)
size = codecs.decode(size_string[2:], 'hex_codec') # 0xc50000 -> [c5,00,00]
bin_list[0x8a] = size[0]
bin_list[0x8b] = size[1]
size_string = int(size_string[2:],16)
size_string = f"{size_string:08X}"
size = codecs.decode(size_string, 'hex_codec') # 0xc50000 -> [00,c5,00,00]
bin_list[0x89] = size[2]
bin_list[0x8a] = size[1]
bin_list[0x8b] = size[0]
result = hashlib.md5(bytes(bin_list[0:0xa0]))
partition_data = bytes(bin_list) + result.digest()
file.seek(0)