Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
skyarm opened this issue Mar 29, 2021 · 3 comments
Closed

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

skyarm opened this issue Mar 29, 2021 · 3 comments
Labels
Area: cpu Area: CPU/MCU ports Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@skyarm
Copy link

skyarm commented Mar 29, 2021

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
Copy link
Author

skyarm commented Mar 29, 2021

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
Copy link
Author

skyarm commented Mar 29, 2021

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 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,
false);

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

@jeandudey jeandudey added Area: cpu Area: CPU/MCU ports Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) labels Apr 23, 2021
@aabadie aabadie added the Platform: ARM Platform: This PR/issue effects ARM-based platforms label May 20, 2021
@MrKevinWeiss MrKevinWeiss added this to the Release 2021.07 milestone Jun 22, 2021
@MrKevinWeiss MrKevinWeiss removed this from the Release 2021.07 milestone Jul 15, 2021
@maribu
Copy link
Member

maribu commented Jan 5, 2023

Let me just claim #18711 fixed the issue. Please reopen if that is not correct.

@maribu maribu closed this as completed Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

No branches or pull requests

5 participants