Skip to content

Commit be64e6a

Browse files
committed
bootutil_public: made boot_read_swap_state_by_id() API
Made boot_read_swap_state_by_id() public API function. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
1 parent 14ef576 commit be64e6a

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

boot/bootutil/include/bootutil/bootutil_public.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ extern "C" {
8888

8989
#define BOOT_MAGIC_SZ (sizeof boot_img_magic)
9090

91+
struct boot_swap_state {
92+
uint8_t magic; /* One of the BOOT_MAGIC_[...] values. */
93+
uint8_t swap_type; /* One of the BOOT_SWAP_TYPE_[...] values. */
94+
uint8_t copy_done; /* One of the BOOT_FLAG_[...] values. */
95+
uint8_t image_ok; /* One of the BOOT_FLAG_[...] values. */
96+
uint8_t image_num; /* Boot status belongs to this image */
97+
};
98+
9199
/**
92100
* @brief Determines the action, if any, that mcuboot will take on a image pair.
93101
*
@@ -153,6 +161,17 @@ uint32_t boot_swap_info_off(const struct flash_area *fap);
153161
*/
154162
int boot_read_image_ok(const struct flash_area *fap, uint8_t *image_ok);
155163

164+
/**
165+
* @brief Read the image swap state
166+
*
167+
* @param flash_area_id Id of flash parttition from which trailer will be read.
168+
* @param state Struture for holding swap state.
169+
*
170+
* @return 0 on success, nonzero errno code on fail.
171+
*/
172+
int
173+
boot_read_swap_state_by_id(int flash_area_id, struct boot_swap_state *state);
174+
156175
#define BOOT_MAGIC_ARR_SZ \
157176
(sizeof boot_img_magic / sizeof boot_img_magic[0])
158177

boot/bootutil/src/bootutil_priv.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,6 @@ struct boot_status {
146146

147147
extern const uint32_t boot_img_magic[4];
148148

149-
struct boot_swap_state {
150-
uint8_t magic; /* One of the BOOT_MAGIC_[...] values. */
151-
uint8_t swap_type; /* One of the BOOT_SWAP_TYPE_[...] values. */
152-
uint8_t copy_done; /* One of the BOOT_FLAG_[...] values. */
153-
uint8_t image_ok; /* One of the BOOT_FLAG_[...] values. */
154-
uint8_t image_num; /* Boot status belongs to this image */
155-
};
156-
157149
#ifdef MCUBOOT_IMAGE_NUMBER
158150
#define BOOT_IMAGE_NUMBER MCUBOOT_IMAGE_NUMBER
159151
#else

boot/bootutil/src/bootutil_public.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,6 @@ boot_read_swap_state(const struct flash_area *fap,
295295
return boot_read_image_ok(fap, &state->image_ok);
296296
}
297297

298-
/**
299-
* Reads the image trailer from the scratch area.
300-
*/
301298
int
302299
boot_read_swap_state_by_id(int flash_area_id, struct boot_swap_state *state)
303300
{

0 commit comments

Comments
 (0)