RIOT-OS / RIOT

RIOT - The friendly OS for IoT
https://riot-os.org
GNU Lesser General Public License v2.1
4.91k stars 1.98k forks source link

I found stm32 DMA periph driver bugs! when I tested stm32l431rc board. #16242

Closed skyarm closed 1 year ago

skyarm commented 3 years ago

Description

The next issue, at cpu/stm32/periph/spi.c, The issue can run correctly, But it is just a coincidence!!! dma_setup(spi_config[bus].tx_dma, spi_config[bus].tx_dma_chan, (uint32_t*)&(dev(bus)->DR), DMA_MEM_TO_PERIPH, 0, DMA_DATA_WIDTH_BYTE);

But the prototype of the dma_setup is: void dma_setup(dma_t dma, int chan, void periph_addr, dma_mode_t mode, uint8_t width, bool inc_periph); So correctly call must be: dma_setup(spi_config[bus].tx_dma, spi_config[bus].tx_dma_chan, (uint32_t)&(dev(bus)->DR), DMA_MEM_TO_PERIPH, DMA_DATA_WIDTH_BYTE, 0); Although the correct result can be obtained, it is just a coincidence!!!

Steps to reproduce the issue

Expected results

Actual results

Versions

skyarm commented 3 years ago

The next issue: The IRQ Vector value isn't correct if the stream parameter >= 7 or >= 12 at cpu/stm32/periph/dma.c line 208

if defined(DMA2_BASE)

if defined(CPU_FAM_STM32F1)

else if (stream < 11) {

else

else if (stream < 13 ) {

endif

    return ((IRQn_Type)((int)DMA2_Channel1_IRQn **+ stream));**
}

if !defined(CPU_FAM_STM32L1)

else {

if defined(CPU_FAM_STM32F1)

    return (DMA2_Channel4_5_IRQn);

else

    return ((IRQn_Type)((int)DMA2_Channel6_IRQn **+ stream));**

endif

}

endif / !defined(CPU_FAM_STM32L1) /

endif / defined(DMA2_BASE) /

skyarm commented 3 years ago

The next issue, at cpu/stm32/periph/spi.c. line 236, The issue can run correctly, But it is just a coincidence!!! dma_setup(spi_config[bus].tx_dma, spi_config[bus].tx_dma_chan, (uint32_t*)&(dev(bus)->DR), DMA_MEM_TO_PERIPH, 0, DMA_DATA_WIDTH_BYTE);

But the prototype of the dma_setup is: void dma_setup(dma_t dma, int chan, void periph_addr, dma_mode_t mode, _uint8_t width, bool incperiph);

So correctly call must be: dma_setup(spi_config[bus].tx_dma, spi_config[bus].tx_dma_chan, (uint32_t)&(dev(bus)->DR), DMA_MEM_TO_PERIPH, DMA_DATA_WIDTH_BYTE, false);

Although the correct result can be obtained, it is just a coincidence!!!

maribu commented 1 year ago

Let me just claim https://github.com/RIOT-OS/RIOT/pull/18711 fixed the issue. Please reopen if that is not correct.