cancel
Showing results for 
Search instead for 
Did you mean: 

does a 32GByte ultra SD work in FatFS ?

Trevor Jones
Senior

I have a shiny new Samsung EVO 32GB formated as 29.8GB Fat32

will it work ?

I have a H743

tried the FatFS application

it doesn't find the card.

FATFS_LinkDriver fails

22 REPLIES 22

std RTx1 PA9/PA10 for debug port.

turned of the TRANSCEIVER option = 0...

stuck here

DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
{
  DRESULT res = RES_ERROR;
  ReadStatus = 0;
  uint32_t timeout;
#if (ENABLE_SD_DMA_CACHE_MAINTENANCE == 1)
  uint32_t alignedAddr;
#endif
 
  if(BSP_SD_ReadBlocks_DMA((uint32_t*)buff,
                           (uint32_t) (sector),
                           count) == MSD_OK)
  {
    /* Wait that the reading process is completed or a timeout occurs */
    timeout = HAL_GetTick();
    while((ReadStatus == 0) && ((HAL_GetTick() - timeout) < SD_TIMEOUT))     /// <---- stuck here
    {
    }
    /* incase of a timeout return error */
    if (ReadStatus == 0)
    {
      res = RES_ERROR;
    }
    else

Bill Dempsey
Senior

"does a 32GByte ultra SD work in FatFS ?"

I'm able to use one with a F446 running FatFS,,,, I use the mbed libs for SD and not had an issue.

Yeah, wouldn't do that, apt to trash the media. Get READ working 100% first

FS_FileOperations() is some LCD User Interface stuff

Do this first

{

 FATFS *fs;

 DWORD fre_clust, fre_sect, tot_sect;

 /* Get volume information and free clusters of drive 1 */

 res = f_getfree("", &fre_clust, &fs);

 if (res != FR_OK)

 {

  printf("res = %d f_getfree\n", res);

  return;

 }

 switch(fs->fs_type)

 {

  case FS_FAT12 : puts("FAT12"); break;

  case FS_FAT16 : puts("FAT16"); break;

  case FS_FAT32 : puts("FAT32"); break;

  case FS_EXFAT : puts("EXFAT"); break;

  default : puts("Unknown FAT");

 }

 /* Get total sectors and free sectors */

 tot_sect = (fs->n_fatent - 2) * fs->csize;

 fre_sect = fre_clust * fs->csize;

 /* Print the free space (assuming 512 bytes/sector) */

 printsize(tot_sect / 2, "total drive space");

 printsize(fre_sect / 2, "available");

 printsize((tot_sect - fre_sect) / 2, "used");

}

in the sd_diskio_dma

/**

 * @brief Rx Transfer completed callbacks

 * @param hsd: SD handle

 * @retval None

 */

void BSP_SD_ReadCpltCallback(void)

{

 ReadStatus = 1;

}

in the bsp

/**

 * @brief Rx Transfer completed callbacks

 * @param hsd: SD handle

 * @retval None

 */

void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd) // <- make sure you have this

{

 BSP_SD_ReadCpltCallback(); // which calls this, that flags completion

}

Or do without DMA

/**

 * @brief Reads Sector(s)

 * @param lun : not used

 * @param *buff: Data buffer to store read data

 * @param sector: Sector address (LBA)

 * @param count: Number of sectors to read (1..128)

 * @retval DRESULT: Operation result

 */

DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)

{

 DRESULT res = RES_ERROR;

 if(BSP_SD_ReadBlocks((uint32_t*)buff,

            (uint32_t) (sector),

            count, SD_TIMEOUT) == MSD_OK)

 {

  /* wait until the read operation is finished */

  while(BSP_SD_GetCardState()!= MSD_OK)

  {

  }

  res = RES_OK;

 }

 return res;

}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

This is a non-DMA test for the SR1, so same USART1

Should output stats and a directory for card, then clocks/plls

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
I will have to check that when I get home.
but from the code on the forum,
I got this result..
res = 12 f_getfree
hex file ?
cant see your solution
will run it tonight

Yes, the .HEX should give us a go/no-go indication if we're chasing ghosts or not without fighting about the build environment.

Will share source/project with you privately. Currently porting in the DMA plumbing into the SR1 demo

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
getting this:
res = 12 f_getfree
Unknown FAT
total drive space 576883200
available -1704342528
used -2013742080

DMA has to go into 0x24000000 (512KB) SRAM1

/**

 * @brief Configure the MPU attributes.

 * @note  The Base Address 0x24000000 is the SRAM1 accessible by the SDIO internal DMA.

      the configured region is 512Kb size.

 * @param None

 * @retval None

 */

static void MPU_Config(void)

{

 MPU_Region_InitTypeDef MPU_InitStruct;

 /* Disable the MPU */

 HAL_MPU_Disable();

 /* Configure the MPU attributes as WT for SRAM1 */

 MPU_InitStruct.Enable = MPU_REGION_ENABLE;

 MPU_InitStruct.BaseAddress = 0x24000000;

 MPU_InitStruct.Size = MPU_REGION_SIZE_512KB;

 MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;

 MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

 MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;

 MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;

 MPU_InitStruct.Number = MPU_REGION_NUMBER0; // Rank

 MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;

 MPU_InitStruct.SubRegionDisable = 0x00;

 MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

 HAL_MPU_ConfigRegion(&MPU_InitStruct);

 /* Enable the MPU */

 HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);

}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
its pretty cool to have the exact same hardware...
The SR1 is a nice board, seems super stable..
probably just a reflection on the ST processors, very stable, excellent really.
the Cube does work, I found it quite good, but the cube examples are just not there...
ie
maybe ST could do a cube example of SDCard , and or Flash in FS...
so that it just works, like MBED does. @BillDempsey