Skip to content

Commit

Permalink
drivers: disk: add fakefat disk driver
Browse files Browse the repository at this point in the history
Fakefat disk emulates a disk formatted with the FAT file system.
The driver supports FAT16 and FAT32 emulation and multiple instances.
A backend can register at least 15 emulated files on a disk instance.
The file structure contain read and write callbacks that are called
when the filesystem driver accesses the volume. A backend can have
multiple files with read callbacks, but usually only one or zero with
write callbacks.

Fakefat disk can be used for testing or to map services such as
firmware updates to a file on the emulated disk.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
  • Loading branch information
jfischer-no committed Oct 16, 2024
1 parent 8c705ca commit a93c867
Show file tree
Hide file tree
Showing 7 changed files with 1,121 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/disk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if(CONFIG_DISK_DRIVERS)

zephyr_library()

zephyr_library_sources_ifdef(CONFIG_DISK_DRIVER_FFAT ffatdisk.c)
zephyr_library_sources_ifdef(CONFIG_DISK_DRIVER_FLASH flashdisk.c)
zephyr_library_sources_ifdef(CONFIG_DISK_DRIVER_RAM ramdisk.c)
zephyr_library_sources_ifdef(CONFIG_DISK_DRIVER_LOOPBACK loopback_disk.c)
Expand All @@ -15,4 +16,6 @@ zephyr_library_sources_ifdef(CONFIG_MMC_SUBSYS mmc_subsys.c)

add_subdirectory_ifdef(CONFIG_NVME nvme)

zephyr_linker_sources_ifdef(CONFIG_DISK_DRIVER_FFAT DATA_SECTIONS ffatdisk.ld)

endif()
1 change: 1 addition & 0 deletions drivers/disk/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ menuconfig DISK_DRIVERS
if DISK_DRIVERS

source "drivers/disk/Kconfig.ram"
source "drivers/disk/Kconfig.ffat"
source "drivers/disk/Kconfig.flash"
source "drivers/disk/Kconfig.sdmmc"
source "drivers/disk/Kconfig.mmc"
Expand Down
19 changes: 19 additions & 0 deletions drivers/disk/Kconfig.ffat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

config DISK_DRIVER_FFAT
bool "Fake FAT Disk"
default y if DT_HAS_ZEPHYR_FFAT_DISK_ENABLED
help
Fake FAT disk emulates a disk formatted with the FAT file system
and provides very limited functionality. It can be used for testing
or to map services such as firmware updates to a file on
the emulated disk.

if DISK_DRIVER_FFAT

module = FFATDISK
module-str = ffatdisk
source "subsys/logging/Kconfig.template.log_config"

endif # DISK_DRIVER_FFAT
Loading

0 comments on commit a93c867

Please sign in to comment.