主要运行代码
#include
#include /* 当需要使用文件操作时,需要包含这个头文件 */
static void mkdir_sample(void) {
int ret;
/* 创建目录*/
ret = mkdir("/hello_1", 0x777);
ret = mkdir("/hello_2", 0x777);
ret = mkdir("/hello_3", 0x777);
ret = mkdir("/hello_4", 0x777);
ret = mkdir("/hello_5", 0x777);
ret = mkdir("/hello_6", 0x777);
if (ret < 0)
{
/* 创建目录失败*/
rt_kprintf("dir error!\n");
}
else
{
/* 创建目录成功*/
rt_kprintf("mkdir ok!\n");
}
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT(mkdir_sample, mkdir sample);
问题
一但创建第三个目录就会出事,但文件数量创建了二十多个也没出事
出现packages/littlefs-latest/lfs.c560error: No more free space 9 错误
没有更多可用的空间?
感觉分了768KB给littlefs(STM32427VIT6 扇区17到23),应该也够用了吧。 难道创建目录
占很多的空间?
源码看的我有点晕,有没有dalao有想法,望指点。
packages/littlefs-latest/lfs.c文件对应560行处函数
// check if we have looked at all blocks since last ack
if (lfs->free.ack == 0) {
LFS_ERROR("No more free space %"PRIu32,
lfs->free.i + lfs->free.off);
return LFS_ERR_NOSPC;
}
初始化情况
\ | /
- RT - Thread Operating System
/ | \ 4.0.2 build Feb 2 2021
2006 - 2019 Copyright by rt-thread team
[D/FAL] (fal_flash_init:61) Flash device | onchip_flash_16k | addr: 0x08100000 | len: 0x00010000 | blk_size: 0x00004000 |initialized finish.
[D/FAL] (fal_flash_init:61) Flash device | onchip_flash_64k | addr: 0x08110000 | len: 0x00010000 | blk_size: 0x00010000 |initialized finish.
[D/FAL] (fal_flash_init:61) Flash device | onchip_flash_128k | addr: 0x08120000 | len: 0x000e0000 | blk_size: 0x00020000 |initialized finish.
[32;22m[I/FAL] ==================== FAL partition table ====================[0m
[32;22m[I/FAL] | name | flash_dev | offset | length |[0m
[32;22m[I/FAL] -------------------------------------------------------------[0m
[32;22m[I/FAL] | bl | onchip_flash_16k | 0x00000000 | 0x00010000 |[0m
[32;22m[I/FAL] | param | onchip_flash_64k | 0x00000000 | 0x00010000 |[0m
[32;22m[I/FAL] | app | onchip_flash_128k | 0x00000000 | 0x00020000 |[0m
[32;22m[I/FAL] | filesystem | onchip_flash_128k | 0x00020000 | 0x000c0000 |[0m
[32;22m[I/FAL] =============================================================[0m
[32;22m[I/FAL] RT-Thread Flash Abstraction Layer (V0.5.0) initialize success.[0m
[32;22m[I/FAL] The FAL MTD NOR device (filesystem) created successfully[0m
[32m[I/main] Filesystem initialized![0m
msh />
附件
fal_cfg.h文件
#ifndef _FAL_CFG_H_
#define _FAL_CFG_H_
#include
#include
/* ===================== Flash device Configuration ========================= */
extern const struct fal_flash_dev stm32_onchip_flash_16k ;
extern const struct fal_flash_dev stm32_onchip_flash_64k ;
extern const struct fal_flash_dev stm32_onchip_flash_128k;
/* flash device table */
#define FAL_FLASH_DEV_TABLE \
{ \
&stm32_onchip_flash_16k, \
&stm32_onchip_flash_64k, \
&stm32_onchip_flash_128k, \
}
/* ====================== Partition Configuration ========================== */
#ifdef FAL_PART_HAS_TABLE_CFG
/* partition table */
#define FAL_PART_TABLE \
{ \
{FAL_PART_MAGIC_WORD, "bl", "onchip_flash_16k" , 0, 64 * 1024, 0}, \
{FAL_PART_MAGIC_WORD, "param", "onchip_flash_64k" , 0, 64 * 1024, 0}, \
{FAL_PART_MAGIC_WORD, "app", "onchip_flash_128k", 0, 128* 1024, 0}, \
{FAL_PART_MAGIC_WORD, "filesystem", "onchip_flash_128k", 128 * 1024, 768* 1024, 0}, \
}
#endif /* FAL_PART_HAS_TABLE_CFG */
#endif /* _FAL_CFG_H_ */
其他文件
#define STM32_FLASH_START_ADRESS_16K ((uint32_t)0x08100000)
#define STM32_FLASH_START_ADRESS_64K ((uint32_t)0x08110000)
#define STM32_FLASH_START_ADRESS_128K ((uint32_t)0x08120000)
#define FLASH_SIZE_GRANULARITY_16K (64*1024 )
#define FLASH_SIZE_GRANULARITY_64K (64*1024 )
#define FLASH_SIZE_GRANULARITY_128K (896*1024)
const struct fal_flash_dev stm32_onchip_flash_16k = { "onchip_flash_16k", STM32_FLASH_START_ADRESS_16K, FLASH_SIZE_GRANULARITY_16K, (16 * 1024), {NULL, fal_flash_read_16k, fal_flash_write_16k, fal_flash_erase_16k} };
const struct fal_flash_dev stm32_onchip_flash_64k = { "onchip_flash_64k", STM32_FLASH_START_ADRESS_64K, FLASH_SIZE_GRANULARITY_64K, (64 * 1024), {NULL, fal_flash_read_64k, fal_flash_write_64k, fal_flash_erase_64k} };
const struct fal_flash_dev stm32_onchip_flash_128k = { "onchip_flash_128k", STM32_FLASH_START_ADRESS_128K, FLASH_SIZE_GRANULARITY_128K, (128 * 1024), {NULL, fal_flash_read_128k, fal_flash_write_128k, fal_flash_erase_128k} };