Page 2 of 2

Re: [patch] support mixed DMA and non-DMA I2Cv2

Posted: Sat Jun 09, 2018 11:23 pm
by tridge
steved wrote:If interrupt-driven serial is good enough for you, there are two drivers I've posted here in the past:
a) A UART driver which can use interrupts instead of DMA
b) A version of the serial driver which supports callbacks similar to the UART driver.

thanks. I suspect writing new UART drivers is a favourite sport among ChibiOS developers!

We've done our own uart driver as well. Main features are:

    allows for both DMA and non-DMA operation
    allows for sharing TX DMA channel with another device
    allows for mixed DMA and non-DMA operation (eg. DMA for RX, non-DMA for TX)
    if there is DMA contention then it lowers the max TX size per operation to fit a max latency
    has callback hooks allowing us to calculate the time of first byte arrival in a packet
    supports optional flow control, configured at runtime
    uses two ring buffers and a separate thread for IO
    has event callback for applications that need to be woken on incoming packets

It is in C++, so not easily brought into other ChibiOS projects, but source is here if you are interested:
https://github.com/ArduPilot/ardupilot/ ... Driver.cpp

Your DMA resolver looks to be a potentially useful general tool - it can be "fun" getting the DMA assignments right.


it is here:
https://github.com/ArduPilot/ardupilot/ ... esolver.py

it would need some munging for use outside ArduPilot I think

Re: [patch] support mixed DMA and non-DMA I2Cv2

Posted: Sun Jun 10, 2018 2:30 pm
by alex31
tridge wrote:that datasheet fix for I2C4_TX does allow us to get I2C4 with DMA. This is what our resolver gives now:



Hello,

I have had the idea since years to made resolver like that, but never had done it, thanks for that useful tool.

I have not seen how your script is written, however, it seems you use data from the documentation. I think a better way is to use the MCU description in the form of xml files that come with STM32CubeMX tool.

I have done a board.h generator (i will eventually made a post about it) that use theses xml files, and when i query about dma channels, it gives me correct results : by example, for a STM32F767VGTx :

Code: Select all

boardGen.pl --dma I2C4 local/DEVBOARDM7/board.cfg
 
I2C4_TX : [stream(1, 5) C2]
#define STM32_I2C4_TX_DMA_STREAM                STM32_DMA_STREAM_ID(1, 5)
#define STM32_I2C4_TX_DMA_CHANNEL               2

I2C4_TX : [stream(1, 6) C8]
#define STM32_I2C4_TX_DMA_STREAM                STM32_DMA_STREAM_ID(1, 6)
#define STM32_I2C4_TX_DMA_CHANNEL               8

I2C4_RX : [stream(1, 1) C8]
#define STM32_I2C4_RX_DMA_STREAM                STM32_DMA_STREAM_ID(1, 1)
#define STM32_I2C4_RX_DMA_CHANNEL               8

I2C4_RX : [stream(1, 2) C2]
#define STM32_I2C4_RX_DMA_STREAM                STM32_DMA_STREAM_ID(1, 2)
#define STM32_I2C4_RX_DMA_CHANNEL               2


Alexandre

Re: [patch] support mixed DMA and non-DMA I2Cv2

Posted: Mon Jun 11, 2018 11:47 am
by tridge
alex31 wrote:I have not seen how your script is written, however, it seems you use data from the documentation. I think a better way is to use the MCU description in the form of xml files that come with STM32CubeMX tool.

I completely agree. We looked at doing that, and even have some test code for doing it, but we didn't go ahead as we weren't sure the license on the cube database files allowed that sort of extraction and usage.
So we process the PDF datasheet files instead, where it's clear we can use it. If at some point we get a clear license indication on the XML files in the database we'll switch to that.
Cheers, Tridge

Re: [patch] support mixed DMA and non-DMA I2Cv2

Posted: Mon Jun 11, 2018 12:15 pm
by Giovanni
So the question is: can the Cube data files be used for 3rd parties no-profit tools?

Giovanni

Re: [patch] support mixed DMA and non-DMA I2Cv2

Posted: Mon Jun 11, 2018 11:23 pm
by tridge
Giovanni wrote:So the question is: can the Cube data files be used for 3rd parties no-profit tools?

yes, although its not just "no-profit tools". Many projects use ChibiOS in a commercial manner. I think we'd need specific permission to use the database in a manner that is compatible with either apachev2 license or GPLv3. There is also the question of if we can extract updated versions of the database when they come out.
Being able to use the database would be a huge win

Re: [patch] support mixed DMA and non-DMA I2Cv2

Posted: Tue Jun 12, 2018 5:05 am
by Giovanni
I will look into this. Could you specify exactly which files or directories you need?

Giovanni

Re: [patch] support mixed DMA and non-DMA I2Cv2

Posted: Tue Jun 12, 2018 5:10 am
by faisal
FYI: https://github.com/esden/stm32cube-database

They use a ton on XML and FreeMarker templates ..

Re: [patch] support mixed DMA and non-DMA I2Cv2

Posted: Tue Jun 12, 2018 11:39 am
by tridge
Giovanni wrote:I will look into this. Could you specify exactly which files or directories you need?

Ideally the whole db, but the key files are under mcu/
The files are all inter-linked, so there is a file per MCU version, but that links to other files that contain (for example) DMA channels.
If we can't use the db then we can extract the information from the pdf datasheets, it just takes a bit longer