31#ifndef _FIRST_STAGE_BOOT_H
32#define _FIRST_STAGE_BOOT_H
42#ifndef BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_SUPPORT
43#define BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_SUPPORT DISABLED
46#if (BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_SUPPORT != ENABLED) && \
47 (BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_SUPPORT != DISABLED)
48#error "BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_SUPPORT must be ENABLED or DISABLED"
51#ifndef BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_SUPPORT
52#define BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_SUPPORT DISABLED
55#if (BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_SUPPORT != ENABLED) && \
56 (BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_SUPPORT != DISABLED)
57#error "BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_SUPPORT must be ENABLED or DISABLED"
60#ifndef BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_ECDSA
61#define BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_ECDSA DISABLED
63#ifndef BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_RSA
64#define BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_RSA DISABLED
69#if (BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_SUPPORT == ENABLED) && \
70 (BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_SUPPORT == ENABLED)
71#error "Enable only one of BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_SUPPORT or _RUNTIME_SIGNATURE_SUPPORT"
75#if (BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_SUPPORT == ENABLED) && \
76 !defined(BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_ALGO)
77#error "Define BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_ALGO when BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_SUPPORT is ENABLED"
81#if (BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_SUPPORT == ENABLED) && \
82 ((BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_ECDSA == ENABLED) == \
83 (BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_RSA == ENABLED))
84#error "Enable exactly one of BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_ECDSA or _RSA"
89#ifndef BOOT_ANTI_ROLLBACK_SUPPORT
90#define BOOT_ANTI_ROLLBACK_SUPPORT DISABLED
91#elif ((BOOT_ANTI_ROLLBACK_SUPPORT != ENABLED) && (BOOT_ANTI_ROLLBACK_SUPPORT != DISABLED))
92#error BOOT_ANTI_ROLLBACK_SUPPORT parameter is not valid
97#ifndef BOOT_EXT_MEM_ENCRYPTION_SUPPORT
98#define BOOT_EXT_MEM_ENCRYPTION_SUPPORT DISABLED
99#elif ((BOOT_EXT_MEM_ENCRYPTION_SUPPORT != ENABLED) && \
100 (BOOT_EXT_MEM_ENCRYPTION_SUPPORT != DISABLED))
101#error BOOT_EXT_MEM_ENCRYPTION_SUPPORT parameter is not valid
107#if (BOOT_FIRST_STAGE_RUNTIME_INTEGRITY_SUPPORT == DISABLED) && \
108 (BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_SUPPORT == DISABLED) && \
109 !defined(BOOT_FIRST_STAGE_ALLOW_UNVERIFIED_SECOND_STAGE)
110#error "The first stage would accept any second stage passing a CRC32 check. Enable \
111 BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_SUPPORT (or _INTEGRITY_), or define \
112 BOOT_FIRST_STAGE_ALLOW_UNVERIFIED_SECOND_STAGE to accept this."
119 Memory memories[NB_MEMORIES];
120 uint32_t self_address;
123#if (BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_SUPPORT == ENABLED)
124 const char_t *signKey;
127#if (BOOT_EXT_MEM_ENCRYPTION_SUPPORT == ENABLED)
128 const uint8_t *cipherKey;
137 Memory memories[NB_MEMORIES];
138 uint32_t self_address;
142#if (BOOT_FIRST_STAGE_RUNTIME_SIGNATURE_SUPPORT == ENABLED)
143 const char_t *signKey;
146#if (BOOT_EXT_MEM_ENCRYPTION_SUPPORT == ENABLED)
147 const uint8_t *cipherKey;
157 bool_t residentOk, bool_t *updateFound);
165#if ((defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined(__GNUC__) || \
166 defined(__CC_ARM) || defined(__IAR_SYSTEMS_ICC__) || defined(__TASKING__) || \
167 defined(__CWCC__) || defined(__TI_ARM__))
168void bootHandleError(
void);
169void bootSecondStageUpdatedHook(
void);
170void bootJumpingToSecondStageHook(
void);
172#elif ((defined(_MSC_VER) || defined(_WIN32) || defined(WIN32) || defined(WIN64) || \
174extern void bootHandleError(
void);
175extern void bootSecondStageUpdatedHook(
void);
176extern void bootJumpingToSecondStageHook(
void);
__weak_func cboot_error_t bootRecoveryHook(RecoveryReason reason, RecoveryAction *action)
Recovery action callback. It is declared weak and may be replaced in the user code space....
Definition boot_recovery.c:101
cboot_error_t
Error codes.
Definition cboot_error.h:57
CycloneBOOT CRC32 cryptographic integrity tag.
cboot_error_t updateSecondStageBl(BootContext *context)
Install the 2nd stage bootloader update.
Definition boot.c:606
void jumpToSecondStageBl(BootContext *context)
Branching to the 2nd stage bootloader.
Definition boot.c:410
cboot_error_t bootFsm(BootContext *context)
Bootloader Task routine.
Definition boot.c:233
cboot_error_t checkForSecondStageBlUpdate(BootContext *context, uint32_t currentIndex, bool_t residentOk, bool_t *updateFound)
Iterates over the available download slots.
Definition boot.c:434
cboot_error_t bootInit(BootContext *context, BootSettings *settings)
Initialize the first-stage bootloader context from user settings.
Definition boot.c:131
void bootGetDefaultSettings(BootSettings *settings)
Initialize first-stage bootloader settings with default values.
Definition boot.c:55
cboot_error_t getSecondStageBlIndex(BootContext *context, uint32_t *index)
Get the image index of the second stage bootloader.
Definition boot.c:364
Slot * bootGetActiveSlot(BootContext *context)
Resolve the active second-stage (BOOT) slot in the primary memory.
Definition boot.c:174
CycloneBOOT Image management.
CycloneBOOT Memory Layer Abstraction.
First-stage bootloader context.
Definition boot.h:136
First-stage bootloader user settings.
Definition boot.h:118
Memory Definition.
Definition memory.h:225
Slot Type definition.
Definition memory.h:181