2016-10-04 01:01 PM
I have been struggling to set up CubeMX to be able to read and write to a USB memory stick for STM32F4-Discovery board, similarly to what is done in the example from the repository (Repository\STM32Cube_FW_F4_V1.13.0\Projects\STM32F4-Discovery\Applications\FatFs\FatFs_USBDisk). This example from ST is working perfectly.
My setup procedure is as follows:After generating the code I &sharpinclude the fatfs.h in usb_host.c in order to be able to use the functions defined, similarly to what is done in main.c for the original example. Next the private variables (FATFS USBDISKFatFs etc) and the ''MSC_Application'' function is added to the code. I call this function in USBH_UserProcess for the case HOST_USER_CONNECTION. Last I add the red LED to be activated in USB_Error_Handler.
What am I doing wrong? Am I missing any additional settings or code? Please help, as I would like to base most of my upcoming work on the use of CubeMX. #!cubemx #!usb-msc #!stm32f4discoverySolved! Go to Solution.
2016-10-13 12:23 AM
I finally figured out how to set up the USB for STM32F4 Discovery in CubeMX for reading and writing to a memory stick. I made a
http://evenlund.blogspot.no/2016/10/usb-storage-with-stm32f4-discovery-and_58.html
if anyone else would be interested to know.My only challenge now is to be able to call the reading and writing operations originally called from usb_host.c on demand from main.c. CubeMX is calling MX_USB_Host_Process() in the main while loop, and I guess if I fill up a global variable wtext and only call MX_USB_Host_Process() when this is ready I will be able to achieve this. Are there any more elegant ways to do this?
2016-10-10 09:04 AM
Hi Even,
Could you please share more details regarding the issue you are facing after generating the Cube_MX project and updating it? When debugging, where are you struggling compared to the Cube example?-Mayla-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.
2016-10-11 03:32 AM
I'm not sure, how the Code for the F4 is generated. But for the L4 the Implementation in the sd_diskio.c is a ''fill-in-the-blank text''. You have to copy /adjust this File from the Examples ...
2016-10-13 12:23 AM
I finally figured out how to set up the USB for STM32F4 Discovery in CubeMX for reading and writing to a memory stick. I made a
http://evenlund.blogspot.no/2016/10/usb-storage-with-stm32f4-discovery-and_58.html
if anyone else would be interested to know.My only challenge now is to be able to call the reading and writing operations originally called from usb_host.c on demand from main.c. CubeMX is calling MX_USB_Host_Process() in the main while loop, and I guess if I fill up a global variable wtext and only call MX_USB_Host_Process() when this is ready I will be able to achieve this. Are there any more elegant ways to do this?
2016-10-17 12:11 AM
I took a short look over your Blogpost and what I have seen is not the Code for a USB MassStorageDevice. You have only implemented the FatFS-Demo-Code. Somehow you do not have the needed FATFS_LinkDriver() called (or it's somewhere else?), but you do the unlink at the End. I think this works only by Chance.
Anyway, for the USB MSD you have to look into your sd_diskio.c as I wrote above ...