-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/stm32: fix periph_dma #18711
cpu/stm32: fix periph_dma #18711
Conversation
be0e90b
to
a42f4be
Compare
I had planned to add UART4 to the nucleo-f303ze board port to demonstrate this PR. Upon starting that effort, I can see that the board has remnants of DMA support, but this has been broken at one point, or never worked. I don't really want to open that can of worms right now. I can attest that this PR works on my custom board, but see now easy way to demonstrate with any eval board I have on hand. |
I also felt like the lines |
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.
Looks good, just two comments:
b44c7df
to
cf4669a
Compare
I just force pushed to squash my fixup commit. There was no change to the code. |
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 have the hardware to test this, but looks good to me.
The magic numbers need a comment though.
Murdock results✔️ PASSED 4e2c63c cpu/stm32/periph/dma: make dma_prepare() generic
ArtifactsThis only reflects a subset of all builds from https://ci-prod.riot-os.org. Please refer to https://ci.riot-os.org for a complete build for now. |
@Enoch247 please add the comment how you achieved those numbers, then we can merge this. |
As it was, the calculation of DMA2's IRQ number was inccrorect for some STM families. The implmentation alocates streams numbers 0 to 7 for the first DMA controller and 8 and up for the second DMA controller. This offset of +8 was not accounted for when IRQ's of the second DMA controller was calculated. This patch corrects this.
As implmented, dma_resume assumed that transfers widths were 1 byte and that the memory address incrmenting was always on and periphial address incrementing always off. This resulted in memory corruption anytime these assumptions were not true and a dma was resumed. The DMA module allows intitiating transfers that did not meet these assumption. This patch adds proper handling inside dma_resume to safely resume any transfer. Clearifications and errors are added/fixed in the module's header file. Also, a few constants are removed from the gobal namespace.
This patch makes dma_prepare() handle register names a bit more generically.
cf4669a
to
4e2c63c
Compare
Contribution description
This fixes some bugs I found in the STM32 DMA module. See commit messages for further details.
Perhaps a better fix would have been to add a second parameter to the
dma_conf_t
struct to separately define the DMA controller and stream/channel. This would be similar to the how the ADC module handles the ADC and channel number for ADC lines. Should I have done this instead of fixing the current way of mapping DMA stream 0-7 to DMA controller 1, and streams 8 and beyond to controller 2?Testing procedure
On any STM32 based board:
dma_suspend
followeddma_resume
after some timedma_suspend
followeddma_resume
after some timeOn any STM32F303 based board with 2 DMA controllers:
periph_dma
moduleDMA2_Channel6_IRQn
definitionIssues/PRs references