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
1
vote
2 answers

STM32 : FatFs Library - f_mount

I am programming the STM32F0 (Keil uVision 5). I've tried to use FatFs library to manage a file system (SD card). I've writen every initialization functions and the project is compiling without any errors / warnings. But first function f_mount…
HynHiX
  • 11
  • 1
  • 3
0
votes
0 answers

Does Fatfs support storing files larger than 4GB when FF_LBA64 is disabled?

in NXP's Kinetis series MCU, I have formatted the 8GB-sized EMMC as a Fatfs file system and also implemented the USB MSC function, which allows accessing the files in Fatfs through USB on a computer. I have used mutex locks to separate the calls to…
0
votes
1 answer

FatFS f_open FR_INVALID_OBJECT

I'm using the NXP port of FatFS with an SD card using SPI for connection. f_mount returned FR_OK When I call this code to open a file called "skript.txt" in the root folder: printf("Trying to open file %s\n", this->name); // // Open the hex…
0
votes
0 answers

FatFS cannot se files on PC

I have a problem with stm32l4r5 (nucleo-l4r5zi) and reading SD cards. I am using fatfs from https://01001000.xyz/2020-08-09-Tutorial-STM32CubeIDE-SD-card/. SPI and CS pins pulled up, prescaler 256. I have 4 SD cards, but I can only communicate with…
Chey
  • 3
  • 2
0
votes
0 answers

fresult gives FR_NO_FILESYSTEM and f_mount returns FR_DISK_ERR

i am using stm32f103xx to modify sdcard functions but fresult returns FR_NO_FILESYSTEM and f_mount returns FR_DISK_ERR and I have no idea what is the error. int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU…
Maip N.
  • 1
  • 2
0
votes
0 answers

GD32 FATFS: f_mount() return FR_NO_FILESYSTEM

I'm using GD32F105RBT6 and I'm trying to save the text file to FAT32 flash drive. But f_mount() returns FR_NO_FILESYSTEM. If I use a project that uses only USB host and try to save the file, everything works. In a project with other peripherals…
Natr
  • 1
  • 1
0
votes
0 answers

Items not being written to file on FatFS SD Card

UPDATE This code below works. It turns out my problem lied further down the chain with the software I was using to interface with the device and download files off. I pulled the SD card out of the device and plugged it directly into my PC, and you…
jabroni
  • 167
  • 16
0
votes
0 answers

FatFs SD Card Writing OK; Reading Partially

I followed this link STM32 SD Card Example to have made FatFs library work on my STM32 F411 PCB board. Basically I need to store 1000+ floating point values in SD card and read them back. I have no problem in writing; but I cannot read all the…
djsg
  • 107
  • 1
  • 8
0
votes
0 answers

Unit testig embedded module which uses fatfs on a PC

I'm working on an embedded C app. Some modules use fatfs to access an SD card. I would like to build some unit tests for those modules that will run on a pc for easier development. As I did not already use files functions in C, I thought that the…
Julien
  • 846
  • 1
  • 7
  • 19
0
votes
0 answers

Error F_NOT_READY when using sdhc card (4GB) on stm32

I want to store information in sdhc memory using stm32. But the f_mount command always returns FR_NOT_READY. But when using sdsc memories (less than 2G), the code works correctly. My microcontroller is stm32H743iit6 All sdsc memorty card (2GB) work…
Majid Soltani
  • 688
  • 7
  • 5
0
votes
1 answer

write data to 2 different fat volumes within the same SDcard using TivaC mcu tm4c129xnczad microcontroller

I had a tm4c129xnczad microcontroller with SDcard connected to it via SPI3 and the SDcard with 1 Gb size had 2 volumes with about 500 Mb each I want to write data to files to each volume I can access the first one but the second volume is not…
0
votes
1 answer

Error when runing USB_OTG_FS with RTOS for pendrive application

First of all I have run the project with STM32H745I + USB_OTG_FS + FATFS + MSHC for the pendrive application and it runs without any error, I am able to create a file, directrory & write into the file. But when I add FreeRTOS in the same combination…
0
votes
0 answers

How to speed up USB msc host in stm32 or Enable DMA to speed up IO operations on usb?

Is there any way to speed up stm32 USB host applications. For example I am running at 207 MHz in stm32f730v8 my USB clock is 48 MHz and I want to open a director. It takes about 30 milliseconds on average. For a very complicated and hierarchal…
Nima Aghayan
  • 109
  • 1
  • 7
0
votes
0 answers

e-MMC returns FR_OK at very first bring-up but mk_dir return FR_NO_FILESYSTEM

I am using stm32H753xx and Cube FatFs library. After our e-MMC has been soldered to our board, I want to bring-up. My startup codes is here: res = f_mount(&fat_fs, "0:", 0); if (res != FR_OK) { res = f_mkfs("", FM_ANY, 0, work,…
0
votes
0 answers

Issue with writing to SD card on STM32F303

I'm trying to write to an SD card using an STM32F303 controller using STM32 HAL and the FATFS libraries. I'm able to mount the card and successfully write the file to the SD card and write values to it for some time. However after some time, the…