Is your feature request related to a problem? Please describe.
The current InternalFileSystem implementation hard-codes the filesystem size to 7 pages (28KB). For projects requiring more persistent storage, this fixed size may be insufficient. Currently, the only way to increase the filesystem size is to modify the library source directly, which breaks on library updates and complicates project distribution.
Describe the solution you'd like
Allow users to configure the LittleFS size by:
- Creating a LFS_Config.h file in their sketch folder with:
#define LFS_FLASH_PAGES 32 // 32 pages = 128KB
- Or passing a compiler flag: -DLFS_FLASH_PAGES=32
The implementation uses __has_include() to conditionally include the user's config file, falling back to the default 7 pages if not present. The flash start address is computed dynamically so the filesystem always ends right before the bootloader, regardless of size.
Describe alternatives you've considered
- Separate Filesystem: Wear Leveling is split and less effective
Additional context
Patch summary:
// User creates LFS_Config.h in sketch folder:
#define LFS_FLASH_PAGES 32 // 32 pages = 128KB
// Library automatically includes it if present:
#if __has_include("LFS_Config.h")
#include "LFS_Config.h"
#endif
// Computes address so FS ends before bootloader:
#define LFS_FLASH_ADDR (0xF4000 - LFS_FLASH_TOTAL_SIZE)
Patch:
--- nrf52_framework/1.1.12/libraries/InternalFileSytem/src/InternalFileSystem.cpp 2026-01-01 23:35:31.238828649 +0000
+++ InternalFileSystem_1.1.12/src/InternalFileSystem.cpp 2026-01-01 09:34:08.036726471 +0000
@@ -25,13 +25,31 @@
#include "InternalFileSystem.h"
#include "flash/flash_nrf5x.h"
+//--------------------------------------------------------------------+
+// CONFIGURABLE FILESYSTEM SIZE
+// Options to set LFS_FLASH_PAGES:
+// 1. Create "LFS_Config.h" in your sketch folder with:
+// #define LFS_FLASH_PAGES 64
+// 2. Or use compiler flag: -DLFS_FLASH_PAGES=64
+// Default: 7 pages (28KB), Max for nRF52840: 71 pages (284KB)
+//--------------------------------------------------------------------+
+#if __has_include("LFS_Config.h")
+#include "LFS_Config.h"
+#endif
+
+#ifndef LFS_FLASH_PAGES
+#define LFS_FLASH_PAGES 7 // Default: 7 pages = 28KB
+#endif
+
+#define LFS_FLASH_TOTAL_SIZE (LFS_FLASH_PAGES * FLASH_NRF52_PAGE_SIZE)
+
+// Compute start address so filesystem ends right before bootloader
#ifdef NRF52840_XXAA
-#define LFS_FLASH_ADDR 0xED000
+#define LFS_FLASH_ADDR (0xF4000 - LFS_FLASH_TOTAL_SIZE) // Bootloader at 0xF4000
#else
-#define LFS_FLASH_ADDR 0x6D000
+#define LFS_FLASH_ADDR (0x74000 - LFS_FLASH_TOTAL_SIZE) // Bootloader at 0x74000
#endif
-#define LFS_FLASH_TOTAL_SIZE (7*FLASH_NRF52_PAGE_SIZE)
#define LFS_BLOCK_SIZE 128
//--------------------------------------------------------------------+
Is your feature request related to a problem? Please describe.
The current InternalFileSystem implementation hard-codes the filesystem size to 7 pages (28KB). For projects requiring more persistent storage, this fixed size may be insufficient. Currently, the only way to increase the filesystem size is to modify the library source directly, which breaks on library updates and complicates project distribution.
Describe the solution you'd like
Allow users to configure the LittleFS size by:
#define LFS_FLASH_PAGES 32 // 32 pages = 128KB
The implementation uses __has_include() to conditionally include the user's config file, falling back to the default 7 pages if not present. The flash start address is computed dynamically so the filesystem always ends right before the bootloader, regardless of size.
Describe alternatives you've considered
Additional context
Patch summary:
// User creates LFS_Config.h in sketch folder:
#define LFS_FLASH_PAGES 32 // 32 pages = 128KB
// Library automatically includes it if present:
#if __has_include("LFS_Config.h")
#include "LFS_Config.h"
#endif
// Computes address so FS ends before bootloader:
#define LFS_FLASH_ADDR (0xF4000 - LFS_FLASH_TOTAL_SIZE)
Patch: