AnsweredAssumed Answered

Using FatFs to access SD Card and USB Mass Storage Device

Question asked by Andrew Hazelton on Oct 18, 2017
Latest reply on Dec 8, 2017 by Andrew Hazelton

Compiler:           IAR Workbench v8.11.3

Middleware’s:   FatFs & STM32_USB_Host

Hardware:          STM32746G Discovery Board

HAL Version:      V1.8.0

Demo Projects:   C:\STM32Cube_FW_F7_V1.8.0\Projects\STM32746G-Discovery\Applications\USB_Host\MSC_Standalone  AND  C:\STM32Cube_FW_F7_V1.8.0\Projects\STM32746G-Discovery\Applications\FatFs\FatFs_uSD

 

Project:

I have merged together the below two STM32Cube_FW_F7_V1.8.0 Discovery Applications into the one project (attached):

1)  MSC_Standalone – USB host mass storage class demo project.

2)  FatFs_uSD – File system using micro SD card.

My goal is to use the FatFs to open both the USB memory stick and the micro SD card. Then to transfer a .txt file from the USB memory stick to the micro SD card.

 

Problem:

All of the functions f_open(), f_read(), f_write() and f_close() will only work on the first storage device (SD or USB) that you use the FATFS_LinkDriver() and f_mount() on. How do you tell the hardware drivers disk_read() and disk_write() which storage device (SD or USB) you intend to use when you call the f_open() function?

If you have already used the FATFS_LinkDriver() and f_mount() function to link the micro SD card, do you then have to use the FATFS_UnLinkDriver() function to unlink the hardware SD drivers before you can then link the USB Host drivers?

I have already set “_VOLUMES   2” in ffconf.h

 

Attachment: 

Please un-zip the attached project into the below directory:

C:\STM32Cube_FW_F7_V1.8.0\Projects\STM32746G-Discovery\Applications\USB_Host

Outcomes