Questions tagged [fatfs]

FatFs is a generic FAT file system module for small embedded systems.

The FatFs module is written in compliance with ANSI C (C89) and completely separated from the disk I/O layer. Therefore it is independent of the platform. It can be incorporated into small microcontrollers with limited resource, such as 8051, PIC, AVR, ARM, Z80, 78K and etc.

Features

  • Windows compatible FAT file system.
  • Platform independent. Easy to port.
  • Very small footprint for code and work area.
  • Various configuration options:

    • Multiple volumes (physical drives and partitions).
    • Multiple ANSI/OEM code pages including DBCS.
    • Long file name support in ANSI/OEM or Unicode.
    • RTOS support for multi-task operation.
    • Multiple sector size support upto 4KB.
    • Read-only, minimized API, I/O buffer and etc...

Application Interface layer

  1. File Access

    • f_open - Open/Create a file
    • f_close - Close an open file
    • f_read - Read data
    • f_write - Write data
    • f_lseek - Move read/write pointer, Expand size
    • f_truncate - Truncate size
    • f_sync - Flush cached data
    • f_forward - Forward data to the stream
    • f_gets - Read a string
    • f_putc - Write a character
    • f_puts - Write a string
    • f_printf - Write a formatted string
    • f_tell - Get current read/write pointer
    • f_eof - Test for end-of-file
    • f_size - Get size
    • f_error - Test for an error
  2. Directory Access

    • f_opendir - Open a directory
    • f_closedir - Close an open directory
    • f_readdir - Read an item
    • f_findfirst - Open a directory and read first item found
    • f_findnext - Read a next item found
  3. File/Directory Management

    • f_stat - Check existance of a file or sub-directory
    • f_unlink - Remove a file or sub-directory
    • f_rename - Rename or move a file or sub-directory
    • f_chmod - Change attribute of a file or sub-directory
    • f_utime - Change timestamp of a file or sub-directory
    • f_mkdir - Create a sub-directory
    • f_chdir - Change current directory
    • f_chdrive - Change current drive
    • f_getcwd - Retrieve the current directory and drive
  4. Volume Management

    • f_mount - Register/Unregister a work area of a volume
    • f_mkfs - Create an FAT volume on the logical drive
    • f_fdisk - Create logical drives on the physical drive
    • f_getfree - Get total size and free size on the volume
    • f_getlabel - Get volume label
    • f_setlabel - Set volume label
  5. Device Control Interface layer

    Since the FatFs module is a file system layer, it is completely separated from the physical devices, such as memory card, harddisk and any type of storage devices. FatFs accesses the storage devices via a simple interface shown below. The low level device control module is not a part of FatFs module. It is provided by implementer. Also sample implementations for some platforms are available in the downloads.

    • disk_status - Get device status
    • disk_initialize - Initialize device
    • disk_read - Read sector(s)
    • disk_write - Write sector(s)
    • disk_ioctl - Control device dependent features
    • get_fattime - Get current time.
118 questions
0
votes
1 answer

micro SD card with stm32

I'm trying to work with the micro sd card module and stm32 with spi. I have formatted my micro sd card but the received output (using f_getfree function and Uart), claims that my free space is 0. which cannot be true as I have tried 2 different m-sd…
0
votes
0 answers

Unwanted shutdown when reading a file in C

I'm using an ESP32 connected to an external memory flash where I mounted a FATFS partition. I don't understand what could happen if I turn off the ESP32 (and the flash) after a fopen() instruction. The main purpose is to avoid any corruption of the…
Filippo
  • 126
  • 1
  • 12
0
votes
1 answer

FatFs async read without blocking

I am using stm32f103 and i need to read data from sd card. I am using a coroutine system ,so i don't want to block. Is there a possible way to read asyncly?
0
votes
0 answers

How to create a File correctly

