cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to use USB to read/write to files from MCU

Priyank
Associate III

Hi I am using the STM32F7 MCU to use a usb. I can get the USB connected however, when I try to run debug, the application hard faults, and I can't trace the error. I was hoping to get a reference to a tutorial from STM regarding reading/writing to USB. I have the pinout configuration correct. I am using USB_OTG_FS Host Only, Mass Storage Host Class. In FATFS I adjusted the parameters USE_LFN to be enabled with static working buffer on the BSS, I disabled FS_REENTRANT. 

3 REPLIES 3
urbito
Senior

You should have a look on the USB_MSC or Ux_Device_MSC examples if your goal is to make the MCU to be detected as a mass storage device when you connect it through USB to a HOST PC.

 

Greetings

MOBEJ
ST Employee

Hello @Priyank , 

We recommend trying the USB application for the STM32F7 MCU available on our GitHub. For example, the USB_Host/MSC_Standalone  example demonstrates how to use the STM32F7xx USB OTG Host to operate with a USB flash drive using Bulk Only Transfer (BOT) and SCSI commands, combined with the FatFs file system.

This example should help resolve your issue.

Regards,

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.

Hi I think I may have misworded my situation. When a USB is connected to the MCU, the mcu can read/write whatever is on the USB, most examples online just use Mass Storage class and use the device as a host. Is this incorrect? I got the hard fault to stop, I increased the USBH_PROCESS_STACK_SIZE to 1024, but now when the usb is connected it hits the HOST USER CONNECTION, then goes straight to HOST_USER_UNRECOVERED_ERROR. And keeps looping.