[patch] support mixed DMA and non-DMA I2Cv2

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
tridge
Posts: 141
Joined: Mon Sep 25, 2017 8:27 am
Location: Canberra, Australia
Has thanked: 10 times
Been thanked: 20 times
Contact:

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

Postby tridge » Sat Jun 09, 2018 11:23 pm

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

User avatar
alex31
Posts: 374
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 38 times
Been thanked: 61 times
Contact:

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

Postby alex31 » Sun Jun 10, 2018 2:30 pm

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

tridge
Posts: 141
Joined: Mon Sep 25, 2017 8:27 am
Location: Canberra, Australia
Has thanked: 10 times
Been thanked: 20 times
Contact:

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

Postby tridge » Mon Jun 11, 2018 11:47 am

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

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: [patch] support mixed DMA and non-DMA I2Cv2

Postby Giovanni » Mon Jun 11, 2018 12:15 pm

So the question is: can the Cube data files be used for 3rd parties no-profit tools?

Giovanni

tridge
Posts: 141
Joined: Mon Sep 25, 2017 8:27 am
Location: Canberra, Australia
Has thanked: 10 times
Been thanked: 20 times
Contact:

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

Postby tridge » Mon Jun 11, 2018 11:23 pm

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

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: [patch] support mixed DMA and non-DMA I2Cv2

Postby Giovanni » Tue Jun 12, 2018 5:05 am

I will look into this. Could you specify exactly which files or directories you need?

Giovanni

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

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

Postby faisal » Tue Jun 12, 2018 5:10 am

FYI: https://github.com/esden/stm32cube-database

They use a ton on XML and FreeMarker templates ..

tridge
Posts: 141
Joined: Mon Sep 25, 2017 8:27 am
Location: Canberra, Australia
Has thanked: 10 times
Been thanked: 20 times
Contact:

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

Postby tridge » Tue Jun 12, 2018 11:39 am

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


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 12 guests