cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to get RAM Disk as USB MSD for mbed & Nucleo-F401-RE

JShah.10
Associate II

Hi,

I am new to mbed and STM32-F401RE.

I am trying to get the RAM Disk as USB Mass storage device and communicate between PC and STM board. I am trying https://os.mbed.com/users/va009039/code/F401RE_USBMSD_RAM/

I am able to run the binary but board is not detected as USB Drive on the Windows.

  1. define PACKET_SIZE 32
  2. define blocks_data (1024 * 512)

FATFileSystem fs("fs");

SERIAL setup Serial pc(USBTX, USBRX, 230400);

THREADs Thread ramfs_thread;

void ram_disk_setup() { int connect1 = 0;

/* Size of RAM file system exposed to PC as USB MassStorage */ HeapBlockDevice heap_bd(blocks_data, 512);

MBRBlockDevice::partition(&heap_bd, 1, 0x0b, 0, 512 * 512);

MBRBlockDevice part1(&heap_bd, 1);

RAMFS ramfs1("ram1", &part1);

format with FS FATFileSystem::format(&part1); create FS object and mount FS FATFileSystem fat1("fat", &part1);

USBRAMFS usbmsd1(&ramfs1);

now we wait for the user to connect the board to the PC while(true) { if (usbmsd1.connect() && 1 != connect1) { connect1 = 1; printf("Connected to PC - 1\r\n"); }

only try once per second Thread::wait(9000); } }

int main(void) { osStatus err; wait(5);

printf("\r\nUSB Serial done\r\n");

err = ramfs_thread.start(callback(ram_disk_setup)); if (err) { printf("ERROR > send_hid_thread not created\r\n"); } ramfs_thread.join(); }

Thank you in advance.

Regards,

Jignesh

9 REPLIES 9

You'd have to add a USB port to the F401RE to be able to talk to it via USB.

The USB on the NUCLEO-64 boards talks to the F103 implementing the ST-LINK/mbed functionality.

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

Thank you for the response. Yes, I have made a custom connector to connect with PC.

I really am not sure what you meant by "The USB on the NUCLEO-64 boards talks to the F103 implementing the ST-LINK/mbed functionality."

JShah.10
Associate II

When I debugged the USB stack further, I figured that in SCSI communication Host request for READ 10 command but STM32 board sends negative acknowledgment to Host.

Due to this Host sends reset packet to STM32 board.

The board has a USB connector, it communicates with the STM32F103 chip, and NOT the STM32F401RE, that's what I said/meant.

0690X000006DHetQAG.jpg

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

This probably not the best place to discuss mbed coding.

I will observe that the F401 doesn't have 512KB of RAM, so a RAM drive of that size, or 256KB, probably isn't going to be viable.

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

Here is a setup image which I am using. I am using a custom connector on CN10 to have USB connector.

https://os.mbed.com/users/va009039/notebook/F401RE_USBDevice/#commentform

Here there is a code which says to create a RAMdisk and configure as MSD which can be detected on USB and work as USB MSD.

JFYI - I tried with lesser size of RAM drive as well... tried for 64KB also..

I've created working SDRAMDisks using the STM32F429I-DISCO, I think ST has some examples also, but these are stand-alone C projects, not built against mbed libraries.

STM32Cube_FW_F4_V1.21.0\Projects\STM32F429I-Discovery\Applications\FatFs\FatFs_RAMDisk

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

you just have to configure RAM DISK well & make some changes in usb_storage file it will show drive automatically

you don't have to change anything in main file .

Best of luck