cancel
Showing results for 
Search instead for 
Did you mean: 

uSD not work in Riverdi 121STM32H7_1_6

MauFanGilaMedical
Associate II

Hello everybody.

I bought Riverdi STM32 Embedded Display RVT121HVSNWC00-B

I create my first project using touch GFX.

I generate code and import it in STM32CubeIDE.

I format FAT32 a 128G uSD using custom program.

I plug the uSD into adapter and I write this code.

MauFanGilaMedical_0-1738662023020.png

fresult is FS_NOT_READY and I don't understand the reason.

 

 

Here my configuration.

MauFanGilaMedical_1-1738662133868.png

 

MauFanGilaMedical_2-1738662171581.png

MauFanGilaMedical_3-1738662191502.png

MauFanGilaMedical_5-1738662258114.png

MauFanGilaMedical_6-1738662300821.png

MauFanGilaMedical_8-1738662336348.png

MauFanGilaMedical_9-1738662368308.png

 

MauFanGilaMedical_10-1738662387394.png

MauFanGilaMedical_11-1738662407131.png

MauFanGilaMedical_12-1738662431601.png

MauFanGilaMedical_13-1738662449488.png

I notice in the main that there is FATFS initialization

MauFanGilaMedical_14-1738662530908.png

but I don't find a call to MX_SDMMC1_SD_Init.

If I force this call after FATFS initlization the code run in ErrorHandler, but if I inpect hsd1.SdCard struct I see that card property are read correctly (I believe).

MauFanGilaMedical_15-1738662666669.png

BlockSize x BlockNbr = 128G !! OK

 

Can someone help me ?

Thanks in advice

1 ACCEPTED SOLUTION

Accepted Solutions
MauFanGilaMedical
Associate II

Now I can use uSD with this modification.

It's my first time for STM32H757 (and first ST time) so I honestly say that I don't know why it works.

 

1. Replace 0x00 with SD_PRESENT line 297 in bsp_driver_sd.c

MauFanGilaMedical_0-1739267547676.png

 

2. Enable SDMMC1 global interrupt

MauFanGilaMedical_1-1739267608868.png

 

3. Set SDMMC clock divide factor to 4

MauFanGilaMedical_2-1739267662217.png

 

4. Disable CPU DCache

MauFanGilaMedical_3-1739267719156.png

 

5. Enable this defines in /CM7/FATFS/Target/sd_diskio.c

MauFanGilaMedical_4-1739267785864.png

 

With this modifications mount, read and write to uSD work.

 

I would want to lay the CPU DCache Enabled because to being not enabled let me lose computation power.

 

If someone has some suggestion I will appreciate.

View solution in original post

3 REPLIES 3
MauFanGilaMedical
Associate II

If I could help ...

I inspect the code step By step and I notice that my SD card is CARD_V2_X and that code seems go properly until it reaches this instruction in stm32h7xx_hal_sd.c

 

MauFanGilaMedical_0-1738740879399.png

 

error state is 4 (HAL_SD_ERROR_CMD_RSP_TIMEOUT) that is different from HAL_SD_ERROR_NONE and so it returns UNSUPPORTED_FEATURE.

 

Here the stack

MauFanGilaMedical_1-1738740982755.png

MauFanGilaMedical
Associate II

I inspect SDMMC_CmdAppCommand ... I've tried to add some HAL_Delay (commented Mauro Fantina) but the problem still remain

MauFanGilaMedical_2-1738742648851.png

MauFanGilaMedical
Associate II

Now I can use uSD with this modification.

It's my first time for STM32H757 (and first ST time) so I honestly say that I don't know why it works.

 

1. Replace 0x00 with SD_PRESENT line 297 in bsp_driver_sd.c

MauFanGilaMedical_0-1739267547676.png

 

2. Enable SDMMC1 global interrupt

MauFanGilaMedical_1-1739267608868.png

 

3. Set SDMMC clock divide factor to 4

MauFanGilaMedical_2-1739267662217.png

 

4. Disable CPU DCache

MauFanGilaMedical_3-1739267719156.png

 

5. Enable this defines in /CM7/FATFS/Target/sd_diskio.c

MauFanGilaMedical_4-1739267785864.png

 

With this modifications mount, read and write to uSD work.

 

I would want to lay the CPU DCache Enabled because to being not enabled let me lose computation power.

 

If someone has some suggestion I will appreciate.