首先是FAL能正常启动,根目录的分区也挂载正常。
[D/FAL] (fal_flash_init:61) Flash device | coreboard | addr: 0x00000000 | len: 0x01000000 | blk_size: 0x00001000 |initialized finish. [D/FAL] (fal_flash_init:61) Flash device | norflash0 | 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] | bootloader | coreboard | 0x00000000 | 0x00008000 |
[I/FAL] | app | coreboard | 0x00008000 | 0x007f8000 |
[I/FAL] | littlefs | coreboard | 0x00800000 | 0x00200000 |
[I/FAL] | download | coreboard | 0x00a00000 | 0x00200000 |
[I/FAL] | fatfs | coreboard | 0x00c00000 | 0x00300000 |
[I/FAL] | easyflash | coreboard | 0x00f00000 | 0x00100000 |
[I/FAL] | file | norflash0 | 0x00000000 | 0x01000000 |
[I/FAL] =============================================================
[I/FAL] RT-Thread Flash Abstraction Layer (V0.5.0) initialize success.
[I/FAL] The FAL MTD NOR device (littlefs) created successfully
[I/littlefs.sample] para initialized!
[I/FAL] The FAL MTD NOR device (download) created successfully
[E/littlefs.sample] Failed to initialize download!
[Flash] (packagesEasyFlash-v4.1.0srcef_env.c:1818) ENV start address is 0x00000000, size is 8192 bytes.
[Flash] EasyFlash V4.1.0 is initialize success.
[Flash] You can get the latest version on
挂载第一个分区后,新建目录,用于挂载download分区,但是挂载失败
int result = 0;
#ifdef PKG_USING_FAL
// 初始化 fal
fal_init();
#else
return;
#endif
#ifdef PKG_USING_LITTLEFS
#define LITTLEFS_PARTITION_NAME "littlefs"
struct rt_device *mtd_dev = RT_NULL;
// 创建 mtd 设备
mtd_dev = fal_mtd_nor_device_create(LITTLEFS_PARTITION_NAME);
if (!mtd_dev)
{
LOG_E("Can't create a mtd device on '%s' partition.", LITTLEFS_PARTITION_NAME);
}
else
{
// 挂载littlefs
// 参数: 块设备名、文件系统挂载点路径,挂载文件系统类型,读写标志位,文件系统的私有数据
if (dfs_mount(LITTLEFS_PARTITION_NAME, "/", "lfs", 0, 0) == 0)
{
LOG_I("para initialized!");
}
else
{
/* 格式化文件系统 */
dfs_mkfs("lfs", LITTLEFS_PARTITION_NAME);
/* 挂载 littlefs */
if (dfs_mount(LITTLEFS_PARTITION_NAME, "/", "lfs", 0, 0) == 0)
{
LOG_I("%s initialized!",LITTLEFS_PARTITION_NAME);
}
else
{
LOG_E("Failed to initialize %s!",LITTLEFS_PARTITION_NAME);
result = -1;
}
}
}
if(result == 0)
{
#define LITTLEFS_PARTITION_NAME2 "download"
mtd_dev = fal_mtd_nor_device_create(LITTLEFS_PARTITION_NAME2);
if (!mtd_dev)
{
LOG_E("Can't create a mtd device on '%s' partition.", LITTLEFS_PARTITION_NAME2);
}
else
{
if(opendir("/c") == RT_NULL)
{
mkdir("c",0);
}
if (dfs_mount(LITTLEFS_PARTITION_NAME2, "/c", "lfs", 0, 0) == 0)
{
LOG_I("%s Filesystem initialized!",LITTLEFS_PARTITION_NAME2);
}
else
{
dfs_mkfs("lfs", LITTLEFS_PARTITION_NAME2);
if (dfs_mount(LITTLEFS_PARTITION_NAME2, "/c", "lfs", 0, 0) == 0)
LOG_I("%s Filesystem initialized!",LITTLEFS_PARTITION_NAME2);
else
LOG_E("Failed to initialize %s!",LITTLEFS_PARTITION_NAME2);
}
}
}
#endif
#ifdef PKG_USING_EASYFLASH
/* easyflash init */
easyflash_init();
#endif
mtd设备是正常创建的,
device type ref count
-------- -------------------- ----------
download MTD Device 0
littlefs MTD Device 1
norflash Block Device 0
adc1 Miscellaneous Device 0
pwm2 Miscellaneous Device 0
pwm1 Miscellaneous Device 0
刚开始使用文件系统,求大佬指导下,问题在哪。。