DMA2 support on F091 missing? Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
steved
Posts: 823
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

DMA2 support on F091 missing?

Postby steved » Thu Aug 31, 2017 6:07 pm

Is it possible that support for the second DMA controller on the 32F091 is missing or incomplete? I'm getting some strange symptoms for which that is a possible explanation.

Specifically, I'm using both I2C1 and SPI1. If both have DMA channels allocated on controller 1, they work. If I move SPI1 to controller 2 (2,3) and (2,4), it stops working. At the same time, if the I2C is on (1,6) and (1,7) it continues to work. If I2C1 is allocated to (1,2) and (1,3) it fails - makes me wonder if the SPI DMA is accessing the first controller rather than the second.

I've threaded my way through some of the macros, and currently stalled because I can't find where the values for DMA1_Stream0...DMA2_Stream7 in table _stm32_dma_streams in stm32_dma.c are defined.

Edit: Just realised that the F0 series used DMA1, so should be looking for DMA2_Channel4 and similar, which are defined.

Incidentally, there are no compile-time errors; its a run-time problem.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: DMA2 support on F091 missing?

Postby Giovanni » Wed Sep 13, 2017 10:10 am

Hi,

Everything looks fine in the registry and DMAv1 driver, very strange.

Are initialized values visible in DMA2 registers?

Giovanni

steved
Posts: 823
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: DMA2 support on F091 missing?

Postby steved » Wed Sep 13, 2017 1:31 pm

Giovanni wrote:Everything looks fine in the registry and DMAv1 driver, very strange.

I agree; I tracked things through for quite a way, and in some detail. Was rather hoping your better knowledge of these things would lead to a lightbulb moment.

The basic problem is that, with DMA2 involved in SPI transfers, the SPI thread hangs suspended waiting for DMA to complete. Yet the interrupt settings made sense as well.

Giovanni wrote:Are initialized values visible in DMA2 registers?

Yes, everything I checked made sense. And DMA2 clock is enabled.

I did test on another board to eliminate a one-off hardware problem, and there are no published errata which look relevant.

I'm still assuming there's some subtle error in the way that things are set up, but haven't been able to find it. (Could be an error in the RM, of course).

I'm away for a week now, but can have another look thereafter if you've got any suggestions.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: DMA2 support on F091 missing?

Postby Giovanni » Wed Sep 13, 2017 1:36 pm

I will run a test with SPI on my side during weekend and see, I wanted to do a release, hopefully it will not take too long.

Giovanni

steved
Posts: 823
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: DMA2 support on F091 missing?

Postby steved » Wed Sep 13, 2017 3:21 pm

Giovanni wrote:I will run a test with SPI on my side during weekend and see, I wanted to do a release, hopefully it will not take too long.

It is of course possible that some other piece of code is corrupting one of the DMA2-related registers; at present the code is within a 'normal' project, rather than a stripped down test harness. It's running network, I2C and several serial ports, all of which should be pretty solid - and everything runs fine when only using DMA1. But clearly something is upsetting DMA2.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: DMA2 support on F091 missing?

Postby Giovanni » Sun Sep 17, 2017 8:33 am

Hi,

I created an SPI multi demo with F091 support, when trying SPI1 it works both with DMA1 and DMA2. It must me something else on your side.

Giovanni

steved
Posts: 823
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: DMA2 support on F091 missing?

Postby steved » Wed Sep 20, 2017 9:22 am

Thanks for checking; I'll try and dig a bit deeper. Just seemed surprising that the problem arose when the only thing I changed was the DMA channel assignments.

steved
Posts: 823
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: DMA2 support on F091 missing?

Postby steved » Fri Sep 22, 2017 6:26 pm

Made a bit of progress on this. It appears to be an interaction between the I2C and SPI DMA settings. Doesn't appear to matter whether I2C1 or I2C2 is enabled (or both).

In my test project on an F091 Nucleo (attached) the SPI locks if it is started after the I2C, but appears to work if started first.
No I2C activity is needed; just starting on one port, with DMA enabled, seems to be enough. (I've not looked for specific activity on the SPI pins yet, but flashing the LED indicates whether the SPI code is locking up in a suspended state)

If I move the SPI from DMA2 to DMA1 (there's a simple switch in mcuconf.h of the project) the SPI runs.

Using the GCC6.3 compiler from Chibistudio 18, and official 17.6 release (so none of my modified drivers).
Attachments
F091_Test.zip
(24.96 KiB) Downloaded 190 times

User avatar
FXCoder
Posts: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Re: DMA2 support on F091 missing?

Postby FXCoder » Sat Sep 23, 2017 3:42 am

Steve,
I might be off the mark here but encountered the same issue on another project recently.

Bottom line... Isn't this just a case of stream allocation contention?
Both SPI and I2C check for DMA stream allocation error at start.
So when SPI and I2C are run concurrently, and DMAx + streams are the same, you end up with a "osalDbgAssert(!b, "stream already allocated");" when the other driver attempts to start.

The issue can be avoided by...
a) nominating non-competing DMA streams in mcuconf.h for the devices
b) adding semaphore mechanism, etc. and starting/stopping the driver to conduct a transaction when the other driver is not active

Bob

steved
Posts: 823
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: DMA2 support on F091 missing?

Postby steved » Sat Sep 23, 2017 7:50 am

Bob,

Thanks for the reply; however I'm confident that's not the problem here. Having created a stripped down project which only assigns one SPI port and one I2C port, its very clear which DMA channels are assigned (and I stepped through the SPI-related DMA code, which appeared to use the right numbers). I've even switched to the standard I2C drivers, rather than my own ones.

Although you have just reminded me - I must turn the debug options on in the test project to see if they throw up something (they are definitely turned on in the original project)


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 13 guests