Zephyr Project API  3.3.0
A Scalable Open Source RTOS
mcuboot.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Nordic Semiconductor ASA
3 * Copyright (c) 2016 Linaro Limited
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
16#ifndef ZEPHYR_INCLUDE_DFU_MCUBOOT_H_
17#define ZEPHYR_INCLUDE_DFU_MCUBOOT_H_
18
19#include <stdbool.h>
20#include <stddef.h>
21#include <sys/types.h>
22
23#include <zephyr/types.h>
24
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#ifdef BOOT_SWAP_TYPE_NONE
37#if BOOT_SWAP_TYPE_NONE != 1 /*ensure the same definition in MCUboot */
38#error "definition incompatible"
39#endif
40#else
42#define BOOT_SWAP_TYPE_NONE 1
43#endif
44
45#ifdef BOOT_SWAP_TYPE_TEST
46#if BOOT_SWAP_TYPE_TEST != 2 /*ensure the same definition in MCUboot */
47#error "definition incompatible"
48#endif
49#else
51#define BOOT_SWAP_TYPE_TEST 2
52#endif
53
54#ifdef BOOT_SWAP_TYPE_PERM
55#if BOOT_SWAP_TYPE_PERM != 3 /*ensure the same definition in MCUboot */
56#error "definition incompatible"
57#endif
58#else
60#define BOOT_SWAP_TYPE_PERM 3
61#endif
62
63#ifdef BOOT_SWAP_TYPE_REVERT
64#if BOOT_SWAP_TYPE_REVERT != 4 /*ensure the same definition in MCUboot */
65#error "definition incompatible"
66#endif
67#else
69#define BOOT_SWAP_TYPE_REVERT 4
70#endif
71
72#ifdef BOOT_SWAP_TYPE_FAIL
73#if BOOT_SWAP_TYPE_FAIL != 5 /*ensure the same definition in MCUboot */
74#error "definition incompatible"
75#endif
76#else
78#define BOOT_SWAP_TYPE_FAIL 5
79#endif
80
81#define BOOT_IMG_VER_STRLEN_MAX 25 /* 255.255.65535.4294967295\0 */
82
83
96};
97
112};
113
137 union {
140 } h;
141};
142
158 struct mcuboot_img_header *header,
159 size_t header_size);
160
176
190
206
214
224int mcuboot_swap_type_multi(int image_index);
225
226
228#define BOOT_UPGRADE_TEST 0
229#define BOOT_UPGRADE_PERMANENT 1
230
241int boot_request_upgrade(int permanent);
242
255int boot_request_upgrade_multi(int image_index, int permanent);
256
264
272
281
282#ifdef __cplusplus
283}
284#endif
285
290#endif /* ZEPHYR_INCLUDE_DFU_MCUBOOT_H_ */
int boot_erase_img_bank(uint8_t area_id)
Erase the image Bank.
int mcuboot_swap_type_multi(int image_index)
Determines the action, if any, that mcuboot will take on the next reboot.
bool boot_is_img_confirmed(void)
Check if the currently running image is confirmed as OK.
int boot_read_bank_header(uint8_t area_id, struct mcuboot_img_header *header, size_t header_size)
Read the MCUboot image header information from an image bank.
ssize_t boot_get_area_trailer_status_offset(uint8_t area_id)
Get the offset of the status in the image bank.
ssize_t boot_get_trailer_status_offset(size_t area_size)
Get the offset of the status from an image bank size.
int boot_write_img_confirmed(void)
Marks the currently running image as confirmed.
int mcuboot_swap_type(void)
Determines the action, if any, that mcuboot will take on the next reboot.
int boot_write_img_confirmed_multi(int image_index)
Marks the image with the given index in the primary slot as confirmed.
int boot_request_upgrade(int permanent)
Marks the image in slot 1 as pending. On the next reboot, the system will perform a boot of the slot ...
int boot_request_upgrade_multi(int image_index, int permanent)
Marks the image with the given index in the secondary slot as pending. On the next reboot,...
__SIZE_TYPE__ ssize_t
Definition: types.h:28
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Model for the MCUboot image header as of version 1.
Definition: mcuboot.h:107
struct mcuboot_img_sem_ver sem_ver
Definition: mcuboot.h:111
uint32_t image_size
Definition: mcuboot.h:109
Model for the MCUBoot image header.
Definition: mcuboot.h:125
union mcuboot_img_header::@110 h
uint32_t mcuboot_version
Definition: mcuboot.h:131
struct mcuboot_img_header_v1 v1
Definition: mcuboot.h:139
MCUboot image header representation for image version.
Definition: mcuboot.h:91
uint8_t minor
Definition: mcuboot.h:93
uint16_t revision
Definition: mcuboot.h:94
uint32_t build_num
Definition: mcuboot.h:95
uint8_t major
Definition: mcuboot.h:92