mcuboot: Remove public dependency on bootutil
BOOT_MAGIC_SZ and BOOT_MAX_ALIGN were used in the header without including bootutil/bootutil_public.h. This change remove the need of the inclusion by making the dependency private. Fixes #52095 Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
This commit is contained in:
parent
551f8c40b2
commit
e67e6d5af6
4 changed files with 50 additions and 5 deletions
|
@ -251,3 +251,30 @@ int boot_erase_img_bank(uint8_t area_id)
|
|||
|
||||
return rc;
|
||||
}
|
||||
|
||||
ssize_t boot_get_trailer_status_offset(size_t area_size)
|
||||
{
|
||||
return (ssize_t)area_size - BOOT_MAGIC_SZ - BOOT_MAX_ALIGN * 2;
|
||||
}
|
||||
|
||||
ssize_t boot_get_area_trailer_status_offset(uint8_t area_id)
|
||||
{
|
||||
int rc;
|
||||
const struct flash_area *fa;
|
||||
ssize_t offset;
|
||||
|
||||
rc = flash_area_open(area_id, &fa);
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
offset = boot_get_trailer_status_offset(fa->fa_size);
|
||||
|
||||
flash_area_close(fa);
|
||||
|
||||
if (offset < 0) {
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
|
|
@ -54,9 +54,11 @@ 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 +
|
||||
BOOT_TRAILER_IMG_STATUS_OFFS(ctx->flash_area));
|
||||
status_offset);
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -466,7 +466,7 @@ img_mgmt_erase_image_data(unsigned int off, unsigned int num_bytes)
|
|||
*/
|
||||
|
||||
/* erase the image trailer area if it was not erased */
|
||||
off = BOOT_TRAILER_IMG_STATUS_OFFS(fa);
|
||||
off = boot_get_trailer_status_offset(fa->fa_size);
|
||||
if (off >= erase_size) {
|
||||
rc = flash_get_page_info_by_offs(dev, fa->fa_off + off, &page);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue