Skip to main content
MKS
Associate III
June 3, 2020
Question

FatFs for reading text file or binary file

  • June 3, 2020
  • 3 replies
  • 3080 views

Hi,

I have stm32f103rb nucleo board

i want to read/write a text file from flash space of the board.

Is there any example for implementing this c ode.

i am using stm32cube ide.

Regards,

Manjunath K S

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
June 3, 2020

There should be examples for fatfs and internal flash erase/write.

Is there working code you can directly copy, probably not so much.

Going to be relatively small and slow. Pick the block/sector size to match those of the F1 part.​

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
MKS
MKSAuthor
Associate III
June 3, 2020

Hi @Community member​ 

i got exampoles for reading from sd card, i just want to read a text file for my application.

Regards,

manjunath

Tesla DeLorean
Guru
June 3, 2020

It is all just a collection of bytes at the end of the day. FatFs works very much like standard C file IO functions. Read a block or buffer full of data, and parse the ASCII data, break it into strings or whatever.

If you just need to output the content of a file and output to a UART, you could open, get length information, and then read a buffer full at a time, sending to the serial device until all the content is consumed and then closed.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
MKS
MKSAuthor
Associate III
June 3, 2020

Hi,

I am just new to this , as in c cant we use FILE pointer for reading the file, if so what will be location of the file in flash.

i am not able to find any sample code or so to figure out the exact steps.

Regards,

manjunath