1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

riotboot: only depend on periph_flashpage

This commit is contained in:
Koen Zandberg 2020-11-09 16:47:56 +01:00
parent 3aa5203bc5
commit 722223902a
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B
3 changed files with 15 additions and 15 deletions

View File

@ -910,7 +910,6 @@ endif
ifneq (,$(filter riotboot_flashwrite, $(USEMODULE))) ifneq (,$(filter riotboot_flashwrite, $(USEMODULE)))
USEMODULE += riotboot_slot USEMODULE += riotboot_slot
FEATURES_REQUIRED += periph_flashpage FEATURES_REQUIRED += periph_flashpage
FEATURES_OPTIONAL += periph_flashpage_raw
endif endif
ifneq (,$(filter riotboot_slot, $(USEMODULE))) ifneq (,$(filter riotboot_slot, $(USEMODULE)))

View File

@ -41,9 +41,9 @@
* 2. write image starting at second block * 2. write image starting at second block
* 3. write first 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 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 * the other buffers the first chunk (offset zero, page zero). This first
* chunk is written when finalizing the flash operation. The minimal size for * 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 * 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 * @brief Enable/disable raw writes to flash
*/ */
#ifndef CONFIG_RIOTBOOT_FLASHWRITE_RAW #ifndef CONFIG_RIOTBOOT_FLASHWRITE_RAW
#define CONFIG_RIOTBOOT_FLASHWRITE_RAW IS_ACTIVE(MODULE_PERIPH_FLASHPAGE_RAW) #define CONFIG_RIOTBOOT_FLASHWRITE_RAW 1
#endif #endif
/** /**
@ -78,10 +78,10 @@ extern "C" {
*/ */
#if CONFIG_RIOTBOOT_FLASHWRITE_RAW #if CONFIG_RIOTBOOT_FLASHWRITE_RAW
#if (FLASHPAGE_RAW_BLOCKSIZE < 4) #if (FLASHPAGE_WRITE_BLOCK_SIZE < 4)
#define RIOTBOOT_FLASHPAGE_BUFFER_SIZE 4 #define RIOTBOOT_FLASHPAGE_BUFFER_SIZE 4
#else #else
#define RIOTBOOT_FLASHPAGE_BUFFER_SIZE FLASHPAGE_RAW_BLOCKSIZE #define RIOTBOOT_FLASHPAGE_BUFFER_SIZE FLASHPAGE_WRITE_BLOCK_SIZE
#endif #endif
#else /* CONFIG_RIOTBOOT_FLASHWRITE_RAW */ #else /* CONFIG_RIOTBOOT_FLASHWRITE_RAW */
@ -94,13 +94,14 @@ extern "C" {
* @brief Extra attributes required for the firmware intermediate buffer * @brief Extra attributes required for the firmware intermediate buffer
*/ */
#define RIOTBOOT_FLASHPAGE_BUFFER_ATTRS \ #define RIOTBOOT_FLASHPAGE_BUFFER_ATTRS \
__attribute__((aligned(FLASHPAGE_RAW_ALIGNMENT))) __attribute__((aligned(FLASHPAGE_WRITE_BLOCK_ALIGNMENT)))
/** /**
* @brief firmware update state structure * @brief firmware update state structure
* *
* @note @ref FLASHPAGE_SIZE can be very large on some platforms, don't place * @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 { typedef struct {
int target_slot; /**< update targets this slot */ int target_slot; /**< update targets this slot */

View File

@ -59,7 +59,7 @@ int riotboot_flashwrite_init_raw(riotboot_flashwrite_t *state, int target_slot,
if (CONFIG_RIOTBOOT_FLASHWRITE_RAW && offset) { if (CONFIG_RIOTBOOT_FLASHWRITE_RAW && offset) {
/* Erase the first page only if the offset (!=0) specifies that there is /* Erase the first page only if the offset (!=0) specifies that there is
* a checksum or other mechanism at the start of the page. */ * a checksum or other mechanism at the start of the page. */
flashpage_write(state->flashpage, NULL); flashpage_erase(state->flashpage);
} }
return 0; return 0;
@ -78,9 +78,9 @@ int riotboot_flashwrite_flush(riotboot_flashwrite_t *state)
/* Get the offset of the remaining chunk */ /* Get the offset of the remaining chunk */
size_t flashpage_pos = state->offset - flashwrite_buffer_pos; size_t flashpage_pos = state->offset - flashwrite_buffer_pos;
/* Write remaining chunk */ /* Write remaining chunk */
flashpage_write_raw(slot_start + flashpage_pos, flashpage_write(slot_start + flashpage_pos,
state->flashpage_buf, state->flashpage_buf,
RIOTBOOT_FLASHPAGE_BUFFER_SIZE); RIOTBOOT_FLASHPAGE_BUFFER_SIZE);
} }
else { else {
if (flashpage_write_and_verify(state->flashpage, state->flashpage_buf) != FLASHPAGE_OK) { 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) { if (CONFIG_RIOTBOOT_FLASHWRITE_RAW && flashpage_pos == 0) {
/* Erase the next page */ /* Erase the next page */
state->flashpage++; state->flashpage++;
flashpage_write(state->flashpage, NULL); flashpage_erase(state->flashpage);
} }
if (CONFIG_RIOTBOOT_FLASHWRITE_RAW && if (CONFIG_RIOTBOOT_FLASHWRITE_RAW &&
flashwrite_buffer_pos == 0) { flashwrite_buffer_pos == 0) {
@ -131,7 +131,7 @@ int riotboot_flashwrite_putbytes(riotboot_flashwrite_t *state,
state->flashpage_buf, RIOTBOOT_FLASHPAGE_BUFFER_SIZE); state->flashpage_buf, RIOTBOOT_FLASHPAGE_BUFFER_SIZE);
} }
else { else {
flashpage_write_raw((uint8_t*)addr + flashpage_pos, flashpage_write((uint8_t*)addr + flashpage_pos,
state->flashpage_buf, state->flashpage_buf,
RIOTBOOT_FLASHPAGE_BUFFER_SIZE); RIOTBOOT_FLASHPAGE_BUFFER_SIZE);
} }
@ -161,7 +161,7 @@ int riotboot_flashwrite_finish_raw(riotboot_flashwrite_t *state,
#if CONFIG_RIOTBOOT_FLASHWRITE_RAW #if CONFIG_RIOTBOOT_FLASHWRITE_RAW
memcpy(state->firstblock_buf, bytes, len); 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 #else
uint8_t *firstpage; uint8_t *firstpage;