From 93490bc42f243ed7140a112582fbd91a5d080d9d Mon Sep 17 00:00:00 2001 From: Bob McWhirter Date: Mon, 2 Aug 2021 09:48:30 -0400 Subject: [PATCH] Ensure that any bank is not larger than the total from the SVD. --- parse.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/parse.py b/parse.py index 8ccf9f8..37435b3 100755 --- a/parse.py +++ b/parse.py @@ -692,6 +692,10 @@ def parse_chips(): chip_nvic = chip['nvic'] del chip['nvic'] + device_id = determine_device_id(chip_name) + if device_id is not None: + chip['device-id'] = device_id + h = find_header(chip_name) if h is None: raise Exception("missing header for {}".format(chip_name)) @@ -722,6 +726,8 @@ def parse_chips(): if key == 'BANK_1' or key == 'BANK_2': flash_size = determine_flash_size(chip_name) if flash_size is not None: + if flash_size > chip['flash']['bytes'].val: + flash_size = chip['flash']['bytes'].val chip['flash']['regions'][key]['bytes'] = DecimalInt(flash_size) found = [] @@ -1341,6 +1347,13 @@ def determine_flash_size(chip_name): return None +def determine_device_id(chip_name): + for each in memories: + for name in each['names']: + if is_chip_name_match(name, chip_name): + return each['device-id'] + return None + def is_chip_name_match(pattern, chip_name): pattern = pattern.replace('x', '.') return re.match(pattern + ".*", chip_name)