Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootloader: move boot_data_t to memory_shared.h #1196

Merged
1 commit merged into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions src/bootloader/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,40 +96,6 @@ COMPILER_PACK_RESET()
#error "incompatible variable type"
#endif

#define BOOT_NUM_FIRMWARE_SIGNING_KEYS 3u
#define BOOT_NUM_ROOT_SIGNING_KEYS 3u
#define BOOT_FIRMWARE_SIG_M 2u
#define BOOT_ROOT_SIG_M 2u
#define BOOT_PUBKEY_LEN 64u
#define BOOT_SIG_LEN 64u

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpacked"
#pragma GCC diagnostic ignored "-Wattributes"
// Packed to make the layout more explicit.
// Total size equals min erase granularity
typedef uint32_t version_t;
typedef union {
struct __attribute__((__packed__)) {
// `hardware_version` is deprecated/unused, as MPU prevents the firmware from easily reading
// this.
uint16_t hardware_version;
uint8_t is_initialized[2];
version_t signing_pubkeys_version;
uint8_t signing_pubkeys
[BOOT_PUBKEY_LEN *
BOOT_NUM_FIRMWARE_SIGNING_KEYS]; // Keep after signing_pubkeys_version
uint8_t root_signatures_of_signing_pubkeys[BOOT_SIG_LEN * BOOT_NUM_ROOT_SIGNING_KEYS];
version_t firmware_version;
uint8_t
firmware_signatures[BOOT_SIG_LEN * BOOT_NUM_FIRMWARE_SIGNING_KEYS]; // Keep after
// firmware_version
uint8_t show_firmware_hash;
} fields;
uint8_t bytes[FLASH_BOOTDATA_LEN];
} boot_data_t;

#pragma GCC diagnostic pop
// Be sure to not overflow boot data area
static_assert(sizeof(((boot_data_t*)0)->fields) <= FLASH_BOOTDATA_LEN, "boot_data_t too large");
// Be sure signing pubkey data fits within a single chunk
Expand Down
34 changes: 34 additions & 0 deletions src/memory/memory_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,40 @@
#error "Shared data chunk not correct length"
#endif

#define BOOT_NUM_FIRMWARE_SIGNING_KEYS 3u
#define BOOT_NUM_ROOT_SIGNING_KEYS 3u
#define BOOT_FIRMWARE_SIG_M 2u
#define BOOT_ROOT_SIG_M 2u
#define BOOT_PUBKEY_LEN 64u
#define BOOT_SIG_LEN 64u

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpacked"
#pragma GCC diagnostic ignored "-Wattributes"
// Packed to make the layout more explicit.
// Total size equals min erase granularity
typedef uint32_t version_t;
typedef union {
struct __attribute__((__packed__)) {
// `hardware_version` is deprecated/unused, as MPU prevents the firmware from easily reading
// this.
uint16_t hardware_version;
uint8_t is_initialized[2];
version_t signing_pubkeys_version;
uint8_t signing_pubkeys
[BOOT_PUBKEY_LEN *
BOOT_NUM_FIRMWARE_SIGNING_KEYS]; // Keep after signing_pubkeys_version
uint8_t root_signatures_of_signing_pubkeys[BOOT_SIG_LEN * BOOT_NUM_ROOT_SIGNING_KEYS];
version_t firmware_version;
uint8_t
firmware_signatures[BOOT_SIG_LEN * BOOT_NUM_FIRMWARE_SIGNING_KEYS]; // Keep after
// firmware_version
uint8_t show_firmware_hash;
} fields;
uint8_t bytes[FLASH_BOOTDATA_LEN];
} boot_data_t;
#pragma GCC diagnostic pop

// CHUNK_SHARED: Shared data between the bootloader and firmware.
// auto_enter: if sectrue_u8, bootloader mode is entered on reboot
// upside_down: passes screen orientation to the bootloader
Expand Down
Loading