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.
@@ -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)
