45 #define RIOTBOOT_MAGIC_V1 0x544f4952
50 #define RIOTBOOT_MAGIC_V2 0x54304952
53 #if defined(MODULE_RIOTBOOT_HDR_V2)
54 # define RIOTBOOT_MAGIC RIOTBOOT_MAGIC_V2
56 # define RIOTBOOT_MAGIC RIOTBOOT_MAGIC_V1
63 #define RIOTBOOT_HDR_IMAGE_BOOT_COUNT_SHIFT 0u
67 #define RIOTBOOT_HDR_IMAGE_BOOT_COUNT_MASK (0x0000000f << RIOTBOOT_HDR_IMAGE_BOOT_COUNT_SHIFT)
71 #define RIOTBOOT_HDR_IMAGE_STATE_SHIFT 4u
75 #define RIOTBOOT_HDR_IMAGE_STATE_MASK (0x0000000f << RIOTBOOT_HDR_IMAGE_STATE_SHIFT)
79 #ifndef CONFIG_RIOTBOOT_MAX_ATTEMPTS
80 # define CONFIG_RIOTBOOT_MAX_ATTEMPTS 3u
84 "CONFIG_RIOTBOOT_MAX_ATTEMPTS must be at least 1");
87 "CONFIG_RIOTBOOT_MAX_ATTEMPTS must be <= 4");
232 unsigned boot_count);
POSIX.1-2008 compliant version of the assert macro.
#define static_assert(cond,...)
static_assert for c-version < c11
bool riotboot_hdr_is_v2(const riotboot_hdr_t *riotboot_hdr)
Check if the header is version 2.
union riotboot_hdr riotboot_hdr_t
Union to store riotboot headers in different versions.
uint32_t riotboot_hdr_get_start_addr(const riotboot_hdr_t *riotboot_hdr)
Getter for riotboot start address.
int riotboot_hdr_validate(const riotboot_hdr_t *riotboot_hdr)
Validate image header.
uint32_t riotboot_hdr_get_flags(const riotboot_hdr_t *riotboot_hdr)
Getter for riotboot flags.
unsigned riotboot_hdr_get_boot_count(const riotboot_hdr_t *riotboot_hdr)
Get current image boot count.
void riotboot_hdr_print(const riotboot_hdr_t *riotboot_hdr)
Print formatted riotboot_hdr_t to STDIO.
enum riotboot_hdr_img_state riotboot_hdr_img_state_t
Image state enumeration.
int riotboot_hdr_get_img_state(const riotboot_hdr_t *riotboot_hdr)
Get image state.
uint32_t riotboot_hdr_get_version(const riotboot_hdr_t *riotboot_hdr)
Getter for riotboot version.
uint32_t riotboot_hdr_checksum(const riotboot_hdr_t *riotboot_hdr)
Calculate header checksum.
#define CONFIG_RIOTBOOT_MAX_ATTEMPTS
Maximum number of attempts to boot a tentative image before reverting to the previous one.
int riotboot_hdr_set_img_state(riotboot_hdr_t *riotboot_hdr, riotboot_hdr_img_state_t state)
Set image state.
void riotboot_hdr_set_boot_count(riotboot_hdr_t *riotboot_hdr, unsigned boot_count)
Set image boot count.
uint32_t riotboot_hdr_get_checksum(const riotboot_hdr_t *riotboot_hdr)
Getter for the header checksum.
uint32_t riotboot_hdr_get_magic_number(const riotboot_hdr_t *riotboot_hdr)
Getter for riotboot magic number.
riotboot_hdr_img_state
Image state enumeration.
@ RIOTBOOT_HDR_IMG_STATE_DISMISSED
Image is dismissed (0000)
@ RIOTBOOT_HDR_IMG_STATE_INSTALLED
Image is installed (1111)
@ RIOTBOOT_HDR_IMG_STATE_ACTIVATED
Image is activated (1100)
@ RIOTBOOT_HDR_IMG_STATE_CONFIRMED
Image is confirmed (1000)
@ RIOTBOOT_HDR_IMG_STATE_DEACTIVATED
Image is deactivated (1110)
Structure to store image header - All members are little endian.
uint32_t version
Integer representing the partition version
uint32_t start_addr
Address after the allocated space for the header.
uint32_t magic_number
Header magic number
uint32_t chksum
Checksum of riotboot_hdr
Structure to store image header v2 - All members are little endian.
uint32_t chksum
Checksum of riotboot_hdr
uint32_t version
Integer representing the partition version
uint32_t flags
General purpose flags for image state and boot count.
uint32_t magic_number
Header magic number
uint32_t start_addr
Address after the allocated space for the header
Union to store riotboot headers in different versions.
struct riotboot_hdr_v2 v2
Version 2 header.
struct riotboot_hdr_v1 v1
Version 1 header.