cancel
Showing results for 
Search instead for 
Did you mean: 

USB Device MSC with External Flash

Shikamaru
Associate III

Hi team,

            I am working on stm32F7 discovery board, I am working on USB MSC Device however i am not getting , how to configure external flash of this discovery board as Mass Storage. My main goal here is as soon as i connect the controller to PC, the external flash has to detect as mass storage device (predefined size).

 

 

regards,

Shikamaru

 

 

14 REPLIES 14
AChil.1
Associate II

Hi @Shikamaru and @RSheetz 

Did you ever find a solution to this?  I have got to the same point as you both and am confused why it's not working. 

 

Kind Regards

Andrew

OK, you want to see your STM32 board behaving like a USB memory device?

First of all: do you have memory (RAM) on STM32 board which you want to see on PC host?

It works this way:

You configure and build you STM32 board FW so that it will setup an USB device USB memory (USB class MSC).
You have to add this USB stack as MSC device to your STM32 FW project.

This USB MSC works like a SCSI device: it reads the memory via low level primitives like reading and writing sectors on a memory device. The filesystem "interpretation" is done by the host (PC).

You have to implement the read and write functions for sectors on STM32 board, e.g. using internal SRAM as the storage device.
When the USB stack as MSC device on STM32 is running - the PC will see it as an external USB memory device.
It can format, write and read your STM32 like a USB stick.

If you use on STM32 board an external flash (e.g. eMMC), you have to provide the read, write sector functions which goes to you eMMC memory. Bear in mind: if it is a flash (e.g. eMMC), for a write, you have to erase a sector first, whereby the write data is 'cached' (stored somewhere), after erasing this sector you can write the sector.

So, it means:

  • besides adding USB FW stack as MSC to your STM322 project
  • you have to provide also the correct Read, Write functions for handling sectors
  • on flash devices - it is a bit more 'complicated' because you have to erase sectors first before you can write a new sector
  • better, to consider to use a STM32 board which supports also your FW as Azure OS: it comes also with support for flash devices, filesystems on flash memory

BTW: just to connect STM32 board via USB and the 'wish' to see it as memory device does NOT work without an appropriate FW for the board built and running (USB MSC device, mapping the SCSI commands to a physical memory).

It is possible (I did it several times on different STM32 boards). It just needs to get familiar how to add USB MSC Device to your FW project.

BTW: if you are asking how to flash an external flash memory connected on a STM32 board (not to see it as USB memory device, but to flash the content of this memory)...

check out how to install/enable 'external loaders' in STM32 debugger tool (e.g. STM32 Programmer or STM32 ST-Link Utility): it is possible to add and enable an external loader for a flash memory device connected on a STM32 board: just make sure you use a flash device which is supported by the STM32 Programming/Debug tool (you have to specify which loader for which device).

This can see your flash memory device, read and write the content of it. But it does not behave like a USB stick ('just' possible to write content also for this flash memory, not just the STM32 MCU internal flash itself).

==> so, what do you want to implement/accomplish? (USB memory device seen on host PC or flashing memory connected on STM32 board?)

Sadly no,

i have change from USB Device MSC to USB Device CDC.

Thank you for your Detailed answer.

At frist i have a question:
What does USB FW stack mean?

Actually im working with a USB module from STM32 IDE and configured it with the .ioc

Regardless of my situation, I am curious whether it is possible to implement a µ controller with external flash as USB storage. 
In recent weeks, I have not found a working example with USB MSC and an external flash drive.

Thanks for your answer and I look forward to your reply

 

RSheetz