11#include <zephyr/types.h>
12#include <drivers/nrfx_common.h>
24#define EINVALIDLCS 115
27#define SB_PUBLIC_KEY_HASH_LEN 16
30#define BL_MONOTONIC_COUNTERS_DESC_NSIB 0x1
36#define BL_MONOTONIC_COUNTERS_DESC_MCUBOOT_ID0 0x2
77#define BL_STORAGE ((const volatile struct bl_storage_data *)(PM_PROVISION_ADDRESS))
80#define BL_STORAGE_IMPLEMENTATION_ID_SIZE 32
200NRFX_STATIC_INLINE
void otp_copy32(uint8_t *restrict dst, uint32_t
volatile * restrict src,
203 for (
int i = 0; i < size / 4; i++) {
205 uint32_t val = nrfx_nvmc_uicr_word_read(src + i);
207 for (
int j = 0; j < 4; j++) {
208 dst[i * 4 + j] = (val >> 8 * j) & 0xFF;
232#define STATE_ENTERED 0x0000
233#define STATE_NOT_ENTERED 0xFFFF
255 uint16_t provisioning = nrfx_nvmc_otp_halfword_read(
257 uint16_t secure = nrfx_nvmc_otp_halfword_read((uint32_t) &
BL_STORAGE->lcs.secure);
258 uint16_t decommissioned = nrfx_nvmc_otp_halfword_read(
298 enum lcs current_lcs = 0;
309 if (next_lcs < current_lcs) {
314 if (next_lcs == current_lcs) {
#define SB_PUBLIC_KEY_HASH_LEN
Definition bl_storage.h:27
#define EREADLCS
Definition bl_storage.h:23
#define BL_STORAGE
Definition bl_storage.h:77
#define EINVALIDLCS
Definition bl_storage.h:24
#define BL_STORAGE_IMPLEMENTATION_ID_SIZE
Definition bl_storage.h:80
#define STATE_ENTERED
Definition bl_storage.h:232
int verify_public_keys(void)
Function for reading number of public key data slots.
uint32_t s0_address_read(void)
Function for reading address of slot 0.
uint32_t num_public_keys_read(void)
Function for reading number of public key data slots.
#define STATE_NOT_ENTERED
Definition bl_storage.h:233
void otp_copy32(uint8_t *restrict dst, uint32_t volatile *restrict src, size_t size)
Definition bl_storage.h:200
int read_life_cycle_state(enum lcs *lcs)
Read the current life cycle state the device is in from OTP,.
Definition bl_storage.h:249
void invalidate_public_key(uint32_t key_idx)
Function for invalidating a public key.
int num_monotonic_counter_slots(uint16_t counter_desc, uint16_t *counter_slots)
Get the number of monotonic counter slots.
int update_life_cycle_state(enum lcs next_lcs)
Update the life cycle state in OTP.
Definition bl_storage.h:295
int public_key_data_read(uint32_t key_idx, uint8_t *p_buf)
Function for reading public key hashes.
uint32_t s1_address_read(void)
Function for reading address of slot 1.
int set_monotonic_counter(uint16_t counter_desc, uint16_t new_counter)
Set the current HW monotonic counter.
void read_implementation_id_from_otp(uint8_t *buf)
Definition bl_storage.h:217
int get_monotonic_counter(uint16_t counter_desc, uint16_t *counter_value)
Get the current HW monotonic counter.
lcs
The PSA life cycle states a device can be in.
Definition bl_storage.h:184
@ BL_STORAGE_LCS_DECOMMISSIONED
Definition bl_storage.h:189
@ BL_STORAGE_LCS_UNKNOWN
Definition bl_storage.h:185
@ BL_STORAGE_LCS_ASSEMBLY
Definition bl_storage.h:186
@ BL_STORAGE_LCS_PROVISIONING
Definition bl_storage.h:187
@ BL_STORAGE_LCS_SECURED
Definition bl_storage.h:188
uint32_t num_public_keys
Definition bl_storage.h:70
struct bl_storage_data::@151 key_data[1]
uint8_t implementation_id[32]
Definition bl_storage.h:67
uint32_t valid
Definition bl_storage.h:72
uint32_t s0_address
Definition bl_storage.h:68
uint32_t s1_address
Definition bl_storage.h:69
Definition bl_storage.h:64
uint16_t decommissioned
Definition bl_storage.h:57
uint16_t reserved_for_padding
Definition bl_storage.h:56
uint16_t secure
Definition bl_storage.h:50
uint16_t provisioning
Definition bl_storage.h:49
Definition bl_storage.h:48