This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FAT file error

Hi,

we are trying to use FAT file in nRF9160. Referring the test case in "ncs\zephyr\tests\subsys\fs\multi-fs\src" to mount the FAT file.

But getting an error like "ff.h" not found:

../src/main.c:24:10: fatal error: ff.h: No such file or directory
#include <ff.h>

Code tried:

#define FATFS_MNTP "/RAM:"
#define TEST_FILE FATFS_MNTP"/testfile.txt"
#define TEST_DIR FATFS_MNTP"/testdir"
#define TEST_DIR_FILE FATFS_MNTP"/testdir/testfile.txt"

static FATFS fat_fs;

static struct fs_mount_t fatfs_mnt = {
.type = FS_FATFS,
.mnt_point = FATFS_MNTP,
.fs_data = &fat_fs,
};

void main(void)
{
int res;
res = fs_mount(&fatfs_mnt);
if (res < 0) {
printk("Error mounting fs [%d]\n", res);
return 0;
}}

Help us to resolve the error or please point us to the sample code/application to store the content in file system.

And what all are ways to persist  the settings/content in nRF9160 ?

Thanks,
Bala

 

  • Hello Bala, 

    But getting an error like "ff.h" not found:

    ../src/main.c:24:10: fatal error: ff.h: No such file or directory
    #include <ff.h>

    Yes, you are correct, the file is not included in NCS. I'm not sure if this is intentionally or a mistake, will forward to our NCS team. I can not guarantee that this sample works with nRF9160 out of the box, as I see that the official Zephyr sample FAT Filesystem Sample Application  states:

    This sample can be built for an nrf52840_blip board

    What files did you try? The file ff.h is available through the nRF52 SDK, perhaps you could use this file as a work-around?

    More information found here, here and here

  • Thanks,

    Is there any other way to store/persist the settings(key/value pair) in nRF9160.?

  • Have a look at the Flash API and the File systems chapter

    You could also look at the NVS sample:

    NVS Sample for Zephyr using high level API, the sample illustrates the usage of NVS for storing data of different kind (strings, binary blobs, unsigned  32 bit integer) and also how to read them back from flash. The reading of data is illustrated for both a basic read (latest added value) as well as reading back the history of data (previously added values). Next to reading and writing data it also shows how data can be deleted from flash.

    Kind regards,
    Øyvind

  • Hi  I'm having a similar issue.  I've opted to download the ELMFAT source myself and include it in the src and include directories in order to access a FAT32 filesystem on an SD card.  It appears through the zephyr/samples/subsys/fs example that the system should detect a SDHC card at boot, but I'm having trouble understanding how/where the subsystem does this automatically.  I understand that the system should understand through the device tree that the SDHC card is available on a SPI interface, but from there I am having difficulty understanding how to debug either the interface or system detection.

    Per the documentation, it appears by using the following configs and device overlay zephyr should be able to auto-register the SDHC:

    CONFIG_GPIO=y
    CONFIG_SPI=y
    CONFIG_SPI_1=y
    CONFIG_SPI_1_NRF_SPIM=y
    CONFIG_DISK_ACCESS=y
    CONFIG_DISK_ACCESS_SDHC=y
    CONFIG_DISK_ACCESS_SPI_SDHC=y
    CONFIG_DISK_SDHC_VOLUME_NAME="SD"
    CONFIG_LOG=y
    CONFIG_FILE_SYSTEM=y
    # CONFIG_FAT_FILESYSTEM_ELM=y
    CONFIG_PRINTK=y

    &spi1 {
    status = "ok";
    sck-pin = <13>;
    mosi-pin = <11>;
    miso-pin = <12>;
    ss-pin = <10>;
    };

    &spi1 {
    status = "ok";
    cs-gpios = <&gpio0 10 0>;

    sdhc0: sdhc@0 {
    compatible = "zephyr,mmc-spi-slot";
    reg = <0>;
    status = "ok";
    label = "SDHC0";
    spi-max-frequency = <1000000>;
    };
    };


  • Hello , please register a new ticket with your issue as this ticket is closed.

    Kind regards,
    Øyvind

Related