Skip to main content
mahmoud_dhaiwi
Associate II
November 12, 2012
Question

STM3210C EVAL

  • November 12, 2012
  • 10 replies
  • 1753 views
Posted on November 12, 2012 at 15:16

Hello, I use STM3210C-EVAL board.

I have to copy the files from the SD card to a USB wih the format FAT.

Is there someone who can help me?

Thanks in advance.

#stm3210c-eval #fatfs #sdcard-fatfs #f_mount-sdcard #syncobj.c-windows.h
This topic has been closed for replies.

10 replies

Tesla DeLorean
Guru
November 12, 2012
Posted on November 12, 2012 at 16:10

Is there someone who can help me?

I believe that ST maintains a list of consultants/contractors you can hire.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
mahmoud_dhaiwi
Associate II
November 12, 2012
Posted on November 12, 2012 at 17:57

If you have already made a code that makes this function, thank you for advise me.

Tesla DeLorean
Guru
November 12, 2012
Posted on November 12, 2012 at 18:15

You should perhaps dig through the source of the examples, and libraries for the STM32 chips and boards. Amongst the available code are examples of the various aspects you are looking for, ie USB MSC Host, SDIO, FatFs, etc.

I have some of these functions on other boards, but don't have this specific board, or a plan to port it.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
mahmoud_dhaiwi
Associate II
November 13, 2012
Posted on November 13, 2012 at 09:10

Hello,

In fact, I have already started to work on this project. I have compiled the STM32_USB_Device_Library with USB mass storage device example.

The Mass storage example uses the microSD Flash embedded in the STM3210C-EVAL evaluation board as media for data storage.

up to now, I managed to read SD card , and write on the SD card (FATFS).

But my aim is to copy the data from the SD card to a USB key (I do not still have this function code), so I have to compile USB HOST Library. that's why I find it complicated a bit... how I can use both libraries at the same time! In addition I do not see how I use the FatFS commands, for example: f_mount(0,&fatfs) it will be for the USB or the SD card!

best regards

Tesla DeLorean
Guru
November 13, 2012
Posted on November 13, 2012 at 16:40

The first parameter for f_mount() is a drive number, you'd need to implement support for two drives, and map your IO functions to the appropriate device.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
mahmoud_dhaiwi
Associate II
November 21, 2012
Posted on November 21, 2012 at 14:47

Hi Clive1,

Can you please explain to me, what is the role of the ''syncobj.c'' file ?

thnx :)
Tesla DeLorean
Guru
November 21, 2012
Posted on November 21, 2012 at 18:39

Can you please explain to me, what is the role of the ''syncobj.c'' file ?

In an RTOS environment it allows you to implement thread synchronization, or otherwise serialize access to the device/file-system.

It would be required if you are likely to cause re-entrant behaviour into FatFs, ie run one access in the foreground, and other(s) in the background.

Unchecked re-entrant behaviour is likely to cause file-system corruption, and as such is quite undesirable.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
mahmoud_dhaiwi
Associate II
November 22, 2012
Posted on November 22, 2012 at 17:47

I have a problem with the function f_mount(BYTE vol, FATFS *fs) .

In fact, when I compile the Host library for writing and reading on a USB stick, I use this function f_mount(0 , &fatfs).

Similarly, when I compile the Device Library for writing and reading on the SD card, I also use this function f_mount(0 , &fatfs)!!!! How does the program know which drive I will write if I use the same fuction with the same parameters ?!!

for example if I put f_mount(1 , &fatfs)... What is going to happen?
Andrew Neil
Super User
November 22, 2012
Posted on November 22, 2012 at 18:03

As clive1 has already said, ''The first parameter for f_mount() is a drive number, you'd need to implement support for two drives, and map your IO functions to the appropriate device''

The documentation for f_mount() is here:

http://elm-chan.org/fsw/ff/en/mount.html

Home page for FatFs - includes documentation, links to examples, forum, etc:

http://elm-chan.org/fsw/ff/00index_e.html

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Tesla DeLorean
Guru
November 22, 2012
Posted on November 22, 2012 at 19:45

How does the program know which drive I will write if I use the same fuction with the same parameters ?!! for example if I put f_mount(1 , &fatfs)... What is going to happen?

Well you really need to have a unique context for each connection you want to make to FatFs. If you mingle the contexts all kinds of bad things will happen. ie the same way you can't use the same file handle to access two different files simultaneously.

You will need to merge/combine the access functions in diskio.c to direct access the specific drive/volume the incoming request specifies. So one volume directs to the SD routines, the other to USB routines.
Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..