stm32/dma: Reset all dma channels during soft-reset.#12803
Conversation
Signed-off-by: Andrew Leech <[email protected]>
Why have the original structs disappeared? I think it might be better to allow a user C module to register a deinit hook, to be called when soft reset occurs. Then the user C module can explicitly call Note that some user C modules (or other external C code) may actually want the DMA to continue over a soft reset. Eg a Bluetooth controller that uses DMA for the UART transfer, that doesn't get reset on soft reset. |
|
In my application, the dma definition stucts are held by micropython objects that are gc alloc'd by runtime code, so these are wiped out over a reset. Keeping some dma alive for particular use cases is a very good point though. The suggestion to instead have the ability for C modules to register a de-init hook is far better, I can think of many use cases for this.
https://ptb.discord.com/channels/574275045187125269/1012726673709469818/1173760875539206225 Assuming |
Yes! |
On a work project I'm using a C module to configure and use DMA for timer interactions. The same thing can be done with https://github.com/andrewleech/micropython-stm32-pwm-sine-wave
Once DMA interrupts have been enabled with any channels not used by internal micropython usage, these don't get turned off on soft-reset which leaves them still enabled. If they get triggered, a hard fault occurs as the HAL interrupt tries to access the original definition struct which has now disappeared.
This MR adds an explicit reset of all DMA channels during soft reset to ensure this hard fault cannot occur.