AnsweredAssumed Answered

Link_driver failure

Question asked by piet t on Jan 17, 2018
Latest reply on Feb 11, 2018 by piet t

Hey everyone,

 

For some reason I can mount, open and write to a SDcard. Although for some reason I cant use the LinkDriver function.

 

I have the function setup as if(FATFS_LinkDriver(&SD_Driver, SDPath)==0) and when it enters, it fails because disk.nbr seems to always be 1 no matter what I do.

 

Does anyone know what could be causing this? I have one sdcard connected in 4bit sdio mode.

 

A little stumped as it seems to be linked before I even call the function. I also dont have the MX_FATFS_Init(); in the code, so it couldn;t be linked there. Completely Cube generated.

 

 

int main(void)
{

 

  /* USER CODE BEGIN 1 */

 

  /* USER CODE END 1 */

 

  /* Enable I-Cache-------------------------------------------------------------*/
  SCB_EnableICache();

 

  /* Enable D-Cache-------------------------------------------------------------*/
  SCB_EnableDCache();

 

  /* MCU Configuration----------------------------------------------------------*/

 

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

 

  /* USER CODE BEGIN Init */

 

  /* USER CODE END Init */

 

  /* Configure the system clock */
  SystemClock_Config();

 

  /* USER CODE BEGIN SysInit */

 

  /* USER CODE END SysInit */

 

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_SDMMC1_SD_Init();

 


  /* USER CODE BEGIN 2 */
uint32_t wbytes;
uint32_t bytesread;
const char wtext [] = "Hello\0";
char rtext[20]= {0};
 volatile FRESULT res;
 volatile FRESULT res1;
 volatile FRESULT res2;
 //HAL_SD_Init(&hsd1);

 

  if(FATFS_LinkDriver(&SD_Driver, SDPath)==0){
      res = f_mount(&SDFatFS,SDPath,1);
      if(res == FR_OK){
        res2 =f_open(&SDFile, "lat11.txt",FA_CREATE_ALWAYS | FA_WRITE);
       res1 = f_write(&SDFile, wtext, sizeof(wtext), (void *)&wbytes);
  //     res = f_read(&SDFile, rtext, sizeof(wtext), (void *)&bytesread);
          f_close(&SDFile);
      }

 

}

 

  /* USER CODE END 2 */

 

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

 

  /* USER CODE BEGIN 3 */

 

  }
  /* USER CODE END 3 */

 

}

Outcomes