cancel
Showing results for 
Search instead for 
Did you mean: 

Writing on USB-Memory

Stephan Scherer
Associate II
Posted on April 12, 2013 at 07:58

Hello,

i have a little problem. I have adaptet the stm_Host_MSC example on my board.

I use the USB_HS_Core with the internal FS-phy.

I can communicate and wirte on my usb-stick.

my question mow is: What i have to do, that i can wite additional data in an existing file??

Thanks for your help.

5 REPLIES 5
Posted on April 12, 2013 at 08:02

You'll likely need to layer on a file system, like FatFs, and access/modify the files that way.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Stephan Scherer
Associate II
Posted on April 12, 2013 at 09:05

I have added the files for the file-system to my project, but i'm confused where I have to modify.

Can you give me an example or something like that?
Posted on April 12, 2013 at 15:41

Can I send you a bill for my time?

The sector reading and writing routines for FatFs are abstracted in diskio.c

FRESULT res;
FIL fil;
FATFS fs32;
..
memset(&fs32, 0, sizeof(FATFS));
res = f_mount(0, &fs32);
if (res != FR_OK)
printf(''res = %d f_mount
'', res);
..
// Incremental write test
if (f_open(&fil, ''LOG.TXT'', FA_OPEN_ALWAYS | FA_WRITE) == FR_OK)
{
UINT BytesWritten;
const char string[] = ''Another line gets added

'';
f_lseek(&fil, fil.fsize); // Seek to tail

f_write(&fil, string, strlen(string), &BytesWritten); // Add new data

f_close(&fil);
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Stephan Scherer
Associate II
Posted on April 15, 2013 at 07:13

THX clive.

Fanally it works. 🙂
prynk27
Associate
Posted on August 28, 2013 at 21:28

Hello Stephan,

I am new in USB interfacing can you help me how i can interface USB for transferring File in .txt format from STM32F303 to USB stick by giving an example.

Thanks in advance