2020-07-15 10:52 AM
Hi,
I am trying to read a USB flash drive via USB OTG function on a Nucleo-H743ZI2 board.
I am using STM32CubeIDE to generate most of the code automatically and following the example of FatFS_uSD_Standalone comes with the STM32 firmware. The example was reading a micro SD card and I run into some FR_DISK_ERR when using it on USB flash drive.
Setup:
Nucleo-H743ZI2 board
USB 2.0 OTG adapter
USB 2.0 flash drive, 3.72 GB, FAT32
Configuration for .ioc file:
Connectivity: USB_OTG_FS -> Mode: Host_Only, Activate VBUS: VBUS sensing, Activate_SOF
Middleware -> USB_Host -> Class for FS IP: Mass Storage Host Class, Drive_VBUS_FS: GPIOOutput PE1[LD2[Yellow LED]]
Middleware -> FATFS -> USB Disk
480MHz CPU clocks, other clocks are calculated automatically
All others are initialized as default
Problem description:
MX_FATFS_Init(),MX_USB_HOST_Init() and MX_USB_HOST_Process() are generated automatically.
After that f_mount(&USBHFatFS, (TCHAR const*)USBHPath, 0) return FR_OK
f_open(&MyFile, "STM32.TXT", FA_CREATE_ALWAYS | FA_WRITE) return FR_DISK_ERR
Since I get the same return value even without plugging in USB flash drive, I suspect it did not actually see my flash drive. My flash drive lights up, which means power is on.
Please let me know what I missed here. I have attached my complete code and a screenshot of main program as well.
Thank you very much!