cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a "simple" example of how to write/read a USB drive using STM32CubeIDE?

RCooke88
Senior

Hi Folks,

I'd like to find an example of accessing a USB drive using the STM32CubeIDE. I'm currently using the Nucleo-H7A3Zi-Q board.

I believe I have setup the hardware correctly using the device configuration tool but I can't seem to find a simple or concise example on how to develop the code.

I have downloaded the STM32Cube_FW_H7_V1.11.0 code and examples but it still seems more complicated than it should. I've looked at STM32Cube_FW_H7_V1.11.0\Projects\NUCLEO-H7A3ZI-Q\Applications\USB_Host\MSC_Standalone\ but I don't understand how (or what) to import into my workspace.

For a start I just want to be able to write a "Hello World" into a file on the USB key.

Anybody have a good tutorial or example I can use?

Thanks,

Richard

44 REPLIES 44
TDK
Guru

There is not a simple example because USB is not simple. It will take some time to learn.

Did you get the example running? Perhaps clone that and import your code into that project rather than the reverse.

A good resource for USB is here:

https://www.usbmadesimple.co.uk/

If you feel a post has answered your question, please click "Accept as Solution".
Oskar_H
Senior

Maybe you should have a look at example FatFs_USBDisk, it is much simpler and does what you want : write a text file.

Hi Oskar,

The example code for my Nucleo-H7A3ZI-Q doesn't have a FatFs_USBDisk example. The STM32H743-EVAL directory has a subdirectory called FatFs_USBDisk_Standalone. Is this something that could work for my board?

Thanks,

Richard

Pavel A.
Evangelist III

 I don't understand how (or what) to import into my workspace.

@RCooke88 Divide this task to two sub-tasks: a. Build and run the example as is, understand how it works, then b. Find out what to import to your project.  It could be easier this way.

If you decide to go with the FatFS library, consider update it to the latest version.

 

 

Hi Richard,

How about : diy ?  I try to help you and then you not only copy something, but you get it running yourself.

Wanna try ?

If you feel a post has answered your question, please click "Accept as Solution".

AScha,

I'll give it a try. What should I do?

Richard

ok,

in IDE -> file-> new STM32 project -> (board selector) give your board H7A3..nucleo -> select it : -> next -> give a name (only ascii, no space, like:) H7A3-test. finish.  (init alll... -> yes )

If you feel a post has answered your question, please click "Accept as Solution".

in ioc editor ...after a minute or so...  debug : trace swo

AScha3_0-1705523470452.png

usb to host only

AScha3_1-1705523601944.png

usb host to msc

AScha3_2-1705523688126.png

+ here platform setting...

AScha3_3-1705523770241.png

then fatfs to usb disk

AScha3_4-1705523837814.png

if you want : long file names (i do..)

AScha3_5-1705524041710.png

and exfat (for big > 32GB sticks)

AScha3_6-1705524091943.png

ok...save file, generate code . (the gear symbol..)

 

If you feel a post has answered your question, please click "Accept as Solution".

OK. I followed your instructions and have a saved project with code now.