Skip to main content
NikDobro
Associate II
October 25, 2018
Question

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

  • October 25, 2018
  • 2 replies
  • 1842 views

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?

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
October 25, 2018

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 VenmoUp vote any posts that you find helpful, it shows what's working..
NikDobro
NikDobroAuthor
Associate II
October 25, 2018

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?
Tesla DeLorean
Guru
October 25, 2018

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

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
NikDobro
NikDobroAuthor
Associate II
October 25, 2018

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

Tesla DeLorean
Guru
October 25, 2018

>>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 VenmoUp vote any posts that you find helpful, it shows what's working..