Skip to content

Commit

Permalink
Increase host flash size to 64MB. (#2375)
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch authored May 31, 2024
1 parent 5c6b119 commit c119c1a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/flash_registry_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/flash_registry_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions tests/storage-test.toit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit c119c1a

Please sign in to comment.