Commit 08d652db authored by Carlo Kirchmeier's avatar Carlo Kirchmeier Committed by Benjamin Cabé
Browse files

test: fs: enable fstab devicetree integration for fatfs

Added tests in order to verify the functionality of the
newly added fatfs fstab integration.

Signed-off-by: default avatarCarlo Kirchmeier <carlo.kirchmeier@zuehlke.com>
Co-authored-by: default avatarCarlo Kirchmeier <carlo.kirchmeier@zuehlke.com>
Co-authored-by: default avatarDominik Ermel <dominik.ermel@nordicsemi.no>
parent 1ea0267a
Loading
Loading
Loading
Loading
+9 −0
Changes for samples/subsys/fs/fatfs_fstab/CMakeLists.txt: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright (c) 2025 Endress+Hauser AG
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(fatfs_fstab_sample)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
+36 −0
Changes for samples/subsys/fs/fatfs_fstab/README.rst: 36 added lines, 0 removed lines.
Original line number Diff line number Diff line
.. zephyr:code-sample:: fatfs-fstab
   :name: Fatfs filesystem fstab
   :relevant-api: file_system_api

   Define fatfs filesystems in the devicetree.

Overview
***********

This sample shows how to define a fatfs fstab entry in the devicetree.
This scenario uses a fatfs on a RAM disk. The sample is run on the
``native_sim`` board.

Building and running
********************

To run this sample, build it for the ``native_sim`` board
and afterwards run the generated executable file within the build folder.

The RAM disk sample for the ``native_sim`` board can be built as follows:

.. zephyr-app-commands::
   :zephyr-app: samples/subsys/fs/fatfs_fstab
   :host-os: unix
   :board: native_sim
   :gen-args: -DDTC_OVERLAY_FILE=fatfs_fstab.overlay
   :goals: build
   :compact:

Sample Output
=============

When the sample runs successfully you should see following message on the screen:
.. code-block:: console

  I: Filesystem access successful
+24 −0
Changes for samples/subsys/fs/fatfs_fstab/fatfs_fstab.overlay: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
 * Copyright (c) 2025 Endress+Hauser AG
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/ {
	fstab {
		compatible = "zephyr,fstab";
		ffs1: ffs1 {
			compatible = "zephyr,fstab,fatfs";
			automount;
			disk-access;
			mount-point = "/RAM:";
		};
	};

	ramdisk0 {
		compatible = "zephyr,ram-disk";
		disk-name = "RAM";
		sector-size = <512>;
		sector-count = <128>;
	};
};
+10 −0
Changes for samples/subsys/fs/fatfs_fstab/prj.conf: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
CONFIG_DISK_ACCESS=y
CONFIG_DISK_DRIVERS=y

CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y

CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_MKFS=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FS_FATFS_FSTAB_AUTOMOUNT=y
+14 −0
Changes for samples/subsys/fs/fatfs_fstab/sample.yaml: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
sample:
  name: fatfs fstab sample
tests:
  sample.filesystem.fat_fs.fstab:
    platform_allow:
      - native_sim
    extra_args:
      - EXTRA_DTC_OVERLAY_FILE="fatfs_fstab.overlay"
    tags: filesystem
    harness: console
    harness_config:
      type: one_line
      regex:
        - "I: Filesystem access successful"
Loading