cancel
Showing results for 
Search instead for 
Did you mean: 

USB OTG HS - ULPI (Using FatFs Middleware ) Disk Error issue

Abin
Associate III

Hai All,

I am facing an issue on USB File system accessing. Here I am using ULPI protocol for accessing the USB Drive via USB3300 IC.Here I am using an Interrupt method for detecting the USB drive. When we connect, interrupt is happening and File directory is loading.After few seconds or any other operation, if we try to access the file system in USB DISK ERROR is coming.Files are accessing using FatFs and the same FatFs is using for SD crad.Here using SPI protocol and no issues are facing. After analyzing the ff.c file which is generated by Cube IDE, I am getting the macro SS(fr) ( Sector Size )  as Zero. This is the reason that File directory is unable to fetch.But this problem is not in SD crad .How to rectify this issue.

1 ACCEPTED SOLUTION

Accepted Solutions
Abin
Associate III

@FBL 

No, I didn't face any issue on SD card, it is happened only in ULPI. After disabling the pin SOF from the code it is working good.Could you please tell me the root cause behind this, if you know?

View solution in original post

11 REPLIES 11
FBL
ST Employee

Hello @Abin 

 

Have you tried the example firmware FatFs_USBDisk_Standalone? Would you specify the product used to narrow down the possible source of the issue?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Abin
Associate III

Hai @FBL 

I didn't try FatFs_USBDisk_Standalone firmware.Could you please share the link.I am working on I developed the firmware in Free RTOS. Here while connecting the USB drive , the sector size is going to reset, that is it will set as 0

FBL
ST Employee

Hi @Abin 

Great! You can find example FatFs_USBDisk_FreeRTOS as well. You may need to provide more details about the product used (F7, H7, F4xx) otherwise here is an example of implementation

STM32CubeH7/Projects/STM32H743I-EVAL/Applications/FatFs/FatFs_USBDisk_RTOS at b9d11df3020deef82310c88f3d8590d076b43ef7 · STMicroelectronics/STM32CubeH7 (github.com)

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Abin
Associate III

I am using STM32F205VET6 controller. Here only I have tested the firmware.Here I will give you the pat of the code where the issue is exactly happens.The function is  FRESULT find_volume. A part of the code is given below.

 

#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */
 
SS(fs) = ((fs)->ssize);
 
printf("DISK DRIVE NO=%d\n",fs->drv);
 
DRESULT ioctlUSB = disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs));
 
if(ioctlUSB == RES_OK){
 
printf("Sector Size Pointer = %d | Assign = %d |SSize =%d \n",fs->ssize,(fs)->ssize,SS(fs));
 
if( (SS(fs) < _MIN_SS) || (SS(fs) > _MAX_SS))
{
printf("SECTOR SIZE 1 = %d\n",SS(fs));
return FR_DISK_ERR;
}
 
}
else
{
printf("__IO CTL ERROR__\n");
return FR_DISK_ERR;
}
#endif
 
if we check the following condition disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)); then the stack size is getting 0.So it goes to Disk Error
 
FBL
ST Employee

Hi @Abin 

Have you tried increasing the stack size of the disk_ioctl function? You should configure the range of sector size to be supported. 

#define _MIN_SS 512

#define _MAX_SS 1024

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Abin
Associate III

Hai @FBL 

Yes, I fixed this sector size as 512 and 1024.I have a doubt, I have Enabled SOF pin in this protocol.Whether it will create any problem.Do you have any idea?

FBL
ST Employee

I'm not sure about this configuration, but you can isolate it if it's causing the fail. However, application program must no call disk_ioctl() function, It is only called by FatFs file system functions such as, f_mount(), f_read() or f_write(). Do you have issues when trying FatFs micro SD standalone without ULPI interface?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Abin
Associate III

@FBL 

No, I didn't face any issue on SD card, it is happened only in ULPI. After disabling the pin SOF from the code it is working good.Could you please tell me the root cause behind this, if you know?

FBL
ST Employee

Hi again @Abin 

I'm not sure what do you mean by "pin SOF from the code" Is it in the callback function? Maybe the host timer tick is not incrementing as expected for different reasons.  

Otherwise, I'm not sure about the root cause of this issue.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.