Skip to main content
Nello Cris
Associate
June 11, 2018
Solved

NUCLEO-F429ZI - SDIO - FatFs Problem

  • June 11, 2018
  • 4 replies
  • 1022 views
Posted on June 11, 2018 at 09:56

Dear All,

I’m new to this forum and to stm32 board. I’m trying to connect an SD Card to my board NUCLEO-F429ZI but I’m having some problems with it.

I use STM32CUBEMX to create the project using the standard peripherals settings.

I put SDIO in SD 4 bit interfacing mode. I do not change anything in clock configuration.

I connect the SD Card directly to SDIO PIN without any resistors as in picture

http://www.openstm32.org/dl422?display

Board PIN    SD Pin

PD2             2 (CMD)

PC8             7 (Dat0)

PC9             8 (Dat1)

PC10            9 (Dat2)

PC11            1 (Dat3)

PC12             5 (CLK)

3.3V             VCC

GND            GND

this is the piece of code:

HAL_UART_Transmit(&huart3, “Start\r\n�, strlen(“Start\r\n�), 0xFFFF);

FRESULT res;

uint32_t wbytes;

uint8_t wtext[] = “text to write logical disk�;

FATFS_LinkDriver(&SD_Driver, SDPath);

if(f_mount(&SDFatFS, (TCHAR const*)SDPath, 0) == FR_OK)

{

HAL_UART_Transmit(&huart3, “Mounted\r\n�, strlen(“Mounted\r\n�), 0xFFFF);

res = f_open(&SDFile, “STM32.TXT�, FA_CREATE_ALWAYS | FA_WRITE);

if (res == FR_OK)

{

HAL_UART_Transmit(&huart3, “Opened\r\n�, strlen(“Opened\r\n�), 0xFFFF);

if(f_write(&SDFile, wtext, sizeof(wtext), (void *)&wbytes) == FR_OK)

{

HAL_UART_Transmit(&huart3, “Written\r\n�, strlen(“Written\r\n�), 0xFFFF);

f_close(&SDFile);

HAL_UART_Transmit(&huart3, “Closed\r\n�, strlen(“Closed\r\n�), 0xFFFF);

}

} else {

char msg

http://www.openstm32.org/15

;

sprintf(msg, “Error open: %d\r\n�, res);

HAL_UART_Transmit(&huart3, (uint8_t *)msg, strlen(msg), 0xFFFF);

}

}

FATFS_UnLinkDriver(SDPath);

The function F_MOUNT return FR_OK but the program stops there. Sometimes the f_open function return Error 3: Device not ready. Any suggestion?

Thank you for your time.

M

    This topic has been closed for replies.
    Best answer by Nello Cris
    Posted on June 12, 2018 at 07:56

    I found the solution disabling the use of DMA Template (USE_DMA_CODE_SD) in FatFS configuration in CubeMX. There are some misconfiguration in DMA code (as Imen suggested document). Thank you all for help.

    Nello

    4 replies

    Tesla DeLorean
    Guru
    June 11, 2018
    Posted on June 11, 2018 at 13:00

    People seem to have a lot of issues with CubeMX in this regard. I just port the examples in the HAL trees.

    You should instrument the DISKIO code and look for errors reported there.

    Check if you have dependencies on a Card Detect pin.

    Here using the two GPIO below the SDMMC signals for the CD, and WP pins0690X00000604Y3QAI.jpg

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    ST Technical Moderator
    June 11, 2018
    Posted on June 11, 2018 at 15:19

    Hello,

    You can follow this document

    https://community.st.com/0D50X00009bMM7JSAW

     which helps you to configure CubeMX + SDIO +

    DMA + FatFS.

    I hope it will help you.

    With Regards,

    Imen.

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Tesla DeLorean
    Guru
    June 11, 2018
    Posted on June 11, 2018 at 18:23

    Are we sure these ideas are bullet-proof? Lot of forum traffic seems to suggest otherwise.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Nello Cris
    Nello CrisAuthorBest answer
    Associate
    June 12, 2018
    Posted on June 12, 2018 at 07:56

    I found the solution disabling the use of DMA Template (USE_DMA_CODE_SD) in FatFS configuration in CubeMX. There are some misconfiguration in DMA code (as Imen suggested document). Thank you all for help.

    Nello