AnsweredAssumed Answered

[FATFs] Opening file on USB stick returns FR_DISK_ERR

Question asked by smrtkai on Jun 27, 2016
Latest reply on Sep 6, 2016 by smrtkai
Hi,
I want to write some data to a file on a usb stick. I have setup a new project with STM32CubeMX for the STM32F429I discovery board. 

My STM32CubeMX configuration:
USB_OTG_HS: Internal FS Phy - Host Only
USB_HOST: Class for HS IP: Mass Storage Host Class
FATFS: USB Disk

My Code in the main-loop:
while(1) {
  /* USER CODE END WHILE */
    MX_USB_HOST_Process();


  /* USER CODE BEGIN 3 */
    switch(Appli_state) {
      case APPLICATION_START:
        
        if (retUSBH != 0) {
          Error_Handler();
        }
      
        fres = f_mount(&USBFatFs, (TCHAR const*)USBH_Path, 0);
        if(fres != FR_OK) {
          Error_Handler();
        }
        
        fres = f_open(&MyFile, "STM32.TXT", FA_READ);
        if(fres != FR_OK) {
          Error_Handler();
        }
        ...
        
        break;
 
      default:
        break;
    }

When I try to open a file, f_open returns FR_DISK_ERR. Can anyone give me some advice, what might be wrong.

1. "FatFS: Link the USBH driver" is successful => retUSBH = 0
2. Mount is successful => FR_OK
3. Opening file fails => FR_DISK_ERR

So there might be some configuration issue for FATFS or with USB. 

Outcomes