cancel
Showing results for 
Search instead for 
Did you mean: 

USB mass storage in RAM

brakchus
Associate II
Posted on September 01, 2013 at 14:05

Dear All,

I'm working on use RAM memory from STM32F205 on mz custom PCB to run code from STM32_USB-Host-Device_Lib_V2.1.0 under Iar workbench. From mass storage device example workspace I removed all board specific calls lik LCD logger and SD card and changed them to write/read from my uin8_t usbDisk[0x1000] buffer placed in RAM. I can see that device is connected in device manager Win7 without any yellow marks, but when the OS wants to format removable device I got ''Windows was unable to complete the format''. I can see that some SCSI commands are invoked like: SCSI_INQUIRY, SCSI_READ_FORMAT_CAPACITIES, SCSI_READ10, SCSI_MODE_SENSE6 and after device is detected in OS SCSI_TEST_UNIT_READY command is regular called.

You can see my changes in usbd_storage_msd.c file attached.

Best regards,

John

#stm32f2-usb-mass-storage
16 REPLIES 16
Posted on September 01, 2013 at 15:22

4K seems too small to do anything remotely useful, reconsider.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
brakchus
Associate II
Posted on September 01, 2013 at 17:50

Hi clive1,

the 4k was only for test purposes. I've increased the size of my ram usbDisk buffer and it seems that I can now format the disk and put small file on it. Thank you for pointing me the right direction!

Best regrads,

John

Posted on September 01, 2013 at 18:53

With small volumes you may want to look at constructing the file system structures yourself, so as to maximize utilization, and not have windows waste space.

ie no reserved space, one fat, one sector for the root directory (16 files), 512 byte clusters, floppy format (no MBR).
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
brakchus
Associate II
Posted on September 01, 2013 at 19:34

Yes, that's exactly what I'm trying to achieve here. After I know that ram version works next step is to move to flash memory and include all the necessary fat and files data (around 1kB)during compilation. I expect to use less memory than OS - e.g. after format for 64kB mass storage I can only use 44kB... what a waste!;)

Best regards,

John

roman239955
Associate III
Posted on June 06, 2018 at 20:13

I'm aware this is an old thread but is there a trick that we need to know in order to get this example to work in Windows 10?  I can get it to work in Windows 7.

Posted on June 06, 2018 at 20:39

I don't know, what requirements does Win10 have? Don't the mbed MSC implementations work on the ST-LINK (DISCO/NUCLEO)?

It might have specific command/response requirements, or minimum size.

I posted an MSC SDRAM-DISK for the STM32F429I-DISCO a while back, I'd expect that to keep working.

I'd be open to reasonable offers to figure it out.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 06, 2018 at 21:20

I’m using an OEM board and the RAM drive seemed like a rather straight forward way of doing a proof of concept with USB MSC.

The RAM drive works with my stm32l476 board on Windows 7 but it does not work on Windows 10.  IAR compiler.  MXCube 4.25.1, L4xx driver 1.11.

I haven’t gone any further than just trying it out and was wondering if anyone has gotten the MSC RAM drive to work on Win10.  

Posted on June 08, 2018 at 01:02

If you see that recent Win10 updates break things, please complain in Microsoft forums (Technet win10 IT Pro, or Windows drivers). They won't fix if we don't let them know.

-- pa

roman239955
Associate III
Posted on June 08, 2018 at 15:51

I'd like to follow up with an update on my Win 10 issue.  As much as I like to complain about Microsoft it turns out that my issue was Not a Win10 issue but rather an issue with the read and write in the storage msd.c file provided in the first post. 

While a 64kB RAMdrive 'seemed' to work on Win 7 and not on Win 10, I later found that it was Not working on both platforms with only the appearance of partially working on Win7 because of dumb luck.  

Anyway, the memcpy used in the storage read/writes need a little modification. 

in the read function I use memcpy(buf, &usbMassStorage[blk_addr

* STORAGE_BLK_SIZ

],blk_len

* STORAGE_BLK_SIZ

);

The write is similarly modified.

I've only tested this with a small (2,975 bytes) file but  I'm able to drag and drop/delete a file in a PC RAMdrive.

There are still a lot of limitations to this example, like formatting every time the device is plugged in, and Win formatting  eating a lot of space, but with reference to the above example storage.c file and the small changes shown here, the start of a RAMdrive proof of concept can be realized quite quickly.

I hope someone finds this helpful.  Thank you John for starting this discussion and thank you ST for leaving it up for so long.