cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F767. USB-Dev-MSC. How to write/read to/from MCU from the PC?

NikDobro
Associate II

Hi, colleges!

I use Nucleo-144 STm32F767 development board to learn USB.

Now - Application example - device USB MSC.

How can I write/read to/from MCU from the PC?

Do I need some software on PC? Or can I do it by file manager (f.e. Total Commander)?

Please, reveal me the process? Or where can I read about it?

8 REPLIES 8

Device emulates a sub set of SCSI commands. Should be able to find SCSI/ATAPI docs online.

OS typically has an MSC or USBSTOR driver to talk to device, reads ID, CAPACITY and provides block READ /WRITE function. Would need to format media usually with a partition table, and then a file system. ​

OS might provide means to get handle to device to use IOCTL interface to query size, read/write blocks, or send commands. See tools like WinImage.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

If I want to use FARfs on my device, is thees steps right?

  1. Include ff, f_gen_drv, diskio files
  2. Create my own usbd_diskio.c
  3. In this file i fill functions _initialize, _status, _read, _write, _ioctl with functions, which work with SD card (initialize, read, write, ...). Is it right?
  4. in file usbd_storage_if.c i need to fill all functions (Init, GetCapacity, Read, Write). But what i need to write here?

Look through HAL code/examples trees and port the microsd to MSC ones to your platform.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

HAL examples doesn't use FATfs with usb msc device mode. It is used only in host mode.

>>HAL examples doesn't use FATfs with usb msc device mode. It is used only in host mode.

And why would it need to use FATFs in this context, the PC wants to see a block storage device?

I'm confused about what you want to do.

If you want to read the MicroSD card on a PC, via USB, be a USB MSC Device.

If you want to read files from the MicroSD on the STM32 side, use FATFs.

Access SD Card from PC

STM32Cube_FW_F7_V1.12.0\Projects\STM32756G_EVAL\Applications\USB_Device\MSC_Standalone\readme.txt

Files from an SD Card on STM32

STM32Cube_FW_F7_V1.12.0\Projects\STM32F769I_EVAL\Applications\FatFs\FatFs_uSD

Files from a USB Flash Stick on STM32

STM32Cube_FW_F7_V1.12.0\Projects\STM32F769I_EVAL\Applications\FatFs\FatFs_USBDisk

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks a lot, Clive Two.Zero!

I want to see file system on PC when I'm working with SD card via USB.

Next, I will use external SD RAM on my own board instead of SD card.

"I want to see file system on PC when I'm working with SD card via USB."

Are thees steps right?

  1. Include ff, f_gen_drv, diskio files
  2. Create my own usbd_diskio.c
  3. In this file i fill functions _initialize, _status, _read, _write, _ioctl with functions, which work with SD card (initialize, read, write, ...). Is it right?
  4. in file usbd_storage_if.c i need to fill all functions (Init, GetCapacity, Read, Write). But what i need to write here?

No​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..