cancel
Showing results for 
Search instead for 
Did you mean: 

f_print vs F_write in FatFs

GreenGuy
Lead
Posted on April 06, 2018 at 07:04

I am working with F746G-Discovery board running the project application FatFs_uSD built in the repository.  The application runs using the code as is which writes the data to the uSD with the f_write function.  There is also a f_printf function in ff.c.  When I try to call it from main the compiler throws an error indicating the function is not defined.  This is odd since it is in the same ff.c file.  The function is declared in both the ff.h and ff.c and the function is not static.  I checked to see if possibly the directory where the ff.c and ff.h are contained are not in the includes directory list.  Sure enough the folder is not in the list.  So I added it but the same result occurs.  So why is the compiler giving the error?  And why is the f_write not coming up as undefined when the directory containing the files are not in the include list.  I even tried #include 'ff.h' in the top of main and still the errors occurs with f_printf. 

Comments?

PS. ff.c and ff.h are in the Middlewares>FatFs>Core folder in the repository.

4 REPLIES 4
Tilen MAJERLE
ST Employee
Posted on April 06, 2018 at 07:10

f_printf is 'extended string' function, available in FATFS at specific configuration:

http://elm-chan.org/fsw/ff/doc/printf.html

, check QuickInfo information.

Keep in mind that f_printf calls write function for every character which may cause low-throughput. To keep good throughput, FATFS uses internal sector caches. Try to avoid using this function if possible.

Posted on April 09, 2018 at 16:09

Great to know, but the original questions remain unanswered.

Posted on April 09, 2018 at 16:18

Note that FatFs is an independent, 3rd-party product - nothing to do with ST.

So specific question should really be directed to the FatFs forum - see:

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

But the key to your question is probably here:

Majerle.Tilen

wrote:

... available in FATFS at specific configuration

.

(my emphasis)

So - do you have the correct configuration for f_printf to be available?

See the link to the FatFs documentation which

Majerle.Tilen

‌ provided.

Posted on April 09, 2018 at 16:19

Make sure ffconf.h defines the components you want to be pulled in.

...

♯ define _USE_STRFUNC    0

/* This option switches string functions, f_gets(), f_putc(), f_puts() and

/  f_printf().

/

/  0: Disable string functions.

/  1: Enable without LF-CRLF conversion.

/  2: Enable with LF-CRLF conversion. */

...

Going to be a huge sloth, really want to use sprintf() to fill a spill buffer so you can write multiple sectors in a single operation. ie offset += sprintf(&buffer[offset],'%d ', x); with a buffer holding 8192+16 bytes

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..