Skip to content

Commit

Permalink
[nrf fromlist] susbys/dfu/img_util: support ERASE PROGRESSIVELY for n…
Browse files Browse the repository at this point in the history
…on-flash mem

Added support for devices don't require explicit pager erase.
For these device flattening of mcuboot image status is relevant.

Upstream PR: zephyrproject-rtos/zephyr#79152

Signed-off-by: Andrzej Puzdrowski <[email protected]>
(cherry picked from commit 30f066a)
  • Loading branch information
nvlsianpu authored and rlubos committed Oct 22, 2024
1 parent 6045398 commit 02fa1cb
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions subsys/dfu/img_util/flash_img.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,27 @@ int flash_img_buffered_write(struct flash_img_context *ctx, const uint8_t *data,
#ifdef CONFIG_IMG_ERASE_PROGRESSIVELY
ssize_t status_offset = boot_get_trailer_status_offset(
ctx->flash_area->fa_size);
rc = stream_flash_erase_page(&ctx->stream,
ctx->flash_area->fa_off +
status_offset);

#ifdef CONFIG_STREAM_FLASH_ERASE
const struct flash_parameters *fparams =
flash_get_parameters(flash_area_get_device(ctx->flash_area));

if ((flash_params_get_erase_cap(fparams) & FLASH_ERASE_C_EXPLICIT)) {
/* use pistine-page-erase procedure for a device which needs it */
rc = stream_flash_erase_page(&ctx->stream,
ctx->flash_area->fa_off +
status_offset);
} else
#endif
{
if (status_offset > stream_flash_bytes_written(&ctx->stream)) {
rc = flash_area_flatten(ctx->flash_area, status_offset,
ctx->flash_area->fa_off - status_offset);
} else {
rc = 0;
}
}

if (rc) {
return rc;
}
Expand Down

0 comments on commit 02fa1cb

Please sign in to comment.