tools/pydfu.py: Add support for multiple memory segments.

Segments are separated by / and begin with the memory address.  This
follows how the ST DFU tool works.
pull/3877/merge
Damien George 2018-06-22 15:32:32 +10:00
rodzic ec7982ec6d
commit 92667dc2e5
1 zmienionych plików z 18 dodań i 17 usunięć

Wyświetl plik

@ -394,10 +394,11 @@ def get_memory_layout(device):
intf = cfg[(0, 0)]
mem_layout_str = get_string(device, intf.iInterface)
mem_layout = mem_layout_str.split('/')
addr = int(mem_layout[1], 0)
segments = mem_layout[2].split(',')
seg_re = re.compile(r'(\d+)\*(\d+)(.)(.)')
result = []
for mem_layout_index in range(1, len(mem_layout), 2):
addr = int(mem_layout[mem_layout_index], 0)
segments = mem_layout[mem_layout_index + 1].split(',')
seg_re = re.compile(r'(\d+)\*(\d+)(.)(.)')
for segment in segments:
seg_match = seg_re.match(segment)
num_pages = int(seg_match.groups()[0], 10)