Hello Everyone, I'm following these steps ( www2.keil.com/.../ ) in order to understand USB Hosting and create my own application. Unfortunately i encountered a problem. I arrived at Step 3 and i added the Host support correctly but i can't access the usb stick. When i debug the USBH_MSC_DriveMount function , i found that wether the actual usb stick is connected or not , the finit function returns fsDriverError. I checked on Documentation and found out that it means it failed to initialize the drive but i couldn't find a way how to fix it or what it actually means. I'll be glad if you could help me solve my problem and thank you .
I'm using STM32F429
Are you using the Discovery Kit or some other hardware?
The Discovery Kit has current limits for the USB Memory Sticks and older Memory Sticks frequently exceed the limits.
You may also check the status return code from the *fmount* function. The return value gives you a hint of what actually fails. Here is more information: www.keil.com/.../group__system__routines.html
And you should ensure that the USB Memory Stick is formatted using the FAT file system. Also it should have not partitions (some sticks come pre-formatted with a partition).
I did read your thread again, and sorry my answer was not to the point. You did actually analyze the return values already.
I suggest now: - verify the Pin assignments of the USB Host interface (this can be very tricky and a small mistake makes it fail) - finit should call the related CMSIS Driver. This driver gets initialized with two functions: ARM_USBH_Initialize and ARM_USBH_PowerControl. Both functions should return ARM_DRIVER_OK. I suggest you set a breakpoint at the end of each function to check that.
Thank you for your answer. Yes i'm using the Discovry kit. I'm sure that my USB Stick is formated to FAT32. I'm pretty sure i'm using GPIOC 4 as VBUS Power On/Off and GPIOC 5 as OverCurrent Detection Pin. I will check it again. I will debug where you told me and see what will be the returns of the functions.
Hello again, I Rechecked the Over Current Pin and the Power On/Off , they are both assigned correctly. If there's another group of pins that i have to check please let me know.
This is my code
void Thread (void const *argument) { static int result; static FILE *f; stats = USBH_Initialize (0); while (1) { result = USBH_MSC_DriveMount ("U0:"); if (result == USBH_MSC_OK) { f = fopen ("Test.txt", "r"); if (f) { fread (fbuf, sizeof (fbuf), 1, f); fclose (f); } } osDelay (1000); } }
The USBH_Initialize (0) returns usbOk The USBH_MSC_DriveMount ("U0:") returns -1 (USBH_MSC_ERROR) Debugging the USBH_MSC_DriveMount ("U0:") shows that the finit function shows that it returns fsDriverError
I didn't find a way to access the finit function but I checked the returns on both ARM_USBH_Initialize and ARM_USBH_PowerControl by checking register value at the end of the function. Both functions return ARM_DRIVER_OK.
I hope this gives you a better idea on what the problem is and thank you for your time
Are you using latest middleware and latest ST pack (pack version 2.5.0)? Can you try a few different USB Sticks just to rule out that you have same problems consistently?
Hi Medhi,
my test did relate to the CMSIS Driver that interfaces to the physical hardware. This driver is implemented in the file USBH_HS_STM32F4xx.c (under CMSIS-Driver component group) and has two functions ARM_USBH_Initialize and ARM_USBH_PowerControl which can give you an indication of the problem.
Both functions should return ARM_DRIVER_OK. I suggest you set a breakpoint at the end of each function to check that.
Thank you all for your help, i updated the DFP to 2.5.0 and i changed the usb stick now everything works. i suppose that the previous usb stick needed too much power
Doesn't first stick still work with new 2.5.0 DFP pack?
I tested it again and now it works.