-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add data about DMA peripheral triggers #1
Conversation
There's also some configuration recommendations per trigger:
|
9912f48
to
7526dac
Compare
'hardware': 'stm32-channel-request', | ||
'features': [], | ||
'protocols': ['mem2mem', 'mem2per', 'per2per'], | ||
'devices': [{'family': ['l4']}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
STM32F09x devices with the "STM32F091_dma_v1_1" IP also have a request mux like the L4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this categorization is still messy, cos I don’t have a good overview of the DMA implementations yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I roughly cross-checked the generated device files with the reference manuals. Almost all data looks reasonable. Only the requests for F09x devices are missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not just F091 and F098 devices use requests, but also the F030 with size C, and all L0 and L4. ST is weird.
The H7 has 3 DMA instances (DMA1, DMA2, BDMA) and two DMAMUX.
Any request line input of the mux can be connected to any output. The mapping between request mux input ids and peripherals (Table 116/119 in H7 manual) is specified in the Additionally the DMAMUX also has further trigger and synchronization inputs ... |
7526dac
to
2345c22
Compare
Is there a branch for the DMA driver WIP? I want to see what data could be useful for it. |
The branch 'feature/dmahal' is available on RCAs private Gitlab.
|
Btw, I uploaded some of my experimentation of comparing/compressing the STM32 memory maps as described by the CMSIS header files. Not sure what it all means, but you can get an overview of the different DMA implementations: |
4d27c4f
to
770a3b4
Compare
The DMA data is not accessible from the modm build system: $ print(device.get_driver("dma"))
{'instance': ['1', '2'], 'name': 'dma', 'type': 'stm32-stream-channel'} |
What |
We were using a STM32F4 Discovery example (stm32f407vgt). It seems child elements are discarded when the parent node has a "value" attribute. |
Oh yeah 🤦♂️ |
770a3b4
to
d02739c
Compare
Ok, I fixed this by using the |
devices/stm32/stm32f1-03-c_d_e.xml
Outdated
@@ -141,6 +137,96 @@ | |||
</driver> | |||
<driver name="usb" type="stm32-v1.1"/> | |||
<driver name="wwdg" type="stm32-v1.0"/> | |||
<driver name="dma" type="stm32-channel"> | |||
<channels> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This <channels>
does not know to which instance it belongs.
modm-devices/devices/stm32/stm32f1-03-c_d_e.xml
Lines 227 to 228 in d02739c
<instance value="1"/> | |
<instance value="2"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed!
d02739c
to
9ad5439
Compare
@salkinium Thanks for the great data. Unfortunately, some data is still missing. ST wouldn't be ST if they didn't prepare a special surprise for us. Most F0 and all F3 devices have an annoying DMA remapping feature. To use some combinations of peripherals and channels certain bits in SYSCFG_CFGR1 have to be set. |
Oh, FFS. |
Can you check if this is somehow encoded in the raw CubeMX data? Otherwise I'd have to manually add it like the AFIO for STM32F1/L1 |
There seems to be some data: <RefParameter Comment="DMA Remap" DefaultValue="HAL_REMAPDMA_ADC24_DMA2_CH34" Group="" Name="DMA_Remap" Type="list" Visible="false">
<PossibleValue Comment="ADC2 and ADC4 DMA remap" Value="HAL_REMAPDMA_ADC24_DMA2_CH34"/>
<Condition Diagnostic="" Expression="(ADC2_Remap&(Instance=DMA2_Channel3))|(ADC4_Remap&(Instance=DMA2_Channel4))"/>
</RefParameter>
[...] |
CubeMX generates something like |
Something like this: <remapping>
<remap_group>
<default>
<signal dma_instance="2" dma_channel="1" driver="adc" instance="2" name="dma"/>
<signal dma_instance="2" dma_channel="2" driver="adc" instance="4" name="dma"/>
</default>
<remapped>
<signal dma_instance="2" dma_channel="3" driver="adc" instance="2" name="dma"/>
<signal dma_instance="2" dma_channel="4" driver="adc" instance="4" name="dma"/>
</remapped>
<!--
Remap bit "SYSCFG_CFGR1_ADC24_DMA_RMP" can be computed
from <signal> elements inside <remapped> above
-->
</remap_group>
</remapping> |
9ad5439
to
26d9741
Compare
</signal> | ||
<signal driver="tim" instance="17" name="up"> | ||
<remap position="12" mask="1" id="0"/> | ||
</signal> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added these remappings manually from the F303x6/8 RM, so we can discuss the formatting. I believe this is a compact and unique mapping, but I have to check this computationally.
This would require the dma driver module file to compute the conflicts somehow, but the information is all here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that similar to the STM32F1 remap, the bit position for the config registers is directly encoded here, to be independent of STs naming register conventions.
devices/stm32/stm32f3-03-6_8.xml
Outdated
</signal> | ||
<signal driver="spi" instance="1" name="rx"> | ||
<remap position="64" mask="3" id="0"/> | ||
<remap position="64" mask="3" id="3"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(position / 32) + 1
gives the registers number, here CFGR3
. Same idea used for AFIOx in STM32F1 GPIO remappings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No clue why ST thinks it needs two mappings for this value. I'm not sure if this isn't a copy-paste error in the PDF.
26d9741
to
3519411
Compare
tools/generator/dfg/stm32/stm.py
Outdated
'dma1ch2': { | ||
'adc2': {'position': 72, 'clear': 3, 'set': 2}, | ||
'i2c_tx': {'position': 70, 'clear': 3, 'set': 1}, | ||
'spi_rx': {'position': 64, 'clear': 3, 'set': 0}, # also 'set': 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see an advantage for also adding the 0b11 encoding here, it does the same thing as the 0b00 encoding.
tools/generator/dfg/stm32/stm.py
Outdated
'i2c_rx': {'position': 68, 'clear': 3, 'set': 0}, # also 'set': 3 | ||
'spi_tx': {'position': 66, 'clear': 3, 'set': 2}, | ||
'tim17_ch1': 'tim17_up', | ||
'tim17_up': {'position': 12, 'clear': 1, 'set': 1}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tools/generator/dfg/stm32/stm.py
Outdated
'tim6_up': {'position': 13, 'clear': 1, 'set': 1}, | ||
}, | ||
'dma1ch4': { | ||
'adc2': {'position': 72, 'clear': 3, 'set': 3}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh gawd, this is a gem, see dma2ch1. Note that this writes both bit 72 and bit 73.
tools/generator/dfg/stm32/stm.py
Outdated
|
||
|
||
'dma2ch1': { | ||
'adc2': [{'position': 8, 'clear': 1, 'set': 0}, {'position': 73, 'clear': 1, 'set': 0}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3519411
to
63c5e83
Compare
}, | ||
} | ||
|
||
stm32f0_dma_remap = \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rleh @chris-durand These remaps are some ugly constraints, you're going to have to be smart about the channel scheduler with this.
63c5e83
to
eec86a4
Compare
I've added the remaps groups now in an automated fashion, please do a spot check for your devices, to see if there are any systematic errors in this. I've extracted the F0/F3 remap sets manually from the reference manuals, the may be faults in there. |
04cb3ac
to
367e3b1
Compare
367e3b1
to
2615dd0
Compare
I'll be merging this into modm-devices to prevent this work going stale and to allow implementing an (incomplete) API in modm already. |
3de381b
to
6f51b1c
Compare
de8ac43
to
489c111
Compare
* working device files for D21, D51, L21
* working device files for D21, D51, L21
This adds a parser for the
IP/DMA-*
files for all STM32 devices.stm32
data, only has channels (F0, F1, F3, L0, L1, L4)stm32-extended
data, has streams and channels (F2, F4, F7)stm32-advanced
data, what the heck?! (H7, L4+)cc @rleh @chris-durand