From ff31e10d9e07a03d18f4f9a6f865a77ba32b5fec Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 16 Mar 2021 18:28:25 +1100 Subject: [PATCH] HAL_ChibiOS: ensure that RCIN DMA channel is not shared RCIN DMA cannot be shared as it runs all the time --- libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py | 9 ++++++++- libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_resolver.py | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 573de6e53c..f84034462e 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -108,6 +108,9 @@ uart_serial_num = {} mcu_type = None dual_USB_enabled = False +# list of device patterns that can't be shared +dma_noshare = [] + def is_int(str): '''check if a string is an integer''' try: @@ -1786,6 +1789,8 @@ def write_hwdef_header(outfilename): ''') + dma_noshare.extend(get_config('DMA_NOSHARE', default='', aslist=True)) + write_mcu_config(f) write_SPI_config(f) write_ADC_config(f) @@ -1800,7 +1805,7 @@ def write_hwdef_header(outfilename): dma_unassigned, ordered_timers = 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_noshare=dma_noshare) if not args.bootloader: write_PWM_config(f, ordered_timers) @@ -1953,6 +1958,8 @@ def build_peripheral_list(): if label[-1] == 'N': label = label[:-1] peripherals.append(label) + # RCIN DMA channel cannot be shared as it is running all the time + dma_noshare.append(label) elif not p.has_extra('ALARM') and not p.has_extra('RCININT'): # get the TIMn_UP DMA channels for DShot label = p.type + '_UP' diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_resolver.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_resolver.py index 600820fa51..02606a3f9d 100755 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_resolver.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/dma_resolver.py @@ -290,7 +290,7 @@ def forbidden_list(p, peripheral_list): def write_dma_header(f, peripheral_list, mcu_type, dma_exclude=[], - dma_priority='', dma_noshare=''): + dma_priority='', dma_noshare=[]): '''write out a DMA resolver header file''' global dma_map, have_DMAMUX, has_bdshot timer_ch_periph = [] @@ -304,7 +304,7 @@ def write_dma_header(f, peripheral_list, mcu_type, dma_exclude=[], peripheral_list = sorted(peripheral_list, key=lambda x: get_list_index(x, priority_list)) # form a list of peripherals that can't share - noshare_list = dma_noshare.split() + noshare_list = dma_noshare[:] try: lib = importlib.import_module(mcu_type)