Commit be64e6ad authored by Andrzej Puzdrowski's avatar Andrzej Puzdrowski
Browse files

bootutil_public: made boot_read_swap_state_by_id() API



Made boot_read_swap_state_by_id() public API
function.

Signed-off-by: default avatarAndrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
parent 14ef5763
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -88,6 +88,14 @@ extern "C" {

#define BOOT_MAGIC_SZ (sizeof boot_img_magic)

struct boot_swap_state {
    uint8_t magic;      /* One of the BOOT_MAGIC_[...] values. */
    uint8_t swap_type;  /* One of the BOOT_SWAP_TYPE_[...] values. */
    uint8_t copy_done;  /* One of the BOOT_FLAG_[...] values. */
    uint8_t image_ok;   /* One of the BOOT_FLAG_[...] values. */
    uint8_t image_num;  /* Boot status belongs to this image */
};

/**
 * @brief Determines the action, if any, that mcuboot will take on a image pair.
 *
@@ -153,6 +161,17 @@ uint32_t boot_swap_info_off(const struct flash_area *fap);
 */
int boot_read_image_ok(const struct flash_area *fap, uint8_t *image_ok);

/**
 * @brief Read the image swap state
 *
 * @param flash_area_id Id of flash parttition from which trailer will be read.
 * @param state Struture for holding swap state.
 *
 * @return 0 on success, nonzero errno code on fail.
 */
int
boot_read_swap_state_by_id(int flash_area_id, struct boot_swap_state *state);

#define BOOT_MAGIC_ARR_SZ \
    (sizeof boot_img_magic / sizeof boot_img_magic[0])

+0 −8
Original line number Diff line number Diff line
@@ -146,14 +146,6 @@ struct boot_status {

extern const uint32_t boot_img_magic[4];

struct boot_swap_state {
    uint8_t magic;      /* One of the BOOT_MAGIC_[...] values. */
    uint8_t swap_type;  /* One of the BOOT_SWAP_TYPE_[...] values. */
    uint8_t copy_done;  /* One of the BOOT_FLAG_[...] values. */
    uint8_t image_ok;   /* One of the BOOT_FLAG_[...] values. */
    uint8_t image_num;  /* Boot status belongs to this image */
};

#ifdef MCUBOOT_IMAGE_NUMBER
#define BOOT_IMAGE_NUMBER          MCUBOOT_IMAGE_NUMBER
#else
+0 −3
Original line number Diff line number Diff line
@@ -295,9 +295,6 @@ boot_read_swap_state(const struct flash_area *fap,
    return boot_read_image_ok(fap, &state->image_ok);
}

/**
 * Reads the image trailer from the scratch area.
 */
int
boot_read_swap_state_by_id(int flash_area_id, struct boot_swap_state *state)
{