From c119c1aa394de3152b9fef2cbd7aa78df6522b29 Mon Sep 17 00:00:00 2001 From: Florian Loitsch Date: Fri, 31 May 2024 10:09:02 +0200 Subject: [PATCH] Increase host flash size to 64MB. (#2375) --- src/flash_registry_posix.cc | 2 +- src/flash_registry_win.cc | 2 +- tests/storage-test.toit | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/flash_registry_posix.cc b/src/flash_registry_posix.cc index 23b08ec03..b1287826b 100644 --- a/src/flash_registry_posix.cc +++ b/src/flash_registry_posix.cc @@ -32,7 +32,7 @@ namespace toit { -static const int ALLOCATION_SIZE = 2 * MB; +static const int ALLOCATION_SIZE = 64 * MB; static void* allocations_mmap = null; static size_t allocations_mmap_size = 0; diff --git a/src/flash_registry_win.cc b/src/flash_registry_win.cc index 56118e068..56a381167 100644 --- a/src/flash_registry_win.cc +++ b/src/flash_registry_win.cc @@ -22,7 +22,7 @@ namespace toit { -static const word ALLOCATION_SIZE = 2 * MB; +static const word ALLOCATION_SIZE = 64 * MB; // An aligned (FLASH_BASED_SIZE) view into the allocations_malloced. uint8* FlashRegistry::allocations_memory_ = null; diff --git a/tests/storage-test.toit b/tests/storage-test.toit index 57c375ba0..75a97f006 100644 --- a/tests/storage-test.toit +++ b/tests/storage-test.toit @@ -25,6 +25,7 @@ main: test-region-flash-out-of-space test-region-flash-stream test-region-flash-no-writable + test-region-flash-large test-region-flash-delete test-region-flash-list @@ -338,6 +339,22 @@ test-region-flash-no-writable: region.read --from=0 --to=1 region.close +test-region-flash-large: + capacity := 60_000_000 // Roughly 60 MB. + region := storage.Region.open --flash "region-large" --capacity=capacity + region.erase + content := ByteArray capacity + 1000.repeat: + content[random capacity] = random 0x100 + content[0] = 42 + content[capacity - 1] = 0x42 + region.write --at=0 content + region.close + region = storage.Region.open --flash "region-large" --capacity=capacity + stored := region.read --from=0 --to=capacity + expect-equals content stored + region.close + test-region-flash-delete: region := storage.Region.open --flash "region-3" --capacity=8192 expect-throw "ALREADY_IN_USE": storage.Region.delete --flash "region-3"