Page 1 of 1

Where to override DMA stream declarations for remapping?

Posted: Fri Jul 31, 2015 10:18 pm
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

Re: Where to override DMA stream declarations for remapping?

Posted: Fri Jul 31, 2015 11:12 pm
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

Re: Where to override DMA stream declarations for remapping?

Posted: Sun Aug 02, 2015 2:59 am
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

Re: Where to override DMA stream declarations for remapping?

Posted: Sun Aug 02, 2015 7:22 am
by Giovanni
This is strange because the serial driver has not been modified.

Giovanni