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.
95 questions
11
votes
1 answer

STM32 USB OTG HOST Library hangs trying to create file with FatFs

I am trying to create a file with FatFs on USB flash, but my f_open call trying to read boot sector for first time file system mount hangs on this function. DRESULT disk_read ( BYTE drv, /* Physical drive number (0) */ …
Mykola
  • 3,152
  • 6
  • 20
  • 39
3
votes
2 answers

Does any FAT FS driver want bytes 508 and 509 of the boot sector to be zero?

While implementing my own boot sector loaders starting in 2012 I made sure to zero the bytes at offsets 508 and 509. These are the fourth to last and third to last bytes of a standard 512 byte sized sector. This is what I put there: _fill…
ecm
  • 2,092
  • 2
  • 15
  • 22
3
votes
1 answer

STM32 + SD card (FATFS and SPI) + physical connection + FR_NOT_READY

I am new to the world of stm and STM32CubeMX. So far, I was able to successfully implement SPI and I2C on a temperature sensor. Now I try to write data to an SD card, unfortunately so far without success. As a microcontroller I use the STM32L073RZT6…
Till
  • 31
  • 1
  • 4
3
votes
1 answer

Fatfs significant slow down in directories with many files

I have a data logging system running on an STM32F7 which is storing data using FatFs by ChaN to an SD card: http://elm-chan.org/fsw/ff/00index_e.html Each new set of data is stored in a separate file withing a directory. During post-processing on…
3
votes
2 answers

STM32 and SD card (FATFS and SPI)

I'm starting to work with a stm32l0 board and it was fine until I had some more interesting functions to use. I never read SD card out of windows, I found Pins links and started to read about SPI which could be a suitable solution for our prject (I…
Blaitox
  • 33
  • 1
  • 1
  • 4
2
votes
1 answer

FatFS - Cannot format drive, FR_MKFS_ABORTED

I am new to embedded development and have been tasked with implementing a file system on SPI flash memory. I am using a w25qxx chip and an STM32F4xx on STM32CubeIDE. I have successfully created the basic i/o for the w25 over SPI, being able to write…
2
votes
0 answers

Problems with SD-Card and FatFs (Mounting, Opening Files)

I've got some problems with the FATFs library and the STM32F7 Series. I want to connect a SD-Card (32GB, SanDisk, FAT32) with the F746G-Discovery-Board to save some data on it. (at first .txt-Files, later read .csv Files to visualize some measuring…
Melissa123
  • 55
  • 7
2
votes
1 answer

How to emulate FatFS?

I'd like to present some data on a microcontroller (STM32L4xx) to appear as though it was a single file on a filesystem mounted over USB to a host PC. I have functions that can produce the data at any requested offset in the (emulated) file. The…
Alex I
  • 18,105
  • 7
  • 72
  • 135
2
votes
1 answer

Why does sending CMD58 over SPI to my Class 10 SD return 0x01 instead of 0x00?

I am trying to initialize an SD card using an SPI bus and STM32F4 Discovery Board. I am mainly relying on Elm Chan's implementation of the disk_initialize function in the example code to base my own implementation. Unfortunately, I have run into an…
2
votes
4 answers

STM32F7 + FatFs = FR_NOT_READY

I am now using CubeMx 4.23.0 and FW package for STM32F7 1.8.0 MCU is STM32F746 on Core746i board. Everything is generated by CubeMx automatically. main.c: SCB_EnableICache(); SCB_EnableDCache(); HAL_Init(); SystemClock_Config(); …
ub0baa
  • 65
  • 1
  • 9
2
votes
0 answers

Fat12 emulation

I implemented FatFS in internal memory of MCU STM32 Chan's library. Now I try to emulate bigger volume of flash device to receive large files from PC. I can do it by changing two places of FatFS image: 1. By changing MBR_start + 12 field value of…
user3583807
  • 603
  • 1
  • 8
  • 21
2
votes
5 answers

FatFS f_write not working

I am on a ZedBoard and I am trying to write on an SD card. I am working on an embedded system and I dont have any OS, I am running baremetal. I can read fine from the SD card, their is no problem. But when I triy to read, I have some weird behaviour…
Aymen
  • 93
  • 1
  • 1
  • 9
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
  • 65
  • 8
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

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
2 3 4 5 6 7