Skip to content

Commit

Permalink
susbys/dfu/img_util: support ERASE PROGRESSIVELY for non-flash mem
Browse files Browse the repository at this point in the history
Added support for devices don't require explicit pager erase.
For these device flattening of mcuboot image status is relevant.

Signed-off-by: Andrzej Puzdrowski <[email protected]>
  • Loading branch information
nvlsianpu committed Sep 28, 2024
1 parent 0d118ec commit e0f5354
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 {

Check notice on line 74 in subsys/dfu/img_util/flash_img.c

View workflow job for this annotation

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

You may want to run clang-format on this change

subsys/dfu/img_util/flash_img.c:74 - const struct flash_parameters *fparams = flash_get_parameters(flash_area_get_device(ctx->flash_area)); + 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); + 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); + ctx->flash_area->fa_off - status_offset);
rc = 0;
}
}

if (rc) {
return rc;
}
Expand Down

0 comments on commit e0f5354

Please sign in to comment.