Skip to content

Commit

Permalink
Added gpio default value standardization and value checks.
Browse files Browse the repository at this point in the history
Created files will have lower case hexadecimal digits.
Default values must be in the 13'hxxxx format where x is a hexadecimal digit.
The resulting binary number must not have more than 13 digits.

NOTE: none of these checks are fatal errors. The default in question will merely be ignored.
  • Loading branch information
d-m-bailey committed May 3, 2024
1 parent 17cec19 commit f18c991
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/gen_gpio_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f18c991

Please sign in to comment.