【RT-Thread Studio】nor flash配置Fal分区

前置条件:【RT-Thread Studio】W25Q128配置


添加 FAL软件包

配置SFUD驱动程序,使用FAL的设备为W25Q128

将fal_cfg.h和fal_flash_sfud_port.c提取出来,放到自己创建的fal_porting目录。

修改
fal_flash_sfud_port.c

c 复制代码
struct fal_flash_dev nor_flash0 =
{
    .name       = FAL_USING_NOR_FLASH_DEV_NAME,
    .addr       = 0,
    .len        = 16 * 1024 * 1024,
    .blk_size   = 4096,
    .ops        = {init, read, write, erase},
    .write_gran = 1
};

fal_cfg.h

c 复制代码
#define NOR_FLASH_DEV_NAME             FAL_USING_NOR_FLASH_DEV_NAME

/* ===================== Flash device Configuration ========================= */
extern struct fal_flash_dev nor_flash0;

/* flash device table */
#define FAL_FLASH_DEV_TABLE                                          \
{                                                                    \
    &nor_flash0,                                                     \
}
/* ====================== Partition Configuration ========================== */
#ifdef FAL_PART_HAS_TABLE_CFG
/* partition table */
#define FAL_PART_TABLE                                                                  \
{                                                                                       \
    {FAL_PART_MAGIC_WORD,   "filesystem",   NOR_FLASH_DEV_NAME, 0,  16*1024*1024,   0}, \
}
#endif /* FAL_PART_HAS_TABLE_CFG */

测试应用

c 复制代码
#include <app_fs/w25qxx.h>
#include <fal.h>

static void app_fs_init(void)
{
    dev_spi_flash_init();
    fal_init();
}

static int component_app_fs_init(void)
{
    app_fs_init();
    return RT_EOK;
}

INIT_COMPONENT_EXPORT(component_app_fs_init);

开机日志:

shell 复制代码
[16] I/SFUD: Find a Winbond flash chip. Size is 16777216 bytes.
[24] I/SFUD: W25Q128 flash device is initialize success.
[30] I/SFUD: Probe SPI flash W25Q128 by SPI device spi10 success.
read w25q ID is:17ef
[D/FAL] (fal_flash_init:49) Flash device |                  W25Q128 | addr: 0x00000000 | len: 0x01000000 | blk_size: 0x00001000 |initialized finish.
[I/FAL] ==================== FAL partition table ====================
[I/FAL] | name       | flash_dev |   offset   |    length  |
[I/FAL] -------------------------------------------------------------
[I/FAL] | filesystem | W25Q128   | 0x00000000 | 0x01000000 |
[I/FAL] =============================================================
[I/FAL] RT-Thread Flash Abstraction Layer (V1.0.0) initialize success.
相关推荐
xzl048 小时前
PL111 RGB LCD时序配置详解
rt-thread·pl111
xzl041 天前
LVGL 启动流程全解析:RT-Thread 下的界面渲染链路
rt-thread·lvgl
xzl041 天前
LVGL Coffee UI 接入实战:问题解决全记录
ui·rt-thread·lvgl
神一样的老师7 天前
【兆易创新GD32VW553开发板试用】 BSP 从 GitHub 下载与编译指南
单片机·github·rt-thread
xzl047 天前
【Menuconfig】RT-Thread配置菜单第一级
rt-thread
xzl048 天前
瑞萨 FSP 和 STM32 HAL 库的启动流程核心差异
stm32·单片机·嵌入式硬件·rt-thread
xzl048 天前
RT-Thread 5.2.2内核模块
开发语言·rt-thread
fox08152 个月前
RTThread-Studio中,使用5.2.0版本默认配置生成工程,进行编译报警告的部分解决方法。
mcu·rt-thread·rtthread-studio
混分巨兽龙某某3 个月前
基于STM32的嵌入式操作系统RT-Thread移植教学(HAL库版本)
stm32·嵌入式硬件·rt-thread·rtos
张世争3 个月前
RT-Thread 5.3 windows bsp simulator scons --target=vs 生成的工程编译失败问题
windows·rt-thread·simulator