2019-01-29 11:01 AM
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.
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
2019-01-29 11:04 AM
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.
2019-01-29 11:06 AM
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."
2019-01-29 11:08 AM
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.
2019-01-29 11:37 AM
The board has a USB connector, it communicates with the STM32F103 chip, and NOT the STM32F401RE, that's what I said/meant.
2019-01-29 11:38 AM
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.
2019-01-29 11:40 AM
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.
2019-01-29 11:41 AM
JFYI - I tried with lesser size of RAM drive as well... tried for 64KB also..
2019-01-29 02:03 PM
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
2019-12-14 01:59 AM
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