cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX - using FATFS when ''Host supporting all classes'' is selected

Marcin Pociecha
Associate
Posted on December 09, 2016 at 13:47

Hi guys! I want to configure my Nucleo board to use USB Host for pendrive and HID (keyboard). I'm creating a project using STM32CubeMX. When I set USB_HOST -> Host supporting ALL classes, I can't select FATFS -> USB Stick (checkbox is disabled). I'm attaching a screenshot below. How can I configure this functionality?

#stm32 #hid #usb-host #stm32cubemx
3 REPLIES 3
Imen.D
ST Employee
Posted on December 09, 2016 at 15:56

Dear

yellowbit

USB Disk is based on USB Host Mass Storage Class (MSC).

S

et USB_HOST to

Mass Storage Host Class, this will enable FATFS: USBDisk.

These user manualshelp you inthis topicto havemoreideaabout

which

functions FatFS needs integrating for USB Disk:

-

http://www.st.com/content/ccc/resource/technical/document/user_manual/61/79/2b/96/c8/b4/48/19/DM00105pdf/files/DM00105pdf/jcr:content/translations/en.DM00105pdf

:'Developing Applications on STM32Cube with FatFs'provides a description of how to use the STM32Cube firmware components with a generic FAT File System (FatFs).

-

http://www.st.com/content/ccc/resource/technical/document/user_manual/b8/5a/28/c2/cf/b6/47/d6/DM00105pdf/files/DM00105pdf/jcr:content/translations/en.DM00105pdf

User manual STM32Cube USB host library

-

http://www.st.com/en/embedded-software/stsw-stm32html

User manual STM32F105xx, STM32F107xx, STM32F2xx and STM32F4xx USB On-The-Go host and device library.

I suggest you have a look to the

FatFs

example within your firmware package to develop yourapplication using most of the functions offered by FatFs.

Hope this help you.

Best Regards

-Imen-

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Yonathan Foto
Associate II
Posted on March 31, 2017 at 19:44

Hey

Pociecha.Marcin

,

When in USB_HOST->

Host supporting ALL classes you must define the user_diskio.cfile yourself.

1) Generate the project as

USB_HOST ->Mass Storage Host Class &

FATFS -> USB Stick

, then open the project and look at the file usbh_diskio.c in the Middlewares/FatFs folder. Copy/Save the file for later.

2) Regenerate the project as

USB_HOST -> Host supporting ALL classes &FATFS -> User Defined, then open the project and look at the file user_diskio.c in the Application/User folder.

3) Finally modify the functions in user_diskio.c:

DSTATUS USER_initialize (BYTE pdrv);

DSTATUS USER_status (BYTE pdrv);

DRESULT USER_read (BYTE pdrv, BYTE *buff, DWORD sector, UINT count);

so that they work the same way the functions in usbh_diskio.c:

DSTATUS USBH_initialize (BYTE);

DSTATUS USBH_status (BYTE);

DRESULT USBH_read (BYTE, BYTE*, DWORD, UINT);

FCR
Associate III
Posted on April 03, 2017 at 14:13

Hi Marcin,

For your information, that bug was fixed in 4.20 release (see in release notes:  409983 [USB Host All classes] : FATFS USB Disk must be available when selecting USB Host All Classes).

It should be ok now if you use CubeMx v4.20 (let us know otherwise if you still face troubles).

The solution suggested by Yonathan is, any way, the workaround to put in place, in case such kind of issue (a mode wrongly disabled on FatFS side) blocks you in your project.

Regards

Fred