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:
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: