2023-03-07 10:56 PM
hello,
I able to see the stm32 RAM as storage in pc. I want to transfer the files and buffer data to pc from stm32 RAM as storage.
int8_t STORAGE_Read_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)
{
/* USER CODE BEGIN 6 */
memcpy(buf,&buffer1[blk_addr*STORAGE_BLK_SIZ],blk_len*STORAGE_BLK_SIZ);
return (USBD_OK);
/* USER CODE END 6 */
}
int8_t STORAGE_Write_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)
{
/* USER CODE BEGIN 7 */
memcpy(&buffer1[blk_addr*STORAGE_BLK_SIZ],buf,blk_len*STORAGE_BLK_SIZ);
return (USBD_OK);
/* USER CODE END 7 */
}
2023-05-26 3:47 AM
So you want to create a RAM-Disk?
Your STM32 should appear as a drive on windows via USB?
If you just add RAM to your USB storage, it appears as "unformated" in windows.
you need to format your ramdisk with a file system like fatfs or azure RTOS FileX and then you can write files to your ram disk
2023-05-26 4:24 AM
There's been examples of an SDRAM-DISK MSC on several of the DISCO boards over the years.
As @Johannes points out you'll need to format with f_mkfs(),perhaps preload with other files for Windows / Linux to find it immediately usable. Can't really auto-run things at this point due to the threat vector that represents, but the OS can read and copy files at user direction.
2023-05-26 6:59 AM
You may also want to use MTP protocol instead of plain mass storage. MTP capable devices are aware of the "files" exchanged between the device and host.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.