Where to override DMA stream declarations for remapping?

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
ulikoehler
Posts: 71
Joined: Tue Mar 17, 2015 2:32 am
Been thanked: 3 times

Where to override DMA stream declarations for remapping?

Post by ulikoehler »

Hi,
in stm32_registry.h there are declarations like these for every peripheral.

Code: Select all

#define STM32_UART_USART1_RX_DMA_STREAM     STM32_DMA_STREAM_ID(1, 3)
#define STM32_UART_USART1_TX_DMA_STREAM     STM32_DMA_STREAM_ID(1, 2)

I have a usecase where I intend to use both SPI1 an USART1 which are mapped to the same DMA stream by default. However, the hardware supports remapping those to

Code: Select all

#define STM32_UART_USART1_RX_DMA_STREAM     STM32_DMA_STREAM_ID(1, 5)
#define STM32_UART_USART1_TX_DMA_STREAM     STM32_DMA_STREAM_ID(1, 4)

via

Code: Select all

  /**
   * Remap USART1 DMA to CH5/CH6
   */
  SYSCFG->CFGR1 |= SYSCFG_CFGR1_USART1_TX_DMA_RMP | SYSCFG_CFGR1_USART1_RX_DMA_RMP:

I have tried using board.h and mcuconf.h for overriding, however these files are included before the registry files. Therefore the registry will take preference.

This leads me to my questions:
1) Is there a preferred place where to override definitions from the registry?
2) If not, wouldn't it be smarter to include mcuconf.h AFTER the registry in all headers in order to allow overrides?

Best regards, Uli
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Where to override DMA stream declarations for remapping?

Post by Giovanni »

Hi,

You should create a local copy of the registry file and modify it. In 3.1 the issue has already been addressed for F0 and L0 devices (soon also F3), it will be possible to assign DMAs in mcuconf.h.

You may checkout the latest code (and help me find problems :)), the RT kernel is not changed. Note that you can backport the HAL from 3.1 to 3.0 with a free commercial license.

Giovanni
ulikoehler
Posts: 71
Joined: Tue Mar 17, 2015 2:32 am
Been thanked: 3 times

Re: Where to override DMA stream declarations for remapping?

Post by ulikoehler »

Thanks Giovanni! I did exactly what you suggested and it not only solved the DMA remapping problem but also magically resolved the issue of USART1 not actually sending data (via the asynchronous driver).

This might be off-topic here, but I have built a CMake-based system for building ChibiOS 3.x which works quite well now. It allows using only a few lines to configure the project:

Code: Select all

set(CHIBIOS_PATH ../../ChibiOS)
set(BOARD_PATH ../../boards)
set(OPENOCD_DIR ../../openocd)

include(../../chibios.cmake)

chibios_use_kernel(nil v6m STM32F0xx)
chibios_use_hal_modules(GPIOv2 I2Cv1 SPIv2 TIMv1 USARTv2 RTCv2 EXTIv1 DMAv1)
chibios_use_board(MyBoard)
chibios_setup_flash_targets()


I will publish that as open source in the near future.

Best regards,
Uli
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Where to override DMA stream declarations for remapping?

Post by Giovanni »

This is strange because the serial driver has not been modified.

Giovanni
Post Reply