cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with SD Card Setup on STM32N6570-DK (FX_BOOT_ERROR on fx_media_open)

TerZer
Associate II

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:


image.png

After checking the schematics, I noticed that the CK pin was incorrect, so I assigned the correct pin (PC2:(
image.pngTerZer_0-1742385627511.png

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:

TerZer_1-1742386159071.png

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:

  1. What could be causing sd_read_data() to succeed but return an empty buffer?
  2. Could it be an issue with SDMMC2 configuration, clock settings, or pull-up resistors?
  3. Do I need additional initialization steps in fx_stm32_sd_driver?
0 REPLIES 0