Page 1 of 1

STM32H7 BDMA Handler issue, with patch.

Posted: Fri Apr 21, 2023 5:28 pm
by timothyzillion
I had been running into some confusing behavior with the H7's ADC3: after running for a while my dma-completion handler would not be called.

After some digging,I discovered that the order of device-initialization changed the behavior.

I set a watchpoint on bdma.streams[0].func and see that the other BDMA device I'm using (spi6) is clearing the wrong bdma.streams index.

It looks like the functions bdmaStreamAllocI() and bdmaStreamFreeI() should be inverses of one another, but bdmaStreamFreeI() always clears the 0-index stream handler -- you only run into this problem when you have more than one peripheral using BDMA.

Code: Select all

diff --git a/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.c b/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.c
index 411a55b30..feadcaeb5 100644
--- a/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.c
+++ b/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.c
@@ -408,8 +408,8 @@ void bdmaStreamFreeI(const stm32_bdma_stream_t *stp) {
   bdma.allocated_mask &= ~(1U << stp->selfindex);
 
   /* Clearing associated handler and parameter.*/
-  bdma.streams->func  = NULL;
-  bdma.streams->param = NULL;
+  bdma.streams[stp->selfindex]->func  = NULL;
+  bdma.streams[stp->selfindex]->param = NULL;
 
   /* Shutting down clocks that are no more required, if any.*/
   if ((bdma.allocated_mask & STM32_BDMA_STREAMS_MASK) == 0U) {

Re: STM32H7 BDMA Handler issue, with patch.

Posted: Fri Apr 21, 2023 5:39 pm
by Giovanni
Hi,

Thanks for finding, will be fixed in next release.

Giovanni

Re: STM32H7 BDMA Handler issue, with patch.

Posted: Tue Apr 25, 2023 10:41 am
by Giovanni
Hi,

Fixed as bug #1263.

Giovanni