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]>
  • Loading branch information
nvlsianpu authored and bjarki-andreasen committed Sep 28, 2024
1 parent e2f1318 commit b1b26f5
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 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,26 @@ 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));

Check warning on line 61 in subsys/dfu/img_util/flash_img.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

subsys/dfu/img_util/flash_img.c:61 line length of 110 exceeds 100 columns

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);

Check warning on line 73 in subsys/dfu/img_util/flash_img.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

subsys/dfu/img_util/flash_img.c:73 line length of 113 exceeds 100 columns
} else {
rc = 0;
}
}

if (rc) {
return rc;
}
Expand Down

0 comments on commit b1b26f5

Please sign in to comment.