5 years, 9 months ago.

Nucleo-F401RE as USB Mass Storage Device

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(); }

Be the first to answer this question.