diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 11c31a375f..7b07166b4e 100755 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -773,6 +773,12 @@ def process_line(line): spidev.append(a[1:]) if a[0] == 'undef': config.pop(a[1], '') + #also remove all occurences of defines in previous lines if any + for line in alllines: + if line.startswith('define') and a[1] in line: + alllines.remove(line) + +