i started working with fatfs a few days ago for reading and writing to a microsd card from my atmega328p. Unfortunately no txt file is created with my code, but i don't get any error out. Does anyone know what the problem could be? #include…
kaan5353
  • 67
  • 5
0
votes
2 answers

How can I write raw data on SD card without filesystem by using DSP?

I'm new in embedded electronic/programming but I have a project. For this project, I want to write raw data provided by sensor in 512b buffers on a SD card (SPI mode) with no filesystem. I'm trying to do it by using the low level functions of the…
Thomas
  • 11
  • 2
0
votes
1 answer

SPI SD Card 32GB Never passes CMD55, ACMD41 Initalization Step

I am using Elm-chan FatFs module. I ported it correctly as it works when using a 16GB SD card. But when using a 32GB card, the code is getting stuck at the CMD55, ACMD41 set up loop. Bellow is the print out of the command and response I am…
Emil
  • 1
  • 1
0
votes
1 answer

Deinitialising FatFS and mounting another SD card

I've been trying to mount an SD card, write some data to some files, then dismount the SD card. Mount a separate one and write to more files (This is done via a multiplexer and two separate but identical SD card modules). I am using an STM32F3 and…
Liamm36
  • 13
  • 4
0
votes
1 answer

STM32 SD FATFS mount error (FR_NOT_READY)

I'm actually trying to write on a µSD card with a STM32L486QGI6. The function f_mount() returns FR_NOT_READY whether the µSD is placed or not... I already checked dozens of tutorials and examples for CubeMX generation (Checked the pins, the…
Anis AIT
  • 31
  • 1
  • 1
  • 7
0
votes
1 answer

Is it possible to implement DISKCOPY to copy block by block from eMMC volume to USB volume

I am using STM32, FATFS, SDMMC, eMMC and have created the FATFS on the eMMC. I have also created a FATFS volume on the USBH (host mode). This also works fine. The eMMC FATFS work fine then I need to copy all files from the eMMC to the USB drive.…
0
votes
1 answer

C - Why does assigning an element to a first element of adynamically allocated array always return nothing

I am developing an application where I need to read some files off an SD Card. Everything runs on an STM32 microcontroller with FatFS. I just open the root, and iterate over each element in that directory and check whether it's a file or a folder, I…
Marek Ant
  • 67
  • 7
0
votes
1 answer

Having Difficulty configuring FatFs for flash memory

I am but a lowly intern, cast into the unforgiving fires of firmware development. I have been tasked with implementing a file system onto an STM32 chip, using a w25qxx through SPI. I have been able to successfully read and write to the w25q through…
Jonathan Just
  • 49
  • 1
  • 8
0
votes
0 answers

FatFs date and time to DateTime

I'm trying to convert UInt16 values representing FatFs date and time (here) into C# DateTime object. I have two UInt16 values representing fdate and ftime as seen in the link. Whats the easiest way to convert those into a DateTime in C#?
Werner
  • 1,229
  • 1
  • 10
  • 24
0
votes
1 answer

Is there a way to delete data from a specific point of a file?

I'm using Chan's FatFS (http://elm-chan.org/fsw/ff/00index_e.html) in C and I'm trying to delete all the following lines from a specific point of a file. I've set the filepointer to my new "End of file", the rest of the file should be…
0
votes
1 answer

STM32F407 - SDIO | FATFS - save file to sd card

Problem : Even the card is present or not, The SD card is mounted . I can’t write a file to the sd card. Context : I read a lot of books, documentations and tutorials, I can’t find a way to make it work. From the STM IDE debugger, I can’t get rich…
CharlieWhite
  • 133
  • 1
  • 12
0
votes
0 answers

c Fatfs CSV writing bug

I have an issue with a CSV writing function, some times it prints a blank line to the file. How do I check for this or remove it as I dont want to write a blank line to the CSV. My CSV output is: As you can see the first 2 lines are correct the…
Thomas Morris
  • 794
  • 5
  • 26