123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- #ifndef ZEPHYR_INCLUDE_DFU_MCUBOOT_H_
- #define ZEPHYR_INCLUDE_DFU_MCUBOOT_H_
- #include <stdbool.h>
- #include <stddef.h>
- #include <zephyr/types.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifdef BOOT_SWAP_TYPE_NONE
- #if BOOT_SWAP_TYPE_NONE != 1
- #error "definition incompatible"
- #endif
- #else
- #define BOOT_SWAP_TYPE_NONE 1
- #endif
- #ifdef BOOT_SWAP_TYPE_TEST
- #if BOOT_SWAP_TYPE_TEST != 2
- #error "definition incompatible"
- #endif
- #else
- #define BOOT_SWAP_TYPE_TEST 2
- #endif
- #ifdef BOOT_SWAP_TYPE_PERM
- #if BOOT_SWAP_TYPE_PERM != 3
- #error "definition incompatible"
- #endif
- #else
- #define BOOT_SWAP_TYPE_PERM 3
- #endif
- #ifdef BOOT_SWAP_TYPE_REVERT
- #if BOOT_SWAP_TYPE_REVERT != 4
- #error "definition incompatible"
- #endif
- #else
- #define BOOT_SWAP_TYPE_REVERT 4
- #endif
- #ifdef BOOT_SWAP_TYPE_FAIL
- #if BOOT_SWAP_TYPE_FAIL != 5
- #error "definition incompatible"
- #endif
- #else
- #define BOOT_SWAP_TYPE_FAIL 5
- #endif
- #define BOOT_IMG_VER_STRLEN_MAX 25
- #define BOOT_MAX_ALIGN 8
- #ifndef BOOT_MAGIC_SZ
- #define BOOT_MAGIC_SZ 16
- #endif
- #define BOOT_TRAILER_IMG_STATUS_OFFS(bank_area) ((bank_area)->fa_size -\
- BOOT_MAGIC_SZ -\
- BOOT_MAX_ALIGN * 2)
- struct mcuboot_img_sem_ver {
- uint8_t major;
- uint8_t minor;
- uint16_t revision;
- uint32_t build_num;
- };
- struct mcuboot_img_header_v1 {
-
- uint32_t image_size;
-
- struct mcuboot_img_sem_ver sem_ver;
- };
- struct mcuboot_img_header {
-
- uint32_t mcuboot_version;
-
- union {
-
- struct mcuboot_img_header_v1 v1;
- } h;
- };
- int boot_read_bank_header(uint8_t area_id,
- struct mcuboot_img_header *header,
- size_t header_size);
- bool boot_is_img_confirmed(void);
- int boot_write_img_confirmed(void);
- int boot_write_img_confirmed_multi(int image_index);
- int mcuboot_swap_type(void);
- int mcuboot_swap_type_multi(int image_index);
- #define BOOT_UPGRADE_TEST 0
- #define BOOT_UPGRADE_PERMANENT 1
- int boot_request_upgrade(int permanent);
- int boot_request_upgrade_multi(int image_index, int permanent);
- int boot_erase_img_bank(uint8_t area_id);
- #ifdef __cplusplus
- }
- #endif
- #endif
|