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
2
votes
3 answers

External file ressource on embedded system (C language with FAT)

My application/device is running on an ARM Cortex M3 (STM32), without OS but with a FatFs) and needs to access many resources files (audio, image, etc..) The code runs from internal flash (ROM, 256Kb). The resources files are stored on external…
Tweepy
  • 75
  • 9
2
votes
0 answers

STM32f746G-disco, SD card, f_open returns FR_NO_FILESYSTEM

I have an application which consists of 2 threads and runs on the STM32f746G-discovery board. One thread is implementing an http client (which just gets a file from a server) and the other thread writes a file in the sd card. When i run the threads…
1
vote
0 answers

Can i Write a file to a pendrive using stm32f401ccu6?

I wanna be able to write a file to a pendrive using a MCU, so i tried to use stm32f401ccu6 on a blackpill board that has acess to the USB OTG communication, but there is very few examples and even though i heve read the documentation i didn't get it…
1
vote
0 answers

FatFs printing random characters with snprintf

SD card output: I'm trying to write a string to an SD card using the FatFs library. I'm using the snprintf function to add a variable 'temp' to a string. When the string is written to the SD card there is also random characters there. I've tried…
1
vote
1 answer

Scan a USB for Folders which have mp3 file in them using ELM CHAN fatfs?

I am tying to scan usb msc in stm32 for audio files. This mp3 files are scattered in many folders which are unknown to the application. First I scan for directories in the root folder and find folders then I scan folders for mp3 files. This is very…
Nima Aghayan
  • 109
  • 1
  • 7
1
vote
0 answers

Sort a list of file paths without using memory or array in C?

I Use ELM Chan fatfs library for file system. This application reads a USB memory MSC. I want to read all the MP3 files in root directory in a sorted manner but I can not use an array to save all the file paths, Number of files exceeds ram memory of…
Nima Aghayan
  • 109
  • 1
  • 7
1
vote
1 answer

SD card in SDIO is not working in latest CubeIDE

Im trying to connect sd card in sdio to stm32f407vg discovery to store some data. Im using this tutorial https://www.youtube.com/watch?v=0NbBem8U80Y. Im doing everything step by step, but it is still not working. This is my code. #include…
Arseniy
  • 11
  • 1
1
vote
1 answer

Petit FatFs - pf_read() passes wrong arguments to disk_readp()

I'm using Petit FatFS with an Arduino Mega. I've implemented all necessary functions, however I'm having issues with the pf_read() function. I'm trying to read a file, which is 568 (512 + 56) bytes long. The first sector can be read without a…
ismxy
  • 21
  • 3
1
vote
1 answer

How to get file names using FatFs?

I did not the understand how to get file names in SD card using FATFS. I am able to read and write .txt files with this code below: if (f_mount(&fatfs, SDPath, 1) == FR_OK) { /* Write Test */ res = f_open(&file, (const TCHAR*)"TESTTEST.TXT",…
daaarwiin
  • 127
  • 1
  • 13
1
vote
0 answers

FR_NO_FILESYSTEM error fopen FATFS SPI STM32F103C8 with SanDisk SD Card 1GB

I work with STM32F103C8T6 and add FATFS and SPI in project. I test project with 8 GB SanDisk microSD but I have FR_NO_FILESYSTEM in f_open function. I change MicroSD and test with 1 GB SanDisk microSD and have this error again. I format SD card but…
ladan
  • 11
  • 1
1
vote
0 answers

STM32 FATFS, How to proper remount SD card using SPI?

I am using a SD card for data logging. I am using the free fatfs file system from chan and SPI to communicate with the SD card. However I ran into problems when reenserting the card. It no longer works. More specifically the f_mount() function fails…
1
vote
1 answer

FATFS R0.11 slow read speeds on STM32F103 - SPI

I am working with STM32F103C8 and I got FATFS R0.11 working fine on it (it’s the latest version that CUBEMX uses on STM32F103C8Tx by default), but the read speed is quite low, in the neighbourhood of 100 kB/s. The SPI clock is set to 18 MHz (changed…
KamilWitek
  • 99
  • 1
  • 9
1
vote
1 answer

FatFs on ESP32 with esp-idf can't create file with *.json extension

I want to switch from SPIFFS to FAT on my Esp32 projects due to encryption. In my example project I have this. esp_vfs_spiffs_conf_t conf = { .base_path = "/spiffs", .partition_label = NULL, .max_files = 5, // This decides the maximum number…
SolvedForHome
  • 152
  • 1
  • 15
1
vote
1 answer

AVR and FATFS Multiple block read

I am using atmega1284p and I need to read data from sd card and send audio decoder chip I can do it for low bitrates,higher bitrates MCU struggle to send data on time. Respect to my research to achieve the high bitrates, files can be read muliple…
msalah11
  • 11
  • 1
1
vote
2 answers

FatFs read/write in root work but not in subfolder

Already thanks for your time. I'm a little lost on how can I debug a problem I have with FatFs: write then read files inside folder brings me invalid data. but on the root, it work flawessly. note: I'm working on a bar-metal nrf52832 using FatFs…
quartane
  • 63
  • 6