SDMMC on STM32H735G-DK failed at connect

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
mavilon
Posts: 2
Joined: Sun Mar 23, 2025 11:22 am

SDMMC on STM32H735G-DK failed at connect

Post by mavilon »

Hi Giovanni,

I'm trying to enable SD card using SDMMC1 on STM32H735G development kit.
However I couldn't get the card connect using sdcConnect() function as it always return failed.
I added this code to the demo project and enable SDMMC in mcuconf.h and enabled HAL_USE_SDC in halconf.h

But no matter how I try it will end up fail on sdcConnect().

My version is most recent on master, last commit on 2025-03-18 SHA:46235d3849250f546d16726b5d4cdb64ba84131f

Please guide me how to enable SDMMC successfully on ChibiOS platform

Thank you

Code: Select all


  halInit();
  chSysInit();
 
  sdcStop(&SDCD1);

  chThdSleepMilliseconds(50);
  sdcInit();
  chThdSleepMilliseconds(50);
  sdcObjectInit(&SDCD1);
  chThdSleepMilliseconds(50);
  /* Reconfigures USART3 ports (PD8, PD9) */
  palSetPadMode(GPIOD, 8, PAL_MODE_ALTERNATE(7));
  palSetPadMode(GPIOD, 9, PAL_MODE_ALTERNATE(7));

  SerialConfig ser_cfg = {
      921600,
      0,
      USART_CR2_STOP1_BITS,
      0,
  };
  /*
   * Activates the serial driver
   */
  sdStart(&SD3, &ser_cfg);

  debug_print("Hello World!\r\n");
 
  palSetPadMode(GPIOC, 8, PAL_MODE_ALTERNATE(12) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP);  // SDMMC1_D0
  palSetPadMode(GPIOC, 9, PAL_MODE_ALTERNATE(12) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP);  // SDMMC1_D1
  palSetPadMode(GPIOC, 10, PAL_MODE_ALTERNATE(12) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP); // SDMMC1_D2
  palSetPadMode(GPIOC, 11, PAL_MODE_ALTERNATE(12) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP); // SDMMC1_D3
  palSetPadMode(GPIOC, 12, PAL_MODE_ALTERNATE(12) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP); // SDMMC1_CK
  palSetPadMode(GPIOD, 2, PAL_MODE_ALTERNATE(12) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP);  // SDMMC1_CMD

  static const SDCConfig sdccfg_1bit = {
      .bus_width = SDC_MODE_1BIT,
      .slowdown = 50};

  // sdcStop(&SDCD1);
  sdcStart(&SDCD1, &sdccfg_1bit);

  chThdSleepMilliseconds(500);

  if (sdcConnect(&SDCD1) == HAL_SUCCESS)
  {
    debug_print("SD card connected in 1-bit mode!\r\n");
   
  }
  else
  {

    debug_print("SD Connect failed!\r\n");
  }
 
 
joaquin
Posts: 49
Joined: Sat Jan 22, 2011 8:44 pm
Has thanked: 1 time
Been thanked: 3 times

Re: SDMMC on STM32H735G-DK failed at connect

Post by joaquin »

I had just posted the same problem with an Aliexpress board using the same CPU. Giovanni suggested to try the demo incuded at /demos/STM32/RT-VFS-FATFS and prefixing all FatFS structures with "__nocache_", to avoid the cache nightmare of this CPU.
Right now I'm comparing that demo with my code, but I haven't found yet any difference. I have to try the suggestion on prefixing that string to all the structures of FatFs.
Please, let me know if you managed to solved it
mavilon
Posts: 2
Joined: Sun Mar 23, 2025 11:22 am

Re: SDMMC on STM32H735G-DK failed at connect

Post by mavilon »

I tested the H735 development kit further with SD card tester code created using CubeMX without OS.
The result is OK

This is the debug output

Code: Select all

......
[17:04:07:855] Block 1596, wrote 65536 bytes in 16 ms␊
[17:04:07:864] Block 1597, wrote 65536 bytes in 8 ms␊
[17:04:07:874] Block 1598, wrote 65536 bytes in 10 ms␊
[17:04:07:884] Block 1599, wrote 65536 bytes in 9 ms␊
[17:04:07:886] ␊
[17:04:07:886] Wrote 104857600 bytes in 14.225 s, throughput = 7314 KB/s␊
[17:04:07:888] ␊
[17:04:24:162] File read-back OK, size = 104857600 bytes␊
[17:04:24:164] Read 104857600 bytes in 16.276 s, throughput = 6400 KB/s␊
[17:04:24:164] Write test done.␊




