cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H753I-EVAL2: HAL_SD_Init() fails at CMD55 with HAL_SD_ERROR_CMD_RSP_TIMEOUT

pranavps
Associate II

I am trying to use the microSD card on the STM32H753I-EVAL2 board with ThreadX and FileX.

I generated the base project using CubeMX with the following configuration:

Board: STM32H753I-EVAL2
Peripheral: SDMMC1 enabled
Middleware: ThreadX + FileX
Option "Is external transceiver present?" = Yes (since the board uses the IP4856CX35)
Default CubeMX clock configuration

However, the generated code fails during initialization at:

HAL_SD_Init(&hsd1);

inside:

MX_SDMMC1_SD_Init()

After debugging further, I found the failure occurs inside SD_PowerON() when sending CMD55 (APP_CMD).

The error returned is:

HAL_SD_ERROR_CMD_RSP_TIMEOUT

From stepping through the code:

SD_PowerON()
-> SDMMC_CmdAppCommand()
-> CMD55
-> HAL_SD_ERROR_CMD_RSP_TIMEOUT

So the card never responds to CMD55.

Additional observations: CubeMX configures the SDMMC1 kernel clock to 150 MHz. From the reference manual / datasheet, it seems the maximum SDMMC kernel clock should be around 125 MHz.I am not sure if this clock configuration could be related to the issue.

But the initialization still fails at CMD55.

Questions:Is a 150 MHz SDMMC kernel clock supported on STM32H753?Is there any additional initialization required for the external SD transceiver (IP4856CX35) on this board?Is there a known issue with CubeMX generated SDMMC code for STM32H753I-EVAL2?

10 REPLIES 10
AScha.3
Super User

Set the clock for SD-card to 50MHz .

As this is max frequency for SD-card.

And set 1bit mode at first, as 4bit mode more difficult.

 

If you feel a post has answered your question, please click "Accept as Solution".
static void MX_SDMMC1_SD_Init(void)
{
  /* USER CODE BEGIN SDMMC1_Init 0 */
  /* USER CODE END SDMMC1_Init 0 */

  /* USER CODE BEGIN SDMMC1_Init 1 */
  /* USER CODE END SDMMC1_Init 1 */

  hsd1.Instance = SDMMC1;
  hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
  hsd1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
  hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B;
  hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
  hsd1.Init.ClockDiv = 0;
  hsd1.Init.TranceiverPresent = SDMMC_TRANSCEIVER_PRESENT;
  if (HAL_SD_Init(&hsd1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN SDMMC1_Init 2 */
  /* USER CODE END SDMMC1_Init 2 */
}

 

image.png

tried with the above configuration . Still no luck.

Still fails
HAL_SD_Init ->
HAL_SD_InitCard ->
SD_PowerON

 

while ((count < SDMMC_MAX_VOLT_TRIAL) && (validvoltage == 0U))
{
  /* SEND CMD55 APP_CMD with RCA as 0 */
  errorstate = SDMMC_CmdAppCommand(hsd->Instance, 0);
  if (errorstate != HAL_SD_ERROR_NONE)
  {
    return errorstate; //fails here with SDMMC_ERROR_CMD_RSP_TIMEOUT
  }

 


Edited to apply source code formatting - please see How to insert source code for future reference.

Well, i dont know, what you doing there....

my access to sd-card is just this : 

1. the cube generated code ... (static void MX_SDMMC2_SD_Init(void); ) as it is.

2. in filex ->  I mount card

 void fx_app_thread_entry(ULONG thread_input)
 {

  UINT sd_status = FX_SUCCESS;

/* USER CODE BEGIN fx_app_thread_entry 0*/
  sd_statusx = -1;
  tx_thread_sleep(500);									// wait 500ms for sdcard startup
/* USER CODE END fx_app_thread_entry 0*/

/* Open the SD disk driver */
  sd_status =  fx_media_open(&sdio_disk, FX_SD_VOLUME_NAME, fx_stm32_sd_driver, (VOID *)FX_NULL, (VOID *) fx_sd_media_memory, sizeof(fx_sd_media_memory));

/* Check the media open sd_status */
  if (sd_status != FX_SUCCESS)
  {
     /* USER CODE BEGIN SD DRIVER get info error */
	  printf(" SD mount error ! \r\n");
          Error_Handler(); 
    /* USER CODE END SD DRIVER get info error */
  }

btw

Wait 0.5 s after start/power_up  is important, most cards not responding without some start delay time.

If you feel a post has answered your question, please click "Accept as Solution".

Hello @pranavps 

Please refer to the examples below:

STM32CubeH7/Projects/STM32H743I-EVAL/Examples/SD at master · STMicroelectronics/STM32CubeH7 · GitHub

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

I’ve mostly completed porting my application to the STM32H753I-EVAL2, but I’m facing an inconsistent issue with SD card initialization.


Could this be due to a hardware-related issue, such as SD card slot instability or contact problem?Signal integrity / pull-up configuration? SDMMC peripheral misconfiguration (e.g., clock, bus width, or power sequencing)?

Or is there something in the software stack (HAL / BSP / FileX / ThreadX) that might require reinitialization handling after reinsertion?

Attaching main file and ioc file. Any suggestions on what to check would be really helpful.

> I’m facing an inconsistent issue with SD card initialization.

You have to tell in detail, what happens, what works at all, or sometimes not...

otherwise its a guessing game .

If you feel a post has answered your question, please click "Accept as Solution".
The issue I am facing is detailed in the very first post in this thread.

Whatever cubemx generated when sdcard1 is enabled, after creating the
project based on the board selector(EVAL2) always ends up in the sd card
init failure, which shouldn't be ideally happening with the default cubemx
generated code.

Please check the jtag debugging results in the said post, have posted the
chain of function calls till the failure. It always fails at CMD55 with RSP
timeout error.

As long as sd card init fails I cannot proceed with the sd card enumeration.

I have seen many other similar posts observing the same issue on EVAL2, But
none of them seem to have an accepted solution. Many of those days the
issue is with voltage switching to 1.8v from 3.3, but this particular error
occurs before the voltage switch.

>The issue I am facing is detailed in the very first post in this thread.

No.

There you had 150M as clock, that never can work.

Now - new tests needed. 

If still same problem, there never was a working connection to the card.

And check (in PC) card: still working fine ? (I killed a card , just by trying to clock it with 100MHz.)

So just do what i showed : try to start /mount the card;

now need a scope: look at clk and cmd line , beginning communication with sd-card is always:

- at 3v3 level , check VCC of card also, 3v3 is mandatory.

- cmd/clk at init is at about 400kHz , you should see some "bursts" here.

- if this looks ok, then look at D0 data line: here the first data coming (if card and cpu understand each other),

but now at full clk speed, 25 or 50 Mbit, depends on what the card was "telling" .

+ for every test: power down/up the check the "start" on the lines to card , cmd/clk/D0 . Always power cycle !

If you feel a post has answered your question, please click "Accept as Solution".
As I mentioned in the later posts , I have already reduced the sdmmc kernel
clock to 50Mhz , and clock div is 0. So it should be 50Mhz itself (during
initialisation the code itself calculates the clock div to maintain under
400Khz which is a requirement for sd card)