You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@mynewt.apache.org by "andrzej-kaczmarek (via GitHub)" <gi...@apache.org> on 2025/11/24 22:29:35 UTC
[PR] fs/littlefs: Bump to v2.11.2 and update glue layer [mynewt-core]
andrzej-kaczmarek opened a new pull request, #3545:
URL: https://github.com/apache/mynewt-core/pull/3545
This bumps littlefs repository to the latest v2.11.2 and improves and cleans up glue layer.
New featues:
- add automatic detection of block size and block count from flash area
- add option to disable thread-safety
- add option to disable inlined files
- add option to enabled littlefs traces
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fs/littlefs: Bump to v2.11.2 and update glue layer [mynewt-core]
Posted by "andrzej-kaczmarek (via GitHub)" <gi...@apache.org>.
andrzej-kaczmarek merged PR #3545:
URL: https://github.com/apache/mynewt-core/pull/3545
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fs/littlefs: Bump to v2.11.2 and update glue layer [mynewt-core]
Posted by "kasjer (via GitHub)" <gi...@apache.org>.
kasjer commented on code in PR #3545:
URL: https://github.com/apache/mynewt-core/pull/3545#discussion_r2561747187
##########
fs/littlefs/src/littlefs_glue.c:
##########
@@ -714,125 +703,118 @@ littlefs_dirent_is_dir(const struct fs_dirent *fs_dirent)
struct lfs_info *info;
if (!fs_dirent) {
- return FS_EINVAL;
+ return 0;
}
info = &((struct littlefs_dirent *)fs_dirent)->info;
return info->type == LFS_TYPE_DIR;
}
-/*
- * Initializes only Mynewt glue, to fully initialize call
- * LitteFS must call littlefs_format or littlefs_mount.
- */
-static int
-littlefs_alloc(void)
+int
+littlefs_format(void)
{
- const struct flash_area *fa;
int rc;
- /*
- * Already initialized.
- */
- if (g_lfs && g_lfs_alloc_done) {
- return FS_EOK;
- }
-
- rc = os_mutex_init(&littlefs_mutex);
- if (rc != 0) {
- return FS_EOS;
- }
-
- g_lfs = malloc(sizeof(lfs_t));
- if (!g_lfs) {
- return FS_ENOMEM;
- }
-
- /*
- * This doesn't seem to be needed because lfs_mount initializes
- * all fields, but just to stay on the safe side...
- */
- memset(g_lfs, 0, sizeof(lfs_t));
-
- rc = flash_area_open(MYNEWT_VAL(LITTLEFS_FLASH_AREA), &fa);
+ rc = lfs_format(&g_littlefs, &g_littlefs_config);
if (rc) {
- free(g_lfs);
- g_lfs = NULL;
- return FS_EHW;
+ return littlefs_to_vfs_error(rc);
}
- /*
- * TODO: could check that fa_size matches the configured block size * count
- */
- g_lfs_cfg.context = (struct flash_area *)fa;
- g_lfs_alloc_done = true;
-
return FS_EOK;
}
int
-littlefs_reformat(void)
+littlefs_mount(void)
{
int rc;
- if (!g_lfs_alloc_done) {
- rc = littlefs_alloc();
- if (rc != FS_EOK) {
- return -1;
+ rc = lfs_mount(&g_littlefs, &g_littlefs_config);
+ switch (rc) {
+ case LFS_ERR_OK:
+ break;
+ case LFS_ERR_INVAL:
+ case LFS_ERR_CORRUPT:
+#if MYNEWT_VAL(LITTLEFS_AUTO_FORMAT)
+ rc = lfs_format(&g_littlefs, &g_littlefs_config);
+ if (!rc) {
+ rc = lfs_mount(&g_littlefs, &g_littlefs_config);
}
+#endif
+ break;
}
- return lfs_format(g_lfs, &g_lfs_cfg);
+ if (rc) {
+ return littlefs_to_vfs_error(rc);
+ }
+
+ return FS_EOK;
}
int
littlefs_init(void)
{
+ struct lfs_config *lfs_cfg = &g_littlefs_config;
+ const struct flash_area *fa;
+ static struct flash_sector_range fsr;
+ int fsr_cnt;
+ uint32_t block_count;
+ uint32_t block_size;
int rc;
- if (!g_lfs_alloc_done) {
- rc = littlefs_alloc();
- if (rc != FS_EOK) {
- return rc;
- }
+#ifdef LFS_THREADSAFE
+ rc = os_mutex_init(&g_littlefs_mutex);
+ if (rc) {
+ return FS_EOS;
}
-
- rc = lfs_mount(g_lfs, &g_lfs_cfg);
- switch (rc) {
- case LFS_ERR_OK:
- break;
- case LFS_ERR_INVAL:
- case LFS_ERR_CORRUPT:
- /* No valid LittleFS instance detected; act based on configued
- * detection failure policy.
- */
-#if MYNEWT_VAL(LITTLEFS_DETECT_FAIL_FORMAT)
- rc = lfs_format(g_lfs, &g_lfs_cfg);
- if (!rc) {
- rc = lfs_mount(g_lfs, &g_lfs_cfg);
- }
#endif
- break;
+
+ rc = flash_area_open(MYNEWT_VAL(LITTLEFS_FLASH_AREA), &fa);
+ if (rc) {
+ return FS_EHW;
}
- if (!rc) {
- fs_register(&littlefs_ops);
+ lfs_cfg->context = (struct flash_area *)fa;
+
+ fsr_cnt = 1;
+ rc = flash_area_to_sector_ranges(FLASH_AREA_STORAGE, &fsr_cnt, &fsr);
Review Comment:
What is `FLASH_AREA_STORAGE`? Is it released to `MYNWET_VAL(LITTLEFS_FLASH_AREA)` from line 771
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org