diff --git a/scripts/gen_gpio_defaults.py b/scripts/gen_gpio_defaults.py index a4e9dc65..940c6e83 100755 --- a/scripts/gen_gpio_defaults.py +++ b/scripts/gen_gpio_defaults.py @@ -221,14 +221,24 @@ def usage(): print('No configuration specified for GPIO ' + str(i) + '; skipping.') continue + valid_value = r"^13'h[0-9a-fA-F]{4}$" + value_match = re.match(valid_value, config_value) + if not value_match: + print('Error: Default value ' + config_value + ' is not a 4-digit hex number; skipping') + continue + try: default_str = config_value[-4:] binval = '{:013b}'.format(int(default_str, 16)) + if len(binval) > 13: + print('Error: Default value ' + config_value + ' is not a 4-digit hex number; skipping') + continue + except: print('Error: Default value ' + config_value + ' is not a 4-digit hex number; skipping') continue - cell_name = 'gpio_defaults_block_' + default_str + cell_name = 'gpio_defaults_block_' + default_str.lower() mag_file = magpath + '/' + cell_name + '.mag' cellsused[i] = cell_name