Skip to content

Commit fa0bae8

Browse files
committed
drivers: disk: add fakefat disk driver
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>
1 parent 98e0e65 commit fa0bae8

File tree

7 files changed

+1121
-0
lines changed

7 files changed

+1121
-0
lines changed

drivers/disk/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ if(CONFIG_DISK_DRIVERS)
55

66
zephyr_library()
77

8+
zephyr_library_sources_ifdef(CONFIG_DISK_DRIVER_FFAT ffatdisk.c)
89
zephyr_library_sources_ifdef(CONFIG_DISK_DRIVER_FLASH flashdisk.c)
910
zephyr_library_sources_ifdef(CONFIG_DISK_DRIVER_RAM ramdisk.c)
1011
zephyr_library_sources_ifdef(CONFIG_DISK_DRIVER_LOOPBACK loopback_disk.c)
@@ -15,4 +16,6 @@ zephyr_library_sources_ifdef(CONFIG_MMC_SUBSYS mmc_subsys.c)
1516

1617
add_subdirectory_ifdef(CONFIG_NVME nvme)
1718

19+
zephyr_linker_sources_ifdef(CONFIG_DISK_DRIVER_FFAT DATA_SECTIONS ffatdisk.ld)
20+
1821
endif()

drivers/disk/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ menuconfig DISK_DRIVERS
99
if DISK_DRIVERS
1010

1111
source "drivers/disk/Kconfig.ram"
12+
source "drivers/disk/Kconfig.ffat"
1213
source "drivers/disk/Kconfig.flash"
1314
source "drivers/disk/Kconfig.sdmmc"
1415
source "drivers/disk/Kconfig.mmc"

drivers/disk/Kconfig.ffat

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (c) 2023 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config DISK_DRIVER_FFAT
5+
bool "Fake FAT Disk"
6+
default y if DT_HAS_ZEPHYR_FFAT_DISK_ENABLED
7+
help
8+
Fake FAT disk emulates a disk formatted with the FAT file system
9+
and provides very limited functionality. It can be used for testing
10+
or to map services such as firmware updates to a file on
11+
the emulated disk.
12+
13+
if DISK_DRIVER_FFAT
14+
15+
module = FFATDISK
16+
module-str = ffatdisk
17+
source "subsys/logging/Kconfig.template.log_config"
18+
19+
endif # DISK_DRIVER_FFAT

0 commit comments

Comments
 (0)