diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 13ac42b645..3dd1d7cdbb 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -1470,10 +1470,10 @@ def write_hwdef_header(outfilename): write_peripheral_enable(f) setup_apj_IDs() - dma_resolver.write_dma_header(f, periph_list, mcu_type, - dma_exclude=get_dma_exclude(periph_list), - dma_priority=get_config('DMA_PRIORITY',default='TIM* SPI*', spaces=True), - dma_noshare=get_config('DMA_NOSHARE',default='', spaces=True)) + dma_unassigned = dma_resolver.write_dma_header(f, periph_list, mcu_type, + dma_exclude=get_dma_exclude(periph_list), + dma_priority=get_config('DMA_PRIORITY',default='TIM* SPI*', spaces=True), + dma_noshare=get_config('DMA_NOSHARE',default='', spaces=True)) if not args.bootloader: write_PWM_config(f) @@ -1570,6 +1570,14 @@ def write_hwdef_header(outfilename): f.write("0") f.write(")\n\n") + if not mcu_series.startswith("STM32F1"): + dma_required = ['SPI*', 'ADC*'] + if 'IOMCU_UART' in config: + dma_required.append(config['IOMCU_UART'][0] + '*') + for d in dma_unassigned: + for r in dma_required: + if fnmatch.fnmatch(d, r): + error("Missing required DMA for %s" % d) def build_peripheral_list(): '''build a list of peripherals for DMA resolver to work on''' @@ -1584,13 +1592,17 @@ def build_peripheral_list(): if type.startswith(prefix): ptx = type + "_TX" prx = type + "_RX" - peripherals.append(ptx) - peripherals.append(prx) - if not ptx in bylabel: - bylabel[ptx] = p - if not prx in bylabel: - bylabel[prx] = p - + if prefix in ['SPI', 'I2C']: + # in DMA map I2C and SPI has RX and TX suffix + if not ptx in bylabel: + bylabel[ptx] = p + if not prx in bylabel: + bylabel[prx] = p + if prx in bylabel: + peripherals.append(prx) + if ptx in bylabel: + peripherals.append(ptx) + if type.startswith('ADC'): peripherals.append(type) if type.startswith('SDIO') or type.startswith('SDMMC'): diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_resolver.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_resolver.py index e87c2a8df3..66e62d9775 100755 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_resolver.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_resolver.py @@ -236,7 +236,7 @@ def write_dma_header(f, peripheral_list, mcu_type, dma_exclude=[], if hasattr(lib, "DMA_Map"): dma_map = lib.DMA_Map else: - return + return [] except ImportError: print("Unable to find module for MCU %s" % mcu_type) sys.exit(1) @@ -386,6 +386,7 @@ def write_dma_header(f, peripheral_list, mcu_type, dma_exclude=[], continue f.write('#define STM32_SPI_%s_DMA_STREAMS STM32_SPI_%s_TX_%s_STREAM, STM32_SPI_%s_RX_%s_STREAM\n' % ( key, key, dma_name(key), key, dma_name(key))) + return unassigned if __name__ == '__main__':