diff --git a/sys/Makefile.dep b/sys/Makefile.dep index 99f2b0a329..a4551af11c 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -910,7 +910,6 @@ endif ifneq (,$(filter riotboot_flashwrite, $(USEMODULE))) USEMODULE += riotboot_slot FEATURES_REQUIRED += periph_flashpage - FEATURES_OPTIONAL += periph_flashpage_raw endif ifneq (,$(filter riotboot_slot, $(USEMODULE))) diff --git a/sys/include/riotboot/flashwrite.h b/sys/include/riotboot/flashwrite.h index 4bc1d2c8b5..b211994c95 100644 --- a/sys/include/riotboot/flashwrite.h +++ b/sys/include/riotboot/flashwrite.h @@ -41,9 +41,9 @@ * 2. write image starting at second block * 3. write first block * - * When using periph_flashpage_raw with this module, the need to buffer a full + * When using raw mode is used with this module, the need to buffer a full * flashpage page is removed, instead it must buffer two times the - * FLASHPAGE_RAW_BLOCKSIZE. One is used to buffer the current write block, + * FLASHPAGE_WRITE_BLOCK_SIZE. One is used to buffer the current write block, * the other buffers the first chunk (offset zero, page zero). This first * chunk is written when finalizing the flash operation. The minimal size for * RIOTBOOT_FLASHPAGE_BUFFER_SIZE is 4, at least the riotboot magic number must @@ -70,7 +70,7 @@ extern "C" { * @brief Enable/disable raw writes to flash */ #ifndef CONFIG_RIOTBOOT_FLASHWRITE_RAW -#define CONFIG_RIOTBOOT_FLASHWRITE_RAW IS_ACTIVE(MODULE_PERIPH_FLASHPAGE_RAW) +#define CONFIG_RIOTBOOT_FLASHWRITE_RAW 1 #endif /** @@ -78,10 +78,10 @@ extern "C" { */ #if CONFIG_RIOTBOOT_FLASHWRITE_RAW -#if (FLASHPAGE_RAW_BLOCKSIZE < 4) +#if (FLASHPAGE_WRITE_BLOCK_SIZE < 4) #define RIOTBOOT_FLASHPAGE_BUFFER_SIZE 4 #else -#define RIOTBOOT_FLASHPAGE_BUFFER_SIZE FLASHPAGE_RAW_BLOCKSIZE +#define RIOTBOOT_FLASHPAGE_BUFFER_SIZE FLASHPAGE_WRITE_BLOCK_SIZE #endif #else /* CONFIG_RIOTBOOT_FLASHWRITE_RAW */ @@ -94,13 +94,14 @@ extern "C" { * @brief Extra attributes required for the firmware intermediate buffer */ #define RIOTBOOT_FLASHPAGE_BUFFER_ATTRS \ - __attribute__((aligned(FLASHPAGE_RAW_ALIGNMENT))) + __attribute__((aligned(FLASHPAGE_WRITE_BLOCK_ALIGNMENT))) /** * @brief firmware update state structure * * @note @ref FLASHPAGE_SIZE can be very large on some platforms, don't place - * this struct on the stack or increase the thread stack size accordingly. + * this struct on the stack or increase the thread stack size + * accordingly. */ typedef struct { int target_slot; /**< update targets this slot */ diff --git a/sys/riotboot/flashwrite.c b/sys/riotboot/flashwrite.c index 246c331c73..743676e32e 100644 --- a/sys/riotboot/flashwrite.c +++ b/sys/riotboot/flashwrite.c @@ -59,7 +59,7 @@ int riotboot_flashwrite_init_raw(riotboot_flashwrite_t *state, int target_slot, if (CONFIG_RIOTBOOT_FLASHWRITE_RAW && offset) { /* Erase the first page only if the offset (!=0) specifies that there is * a checksum or other mechanism at the start of the page. */ - flashpage_write(state->flashpage, NULL); + flashpage_erase(state->flashpage); } return 0; @@ -78,9 +78,9 @@ int riotboot_flashwrite_flush(riotboot_flashwrite_t *state) /* Get the offset of the remaining chunk */ size_t flashpage_pos = state->offset - flashwrite_buffer_pos; /* Write remaining chunk */ - flashpage_write_raw(slot_start + flashpage_pos, - state->flashpage_buf, - RIOTBOOT_FLASHPAGE_BUFFER_SIZE); + flashpage_write(slot_start + flashpage_pos, + state->flashpage_buf, + RIOTBOOT_FLASHPAGE_BUFFER_SIZE); } else { if (flashpage_write_and_verify(state->flashpage, state->flashpage_buf) != FLASHPAGE_OK) { @@ -106,7 +106,7 @@ int riotboot_flashwrite_putbytes(riotboot_flashwrite_t *state, if (CONFIG_RIOTBOOT_FLASHWRITE_RAW && flashpage_pos == 0) { /* Erase the next page */ state->flashpage++; - flashpage_write(state->flashpage, NULL); + flashpage_erase(state->flashpage); } if (CONFIG_RIOTBOOT_FLASHWRITE_RAW && flashwrite_buffer_pos == 0) { @@ -131,7 +131,7 @@ int riotboot_flashwrite_putbytes(riotboot_flashwrite_t *state, state->flashpage_buf, RIOTBOOT_FLASHPAGE_BUFFER_SIZE); } else { - flashpage_write_raw((uint8_t*)addr + flashpage_pos, + flashpage_write((uint8_t*)addr + flashpage_pos, state->flashpage_buf, RIOTBOOT_FLASHPAGE_BUFFER_SIZE); } @@ -161,7 +161,7 @@ int riotboot_flashwrite_finish_raw(riotboot_flashwrite_t *state, #if CONFIG_RIOTBOOT_FLASHWRITE_RAW memcpy(state->firstblock_buf, bytes, len); - flashpage_write_raw(slot_start, state->firstblock_buf, RIOTBOOT_FLASHPAGE_BUFFER_SIZE); + flashpage_write(slot_start, state->firstblock_buf, RIOTBOOT_FLASHPAGE_BUFFER_SIZE); #else uint8_t *firstpage;