fix max alloc

This commit is contained in:
Xuan Son Nguyen 2026-01-28 18:32:33 +01:00
parent 7c49fc93e8
commit 1d2fff18d5
2 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,3 @@
#pragma once
#include "ResourcesFS.h"
#include <Arduino.h>
@ -35,7 +33,6 @@ bool ResourcesFS::begin(bool remount) {
spi_flash_mmap_handle_t map_handle; // unused
size_t len = impl->partition->size;
if (len > MAX_ALLOC_SIZE) {
// FIXME: cannot mmap too large region at once, why?
len = MAX_ALLOC_SIZE;
}

View File

@ -11,9 +11,12 @@ class ResourcesFS {
ResourcesFS() = default;
~ResourcesFS() = default;
// FIXME: true MAX_ALLOC_SIZE = ~3.5MB but not enough pages to do mmap
// See: spi_flash_mmap_get_free_pages() --> ~31 free pages on real device
static constexpr size_t MAX_FILES = 32;
static constexpr size_t MAX_FILE_NAME_LENGTH = 32;
static constexpr size_t MAX_ALLOC_SIZE = 3 * 1024 * 1024; // 3 MB
static constexpr size_t MAX_ALLOC_SIZE = 28 * 64 * 1024; // 28 pages == ~1.8 MB
static constexpr size_t ALIGNMENT = 4; // bytes
static constexpr uint32_t MAGIC = 0x46535631; // "FSV1"