[read_info] Fix search partition by name

pull/24/head
remittor 1 year ago
parent a6821fa262
commit b721ff7daf

@ -39,7 +39,7 @@ if len(sys.argv) > 1:
if p < 0 or p >= len(dev.partlist):
die('Partition "mtd{}" not found!'.format(a_part))
else:
p = dev.get_part_num(a_part, comptype = 'ends')
p = dev.get_part_num(a_part)
if p < 0:
die('Partition "{}" not found!'.format(a_part))
name = dev.partlist[p]['name']

@ -197,22 +197,27 @@ class DevInfo():
def get_part_num(self, name_or_addr, comptype = None):
if not self.partlist:
return -2
for i, part in enumerate(self.partlist):
if isinstance(name_or_addr, int):
if isinstance(name_or_addr, int):
addr = name_or_addr
for i, part in enumerate(self.partlist):
if part['addr'] == 0 and part['size'] > 0x00800000:
continue # skip "ALL" part
addr = name_or_addr
if comptype and comptype == '#': # range
if addr >= part['addr'] and addr < part['addr'] + part['size']:
return i
else:
if addr == part['addr']:
return i
else:
if isinstance(name_or_addr, str):
name = name_or_addr.lower()
for i, part in enumerate(self.partlist):
partname = part['name'].lower()
if len(partname) > 2 and partname[1:2] == ':':
partname = partname[2:]
if comptype and comptype[0] == 'e': # endswith
if part['name'].lower().endswith(name_or_addr.lower()):
if partname.endswith(name):
return i
if part['name'].lower() == name_or_addr.lower():
elif partname == name:
return i
return -1
@ -534,7 +539,8 @@ class DevInfo():
ret = self.bl
if verbose:
print("Bootloader info:")
plst = self.get_part_list(['bootloader', 'uboot', 'SBL1', 'APPSBL', 'SBL2', 'SBL3'], comptype = 'ends')
blist = ['bootloader', 'uboot', 'SBL1', 'APPSBL', 'SBL2', 'SBL3', 'BL2', 'FIP']
plst = self.get_part_list(blist)
if not plst:
return ret
for i, p in enumerate(plst):
@ -611,7 +617,8 @@ class DevInfo():
ret = self.env.fw
if verbose:
print("ENV info:")
plst = self.get_part_list(['config', 'nvram', 'APPSBLENV', 'bdata'], comptype = 'ends')
envlist = ['config', 'nvram', 'APPSBLENV', 'bdata']
plst = self.get_part_list(envlist)
if not plst:
return ret
env_breed_addr = 0x60000 # breed env addr for r3g

Loading…
Cancel
Save