Yuqiang Wang e1498cabc9 SDK build (#47) 6 ماه پیش
..
.settings 4795f3d206 更新fsp为2.2.0 7 ماه پیش
board 4795f3d206 更新fsp为2.2.0 7 ماه پیش
figures e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
packages 4795f3d206 更新fsp为2.2.0 7 ماه پیش
rzn 0e9a0dfdbd fix iar link source 7 ماه پیش
rzn_cfg 0e9a0dfdbd fix iar link source 7 ماه پیش
rzn_gen 0e9a0dfdbd fix iar link source 7 ماه پیش
script 4795f3d206 更新fsp为2.2.0 7 ماه پیش
src e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
.api_xml e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
.config 4795f3d206 更新fsp为2.2.0 7 ماه پیش
.cproject 4795f3d206 更新fsp为2.2.0 7 ماه پیش
.gitignore e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
.project 4795f3d206 更新fsp为2.2.0 7 ماه پیش
.secure_azone e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
.secure_rzone 4795f3d206 更新fsp为2.2.0 7 ماه پیش
.secure_xml 4795f3d206 更新fsp为2.2.0 7 ماه پیش
Kconfig 4795f3d206 更新fsp为2.2.0 7 ماه پیش
README.md e1498cabc9 SDK build (#47) 6 ماه پیش
README_zh.md e1498cabc9 SDK build (#47) 6 ماه پیش
SConscript 0e9a0dfdbd fix iar link source 7 ماه پیش
SConstruct e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
buildinfo.ipcf 0e9a0dfdbd fix iar link source 7 ماه پیش
buildinfo.json 4795f3d206 更新fsp为2.2.0 7 ماه پیش
configuration.xml 4795f3d206 更新fsp为2.2.0 7 ماه پیش
envsetup.sh e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
mklinks.bat e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
mklinks.sh e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
ozone_scons.jdebug e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
project.ewd 0e9a0dfdbd fix iar link source 7 ماه پیش
project.ewp 0e9a0dfdbd fix iar link source 7 ماه پیش
project.ewt 0e9a0dfdbd fix iar link source 7 ماه پیش
project.eww e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
rtconfig.h 4795f3d206 更新fsp为2.2.0 7 ماه پیش
rtconfig.py e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش
rzn_cfg.txt 4795f3d206 更新fsp为2.2.0 7 ماه پیش
template.ewd 0e9a0dfdbd fix iar link source 7 ماه پیش
template.ewp 0e9a0dfdbd fix iar link source 7 ماه پیش
template.eww e9ee0a7ce5 add filesystem project and public v1.2.1 10 ماه پیش

README.md

Filesystem Usage Instructions

English | 中文

Introduction

FAL (Flash Abstraction Layer) is an abstraction layer for managing and operating Flash devices and Flash-based partitions. It provides a unified API for upper-layer Flash and partition operations (as shown in the framework diagram below), with the following features:

  • Supports a statically configurable partition table, which can be associated with multiple Flash devices.
  • The partition table supports automatic loading, avoiding the issue of the partition table being repeatedly defined in multi-firmware projects.
  • Lightweight code with no dependency on an operating system, allowing it to run on bare-metal platforms, such as bootloaders with limited resources.
  • A unified operation interface ensures the reusability of underlying Flash drivers for components that rely on Flash, such as file systems, OTA, and NVM (e.g., EasyFlash).
  • Built-in Finsh/MSH-based test commands, enabling developers to read, write, and erase Flash or partitions via shell commands with byte-level addressing, which facilitates debugging and testing.

FAL framework

In this example, the EtherKit onboard GD Flash is combined with the RT-Thread FAL component to build a file system using littlefs.

Hardware Overview

image-20250421131242258

Software Overview

The source code for file system initialization in this example is located at:
../board/ports/filesystem/drv_filesystem.c

/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author                Notes
 * 2025-02-07     newflydd@gmail.com    the first version
 */
#define DBG_TAG "drv.fs"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

#include <rtthread.h>
#include <fal.h>
#include <dfs_fs.h>

int initFileSystem()
{
    fal_init();

    // register onchip flash tail area as littlefs
    struct rt_device* flashDev = fal_mtd_nor_device_create("param");
    if (RT_NULL == flashDev)
    {
        LOG_W("create fal device failed");
        return RT_ERROR;
    }

    if (RT_EOK != dfs_mount("param", "/", "lfs", 0, RT_NULL))
    {
        LOG_W("mount lfs failed once, try to format it");
        if (RT_EOK != dfs_mkfs("lfs", "param"))
        {
            LOG_W("mkfs lfs failed");
            return RT_ERROR;
        }
        LOG_I("mkfs lfs success");

        if (RT_EOK != dfs_mount("param", "/", "lfs", 0, RT_NULL))
        {
            LOG_W("mount lfs failed");
            return RT_ERROR;
        }
    }
    LOG_I("mount lfs success");
    return RT_EOK;
}
INIT_ENV_EXPORT(initFileSystem);

Build & Download

  • RT-Thread Studio: Download the EtherKit resource pack from the RT-Thread Studio package manager, then create a new project and compile it.

  • IAR: First, double-click mklinks.bat to generate links for the rt-thread and libraries folders. Then, use Env to generate the IAR project. Finally, double-click project.eww to open the IAR project and compile it.

Once compiled, connect the development board’s JLink interface to the PC, and download the firmware to the development board.

Running Result

Press the reset button to restart the development board and observe the terminal logs from the board.

image-20250421131424928

Run the following commands to start the FAL read/write test:

> fal probe param param
> fal bench 4096 yes