Issue with SD Card Setup on STM32N6570-DK (FX_BOOT_ERROR on fx_media_open)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-19 5:33 AM
Hello,
I am working with an STM32N6570-DK board and facing an issue while setting up the SD card. I created a project using TouchGFX Designer, generated the code, and opened the .ioc file. In there, I enabled SDMMC2 with 4-bit Wide mode and enabled global interrupt:
After checking the schematics, I noticed that the CK pin was incorrect, so I assigned the correct pin (PC2:(
I made the following additional configurations:
- Changed all SDMMC2 pins to pull-up and set Max output speed to Very High
- Enabled PWR_SD_EN (PQ7) as output level high with context Free
- Changed clock from HCLK to IC4 (should not affect anything)
- Enabled SD_DETECT (PN12) to detect when the SD card is inserted or removed
- Enabled EXTI Line4 and EXTI Line12 for interrupts
- Enabled FileX with mostly default settings, except for increased memory and FX driver initialization:
After this setup, I attempted to initialize the SD card with the following call:
fx_media_open(&sdio_disk, "SDIO_DISK", fx_stm32_sd_driver, NULL, fx_sd_media_memory, FX_STM32_SD_DEFAULT_SECTOR_SIZE);
However, this returns error 0x01 (FX_BOOT_ERROR). Upon further debugging, I found the issue occurs in this section of fx_stm32_sd_driver.c:
case FX_DRIVER_BOOT_READ:
{
/* the boot sector is the sector zero */
status = sd_read_data(media_ptr, 0, media_ptr->fx_media_driver_sectors, unaligned_buffer);
if (status != FX_SUCCESS)
{
media_ptr->fx_media_driver_status = status;
break;
}
/* Check if the sector 0 is the actual boot sector, otherwise calculate the offset into it.
Please note that this should belong to higher level of MW to do this check and it is here
as a temporary work solution */
partition_start = 0;
status = _fx_partition_offset_calculate(media_ptr -> fx_media_driver_buffer, 0,
&partition_start, &partition_size);
/* Check partition read error. */
if (status)
{
/* Unsuccessful driver request. */
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
break;
}
/* Now determine if there is a partition... */
if (partition_start)
{
if (check_sd_status(FX_STM32_SD_INSTANCE) != 0)
{
media_ptr->fx_media_driver_status = FX_IO_ERROR;
break;
}
/* Yes, now lets read the actual boot record. */
status = sd_read_data(media_ptr, partition_start, media_ptr->fx_media_driver_sectors, unaligned_buffer);
if (status != FX_SUCCESS)
{
media_ptr->fx_media_driver_status = status;
break;
}
}
/* Successful driver request. */
media_ptr -> fx_media_driver_status = FX_SUCCESS;
break;
}
The function sd_read_data() returns FX_SUCCESS, but when inspecting the buffer in the debugger, it is empty (no data is present).
Questions:
- What could be causing sd_read_data() to succeed but return an empty buffer?
- Could it be an issue with SDMMC2 configuration, clock settings, or pull-up resistors?
- Do I need additional initialization steps in fx_stm32_sd_driver?
Solved! Go to Solution.
- Labels:
-
SDIO-SDMMC
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-12 11:17 PM
Hello @Saket_Om
When I tried to make the SD card work, there was no support for FileX at the time. After updating HALs, I recreated the project with FileX, and everything worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-12 8:32 AM
Hello @TerZer
Does the SDMMC work without fileX?
Saket_Om
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-12 11:17 PM
Hello @Saket_Om
When I tried to make the SD card work, there was no support for FileX at the time. After updating HALs, I recreated the project with FileX, and everything worked.
