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
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <zephyr/types.h>
|
||||
|
||||
|
@ -79,9 +80,7 @@ extern "C" {
|
|||
|
||||
#define BOOT_IMG_VER_STRLEN_MAX 25 /* 255.255.65535.4294967295\0 */
|
||||
|
||||
#define BOOT_TRAILER_IMG_STATUS_OFFS(bank_area) ((bank_area)->fa_size -\
|
||||
BOOT_MAGIC_SZ -\
|
||||
BOOT_MAX_ALIGN * 2)
|
||||
|
||||
/**
|
||||
* @brief MCUboot image header representation for image version
|
||||
*
|
||||
|
@ -263,6 +262,23 @@ int boot_request_upgrade_multi(int image_index, int permanent);
|
|||
*/
|
||||
int boot_erase_img_bank(uint8_t area_id);
|
||||
|
||||
/**
|
||||
* @brief Get the offset of the status in the image bank
|
||||
*
|
||||
* @param area_id flash_area ID of image bank to get the status offset
|
||||
* @return a positive offset on success, negative errno code on fail
|
||||
*/
|
||||
ssize_t boot_get_area_trailer_status_offset(uint8_t area_id);
|
||||
|
||||
/**
|
||||
* @brief Get the offset of the status from an image bank size
|
||||
*
|
||||
* @param area_size size of image bank
|
||||
* @return offset of the status. When negative the status will not fit
|
||||
* the given size
|
||||
*/
|
||||
ssize_t boot_get_trailer_status_offset(size_t area_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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…
Reference in a new issue