Skip to main content
con3
Senior
August 21, 2018
Solved

Anyone have a working sdcard(FATFS) with DMA on the stm32f7?

  • August 21, 2018
  • 5 replies
  • 1199 views

Hey!

I used HAL and I've tried to get the DMA going, although It doesn't seem to work and I'm not sure where the bug is at this point, I've realized that when I replace BSP_SD_WriteBlocks_DMA with the standard BSP_SD_WriteBlocks in sd_diskio.c the sdcard works fine, so I know the error has to be somewhere in the function but I can't track it down.

I've looked for templates or examples using FATFS and DMA for the stm32f7 but I couldn't find any so Just want to see if anyone has encountered this and has any solutions?

Thanks in advance!

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    To the top level question, Yes, have it working, works fine. Don't have notes with me, but think I can get 20MBps reads.

    STM32Cube_FW_F7_V1.12.0\Middlewares\Third_Party\FatFs\src\drivers\sd_diskio_dma_template.c

    STM32Cube_FW_F7_V1.12.0\Projects\STM32746G-Discovery\Applications\USB_Device\MSC_Standalone\Src

    IRQ Handlers and DMA must be correctly configured.

    5 replies

    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    August 21, 2018

    To the top level question, Yes, have it working, works fine. Don't have notes with me, but think I can get 20MBps reads.

    STM32Cube_FW_F7_V1.12.0\Middlewares\Third_Party\FatFs\src\drivers\sd_diskio_dma_template.c

    STM32Cube_FW_F7_V1.12.0\Projects\STM32746G-Discovery\Applications\USB_Device\MSC_Standalone\Src

    IRQ Handlers and DMA must be correctly configured.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    con3
    con3Author
    Senior
    August 21, 2018

    Hi @Community member​ ,

    Thank you, as always, for the detailed reply!

    I completely missed that and went directly to the processor based examples.

    Could you possibly expand on this: "IRQ Handlers and DMA must be correctly configured.

    Is there anything to watch out for ?

    Thank you!

    Tesla DeLorean
    Guru
    August 21, 2018

    That the BSP macro's expand to the correct names in the vector table, and are consistent with the BSP MSP code initializing the pins/interface.

    extern SD_HandleTypeDef uSdHandle;
     
    /**
     * @brief This function handles SDMMC1 global interrupt request.
     * @param None
     * @retval None
     */
    void BSP_SDMMC_IRQHandler(void)
    {
     HAL_SD_IRQHandler(&uSdHandle);
    }
     
    /**
    * @brief This function handles DMA2 Stream 6 interrupt request.
    * @param None
    * @retval None
    */
    void BSP_SDMMC_DMA_Tx_IRQHandler(void)
    {
     HAL_DMA_IRQHandler(uSdHandle.hdmatx);
    }
     
    /**
    * @brief This function handles DMA2 Stream 3 interrupt request.
    * @param None
    * @retval None
    */
    void BSP_SDMMC_DMA_Rx_IRQHandler(void)
    {
     HAL_DMA_IRQHandler(uSdHandle.hdmarx);
    }

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    con3
    con3Author
    Senior
    August 21, 2018

    Thank you @Community member​!

    I'll implement this and might have a few follow up questions.

    Thank you for all the help

    con3
    con3Author
    Senior
    October 21, 2018

    Hi @Community member​ ,

    I forgot I asked you about the DMA on the sdcard interface, it seems like I'm having issues and can't get the implementation correct. Did you experience any issues with write failures ?

    I made a forum post : https://community.st.com/s/question/0D50X00009sTkwTSAS/cube-generated-sd-card-with-dma-broken-transfer-complete-for-write

    I've gotten it to do single block writes, but multi-block writes completely fail