【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.
相关推荐
602寝室长2 天前
RT-THREAD RTC组件中Alarm功能驱动完善
stm32·单片机·rt-thread·rtos
niu_881 个月前
双向链表的理解
rt-thread·双向链表
苏慕TRYACE3 个月前
RT-Thread+STM32L475VET6实现红外遥控实验
stm32·单片机·嵌入式硬件·rt-thread
苏慕TRYACE3 个月前
RT-Thread+STM32L475VET6——ADC采集电压
stm32·单片机·嵌入式硬件·rt-thread
苏慕TRYACE3 个月前
RT-Thread+STM32L475VET6实现呼吸灯
c++·嵌入式·rt-thread
嵌入式学习和实践7 个月前
stm32 单片机(on-chip flash)(片上flash)使用 rt-thread 的FAL 软件包
stm32·单片机·rt-thread·flash·fal
我先去打把游戏先7 个月前
RT-Thread之STM32使用定时器实现输入捕获
c语言·stm32·单片机·嵌入式硬件·学习·机器人·rt-thread
我先去打把游戏先7 个月前
RT-Thread之STM32使用定时器实现输出比较
c语言·stm32·单片机·嵌入式硬件·学习·机器人·rt-thread
嵌入式学习和实践7 个月前
stm32 使用 rt-thread 引脚PIN中断设置边沿触发问题
stm32·单片机·rt-thread·引脚中断