Zephyr API Documentation  2.7.0-rc2
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
8#ifndef ZEPHYR_INCLUDE_DFU_MCUBOOT_H_
9#define ZEPHYR_INCLUDE_DFU_MCUBOOT_H_
10
11#include <stdbool.h>
12#include <stddef.h>
13
14#include <zephyr/types.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#ifdef BOOT_SWAP_TYPE_NONE
21#if BOOT_SWAP_TYPE_NONE != 1 /*ensure the same definition in MCUboot */
22#error "definition incompatible"
23#endif
24#else
26#define BOOT_SWAP_TYPE_NONE 1
27#endif
28
29#ifdef BOOT_SWAP_TYPE_TEST
30#if BOOT_SWAP_TYPE_TEST != 2 /*ensure the same definition in MCUboot */
31#error "definition incompatible"
32#endif
33#else
35#define BOOT_SWAP_TYPE_TEST 2
36#endif
37
38#ifdef BOOT_SWAP_TYPE_PERM
39#if BOOT_SWAP_TYPE_PERM != 3 /*ensure the same definition in MCUboot */
40#error "definition incompatible"
41#endif
42#else
44#define BOOT_SWAP_TYPE_PERM 3
45#endif
46
47#ifdef BOOT_SWAP_TYPE_REVERT
48#if BOOT_SWAP_TYPE_REVERT != 4 /*ensure the same definition in MCUboot */
49#error "definition incompatible"
50#endif
51#else
53#define BOOT_SWAP_TYPE_REVERT 4
54#endif
55
56#ifdef BOOT_SWAP_TYPE_FAIL
57#if BOOT_SWAP_TYPE_FAIL != 5 /*ensure the same definition in MCUboot */
58#error "definition incompatible"
59#endif
60#else
62#define BOOT_SWAP_TYPE_FAIL 5
63#endif
64
65#define BOOT_IMG_VER_STRLEN_MAX 25 /* 255.255.65535.4294967295\0 */
66
67/* Trailer: */
68#define BOOT_MAX_ALIGN 8
69#ifndef BOOT_MAGIC_SZ
70#define BOOT_MAGIC_SZ 16
71#endif
72
73#define BOOT_TRAILER_IMG_STATUS_OFFS(bank_area) ((bank_area)->fa_size -\
74 BOOT_MAGIC_SZ -\
75 BOOT_MAX_ALIGN * 2)
88};
89
104};
105
129 union {
132 } h;
133};
134
150 struct mcuboot_img_header *header,
151 size_t header_size);
152
168
182
198
206
216int mcuboot_swap_type_multi(int image_index);
217
218
220#define BOOT_UPGRADE_TEST 0
221#define BOOT_UPGRADE_PERMANENT 1
222
233int boot_request_upgrade(int permanent);
234
247int boot_request_upgrade_multi(int image_index, int permanent);
248
256
257#ifdef __cplusplus
258}
259#endif
260
261#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.
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,...
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
Model for the MCUboot image header as of version 1.
Definition: mcuboot.h:99
struct mcuboot_img_sem_ver sem_ver
Definition: mcuboot.h:103
uint32_t image_size
Definition: mcuboot.h:101
Model for the MCUBoot image header.
Definition: mcuboot.h:117
union mcuboot_img_header::@99 h
uint32_t mcuboot_version
Definition: mcuboot.h:123
struct mcuboot_img_header_v1 v1
Definition: mcuboot.h:131
MCUboot image header representation for image version.
Definition: mcuboot.h:83
uint8_t minor
Definition: mcuboot.h:85
uint16_t revision
Definition: mcuboot.h:86
uint32_t build_num
Definition: mcuboot.h:87
uint8_t major
Definition: mcuboot.h:84