From c6c3b341b8d373af0a5089d1681124177d2f0fb0 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 13 Dec 2021 17:46:56 +0100 Subject: [PATCH] fixup! sys/riotboot: add helper functions for riotboot VFS --- sys/riotboot/vfs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/riotboot/vfs.c b/sys/riotboot/vfs.c index 474957feb954..67511c728d55 100644 --- a/sys/riotboot/vfs.c +++ b/sys/riotboot/vfs.c @@ -25,12 +25,13 @@ #include "periph/flashpage.h" #include "riotboot/vfs.h" -static const void *_first_free_page(const void *start) +/* try to guess the end of the firmware */ +static const void *_first_free_chunk(const void *start) { const uword_t *cur = start; const uword_t *end = flashpage_addr(FLASHPAGE_NUMOF); uword_t empty; - unsigned i = flashpage_page(start); + unsigned const chunk_size = 256; memset(&empty, FLASHPAGE_ERASE_STATE, sizeof(empty)); /* try to find the first unused page */ @@ -39,7 +40,7 @@ static const void *_first_free_page(const void *start) cur[2] == empty && cur[3] == empty) { break; } - cur += flashpage_size(i++); + cur += chunk_size; } return cur; @@ -51,7 +52,7 @@ int riotboot_vfs_dump_rom(const char* file) if (IS_ACTIVE(RIOTBOOT)) { start = (void *)(uintptr_t)SLOT0_OFFSET; - end = _first_free_page(start); + end = _first_free_chunk(start); } else { start = flashpage_addr(flashpage_first_used()); end = flashpage_addr(flashpage_first_free());