2017-10-17 08:57 PM
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
#fatfs #usb-mass-storage-device #sd-cardSolved! Go to Solution.
2017-10-18 10:34 PM
See
http://elm-chan.org/fsw/ff/doc/filename.html
You can pass the drive number in the path name or change the default drive with f_chdrive.
When you use both, a SD drive and a USB drive then you have to link each drive to its driver using FATFS_LinkDriver. In that case you should have two Diskio_drvTypeDef instances (one for SD and one for USB) and it is possible to access both drives without to use unlink and link again.
2017-10-18 10:34 PM
See
http://elm-chan.org/fsw/ff/doc/filename.html
You can pass the drive number in the path name or change the default drive with f_chdrive.
When you use both, a SD drive and a USB drive then you have to link each drive to its driver using FATFS_LinkDriver. In that case you should have two Diskio_drvTypeDef instances (one for SD and one for USB) and it is possible to access both drives without to use unlink and link again.
2017-10-20 04:19 AM
Hi ra hummel.
Thanks for that I got it working. I re-attached the working project above if anyone wants to try it.
1) Insert USB memory stick with a file called 'tfile.txt'. Make sure it has lots of text.
2) Insert micro SD card into the board.
2017-12-07 04:01 AM
Hi Andrew, I have test your code and it work well but when I tried to merge it with my own application, it doesn't work. So I am wondering what you have modified in the librairies to get it work?
Thanks
2017-12-08 04:55 AM
Hi Gregoire,
I have not made any changes to any of the libraries. What hardware are you using?
2021-11-18 08:19 AM
Can you share working code