STM32H7 BDMA Handler issue, with patch. Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
timothyzillion
Posts: 2
Joined: Wed Feb 23, 2022 4:16 am
Been thanked: 1 time

STM32H7 BDMA Handler issue, with patch.

Post 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) {
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32H7 BDMA Handler issue, with patch.

Post by Giovanni »

Hi,

Thanks for finding, will be fixed in next release.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32H7 BDMA Handler issue, with patch.

Post by Giovanni »

Hi,

Fixed as bug #1263.

Giovanni
Post Reply