1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

riotboot/flashwrite: Add force flush to storage function

This commit is contained in:
Koen Zandberg 2020-09-28 23:06:12 +02:00
parent a00314bfc4
commit f05c5f7708
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B
2 changed files with 17 additions and 0 deletions

View File

@ -132,6 +132,14 @@ static inline int riotboot_flashwrite_init(riotboot_flashwrite_t *state,
*/
int riotboot_flashwrite_putbytes(riotboot_flashwrite_t *state,
const uint8_t *bytes, size_t len, bool more);
/**
* @brief Force flush the buffer onto the flash
*
* @param[in,out] state ptr to previously used update state
*
* @returns 0 on success, <0 otherwise
*/
int riotboot_flashwrite_flush(riotboot_flashwrite_t *state);
/**
* @brief Finish a firmware update (raw version)

View File

@ -57,6 +57,15 @@ int riotboot_flashwrite_init_raw(riotboot_flashwrite_t *state, int target_slot,
return 0;
}
int riotboot_flashwrite_flush(riotboot_flashwrite_t *state)
{
if (flashpage_write_and_verify(state->flashpage, state->flashpage_buf) != FLASHPAGE_OK) {
LOG_WARNING(LOG_PREFIX "error writing flashpage %u!\n", state->flashpage);
return -1;
}
return 0;
}
int riotboot_flashwrite_putbytes(riotboot_flashwrite_t *state,
const uint8_t *bytes, size_t len, bool more)
{