I also tested with another board from WeAct using STM32H723
It has similar issue where CubeMX generated code can run with same speed as this development board
But in ChibiOS seem like SDMMC cannot read the card

I only have this two development kit that has SD card in SDIO mode.
I think it might be something related to the SDMMCv2 but I couldn't point out where it fail so I tested with various SDIO CMD to see the response

Code: Select all

[21:43:50:682] ========================================␍␊
[21:43:50:683] SD Card Subsystem Initialization␍␊
[21:43:50:683] ========================================␍␊
[21:43:50:683] Configuring card detect pin (PORT <0x8d>, PIN 4)...␍␊
[21:43:50:684] Starting card detection timer...␍␊
[21:43:50:684] Initial card detection state: PRESENT␍␊
[21:43:50:684] SD card initialization complete␍␊
[21:43:50:685] ========================================␍␊
[21:43:50:686] ␍␊
[21:43:50:686] ␍␊
[21:43:50:686] -------- SD CARD DETECTED --------␍␊
[21:43:50:784] Initializing SD card using CubeMX-style approach...␍␊
[21:43:50:805] SDMMC clock: 12207031 Hz, calculated divider: 15␍␊
[21:43:50:825] Waiting 1 ms for 74 clock cycles...␍␊
[21:43:50:845] Performing complete manual SD card initialization sequence...␍␊
[21:43:51:003] Sending CMD0...␍␊
[21:43:51:008] CMD0 sent successfully␍␊
[21:43:51:058] Sending CMD8...␍␊
[21:43:51:062] CMD8 response: 0x000001aa␍␊
[21:43:51:063] Card is SD v2.0 or later␍␊
[21:43:51:063] Sending CMD55...␍␊
[21:43:51:063] CMD55 status: 0x00002000␍␊
[21:43:51:074] CMD55 status: 0x00000040␍␊
[21:43:51:074] CMD55 response: 0x00000120␍␊
[21:43:51:076] Sending ACMD41 with arg: 0x40300000...␍␊
[21:43:51:076] ACMD41 status: 0x00002000␍␊
[21:43:51:084] ACMD41 status: 0x00000001␍␊
[21:43:51:084] ACMD41 CRC failed␍␊
[21:43:51:184] Sending CMD55...␍␊
[21:43:51:184] CMD55 status: 0x00002000␍␊
[21:43:51:193] CMD55 status: 0x00000040␍␊
[21:43:51:193] CMD55 response: 0x00000120␍␊
[21:43:51:195] Sending ACMD41 with arg: 0x40300000...␍␊
[21:43:51:195] ACMD41 status: 0x00002000␍␊
[21:43:51:204] ACMD41 status: 0x00000001␍␊
[21:43:51:205] ACMD41 CRC failed␍␊


But I'm no expert on SDIO stuff so I don't know how ST lib can work.

Hope this help you find what's wrong and can guide me what we can do to make it work

Thanks
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SDMMC on STM32H735G-DK failed at connect

Post by Giovanni »

Hi,

I just tested the RT-VFS-FATFS demo on an STM32H735G-DK/DK32H735G$AT2 and the card is mounted as expected.

The board is marked as MB1520-H735I-C02/A211200190, is that your same revision?

Giovanni
joaquin
Posts: 49
Joined: Sat Jan 22, 2011 8:44 pm
Has thanked: 1 time
Been thanked: 3 times

Re: SDMMC on STM32H735G-DK failed at connect

Post by joaquin »

mavilon wrote:I tested the H735 development kit further with SD card tester code created using CubeMX without OS.
The result is OK

This is the debug output

Code: Select all

......
[17:04:07:855] Block 1596, wrote 65536 bytes in 16 ms␊
[17:04:07:864] Block 1597, wrote 65536 bytes in 8 ms␊
[17:04:07:874] Block 1598, wrote 65536 bytes in 10 ms␊
[17:04:07:884] Block 1599, wrote 65536 bytes in 9 ms␊
[17:04:07:886] ␊
[17:04:07:886] Wrote 104857600 bytes in 14.225 s, throughput = 7314 KB/s␊
[17:04:07:888] ␊
[17:04:24:162] File read-back OK, size = 104857600 bytes␊
[17:04:24:164] Read 104857600 bytes in 16.276 s, throughput = 6400 KB/s␊
[17:04:24:164] Write test done.␊

Mavillon, with a STM32H743 board from weact, I also was unable to initialice the SD Card, but your hint of using CubeMX code to initialice the board also worked for me.
However, I'm not able to get FatFs mount the SD Card. Would you mind passing your code to test FatFs?
Post Reply