diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 40eb0d36f1..89404b3ce0 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -2935,7 +2935,7 @@ Please run: Tools/scripts/build_bootloaders.py %s return False return True - def process_line(self, line): + def process_line(self, line, depth): '''process one line of pin definition file''' self.all_lines.append(line) a = shlex.split(line, posix=False) @@ -3074,14 +3074,21 @@ Please run: Tools/scripts/build_bootloaders.py %s # extract numerical defines for processing by other parts of the script result = re.match(r'define\s*([A-Z_0-9]+)\s+([0-9]+)', line) if result: - self.intdefines[result.group(1)] = int(result.group(2)) + (name, intvalue) = (result.group(1), int(result.group(2))) + if name in self.intdefines and self.intdefines[name] == intvalue: + msg = f"{name} already in defines with same value" + if depth == 0: + print(msg) + # raise ValueError(msg) + + self.intdefines[name] = intvalue def progress(self, message): if self.quiet: return print(message) - def process_file(self, filename): + def process_file(self, filename, depth=0): '''process a hwdef.dat file''' try: f = open(filename, "r") @@ -3100,9 +3107,9 @@ Please run: Tools/scripts/build_bootloaders.py %s include_file = os.path.normpath( os.path.join(dir, include_file)) self.progress("Including %s" % include_file) - self.process_file(include_file) + self.process_file(include_file, depth+1) else: - self.process_line(line) + self.process_line(line, depth) def add_apperiph_defaults(self, f): '''add default defines for peripherals'''