change memory regions from dict to array

This commit is contained in:
Dario Nieuwenhuis 2022-02-07 20:17:33 +01:00
parent 00fc25453d
commit 32b5a815c6

View File

@ -764,16 +764,12 @@ def parse_chips():
for chip_name in group['chip_names']: for chip_name in group['chip_names']:
chip = chips[chip_name] chip = chips[chip_name]
flash = { flash_total = int(chip['flash']) * 1024
'bytes': int(chip['flash']) * 1024, ram_total = int(chip['ram']) * 1024
'regions': {},
}
ram = {
'bytes': int(chip['ram']) * 1024,
'regions': {},
}
found = [] memory_regions = []
found = set()
for each in memories_map['flash']: for each in memories_map['flash']:
if each + '_BASE' in h['defines']['all']: if each + '_BASE' in h['defines']['all']:
if each == 'FLASH': if each == 'FLASH':
@ -787,17 +783,21 @@ def parse_chips():
if key in found: if key in found:
continue continue
found.append(key) found.add(key)
flash['regions'][key] = {
'base': h['defines']['all'][each + '_BASE'] size = 0
}
if key == 'BANK_1' or key == 'BANK_2': if key == 'BANK_1' or key == 'BANK_2':
flash_size = memory.determine_flash_size(chip_name) if size2 := memory.determine_flash_size(chip_name):
if flash_size is not None: size = min(size2, flash_total)
if flash_size > flash['bytes']:
flash_size = flash['bytes'] memory_regions.append({
flash['regions'][key]['bytes'] = flash_size 'name': key,
found = [] 'kind': 'flash',
'address': h['defines']['all'][each + '_BASE'],
'size': size,
})
found = set()
for each in memories_map['ram']: for each in memories_map['ram']:
if each + '_BASE' in h['defines']['all']: if each + '_BASE' in h['defines']['all']:
if each == 'D1_AXISRAM': if each == 'D1_AXISRAM':
@ -806,16 +806,22 @@ def parse_chips():
key = 'SRAM' key = 'SRAM'
else: else:
key = each key = each
if key in found: if key in found:
continue continue
found.append(key) found.add(key)
ram['regions'][key] = {
'base': h['defines']['all'][each + '_BASE'] size = 0
}
if key == 'SRAM': if key == 'SRAM':
ram_size = memory.determine_ram_size(chip_name) if size2 := memory.determine_ram_size(chip_name):
if ram_size is not None: size = min(size2, ram_total)
ram['regions'][key]['bytes'] = ram_size
memory_regions.append({
'name': key,
'kind': 'ram',
'address': h['defines']['all'][each + '_BASE'],
'size': size,
})
docs = documents_for(chip_name) docs = documents_for(chip_name)
@ -828,8 +834,7 @@ def parse_chips():
'die': group['die'], 'die': group['die'],
'device_id': device_id, 'device_id': device_id,
'packages': chip['packages'], 'packages': chip['packages'],
'flash': flash, 'memory': memory_regions,
'ram': ram,
'docs': docs, 'docs': docs,
'cores': cores, 'cores': cores,
} }