STMicroelectronics / stm32f4xx-hal-driver

Provides the STM32Cube MCU Component "hal_driver" of the STM32F4 series.
BSD 3-Clause "New" or "Revised" License
119 stars 50 forks source link

Wrong DMA abort callback function called in HAL_MMC_IRQHandler #22

Open exelsior87 opened 1 year ago

exelsior87 commented 1 year ago

Describe the set-up

Describe the bug (skip if none) Invalid DMA abort function called in HAL_MMC_IRQHandler when error occured during sdio read/write by DMA mode.

How to reproduce the bug (skip if none) Hello, I am a begginer at STM32. English is not my first language so I'm not good at English. Please execuse me... My application firmware code is using FatFS and read/write data from eMMC by DMA mode. An HAL_MMC_ERROR_DATA_TIMEOUT(SDIO_FLAG_DTIMEOUT) error occurs after a certain period of time after the file read operation is completed. At this time, the abort callback function is called and the DMA handle is initialized. However, even though a HAL_MMC_ERROR_DATA_TIMEOUT error occurred during read operation, DMATxAbort callback is called and DMA TX handle initailized to NULL.

Additional context

https://github.com/STMicroelectronics/stm32f4xx_hal_driver/blob/6ea96e3bee7629552b26d92e96c2e64217bebfea/Src/stm32f4xx_hal_mmc.c#L1679-L1698

I think the code should be as follows:

... if (((context & MMC_CONTEXT_WRITE_SINGLE_BLOCK) != 0) || ((context & MMC_CONTEXT_WRITE_MULTIPLE_BLOCK) != 0)) { if (hmmc->hdmatx != NULL) { ... DMA Tx Abort callback ... } } else if (((context & MMC_CONTEXT_READ_SINGLE_BLOCK) != 0) || ((context & MMC_CONTEXT_READ_MULTIPLE_BLOCK) != 0)) { if (hmmc->hdmarx != NULL) { ... DMA Rx Abort callback ... } } ...

Screenshots hmmc2 hmmc_instance2

TOUNSTM commented 1 year ago

hello @exelsior87,

Thank you for this report. We will get back to you as soon as we analyze it further. This may take some time. Thank you for your comprehension.

With regards,