Skip to content

Commit 22fc493

Browse files
committed
bootloader: move boot_data_t to memory_shared.h
To make it available to the firmware.
1 parent 01f51e2 commit 22fc493

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

src/bootloader/bootloader.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -96,40 +96,6 @@ COMPILER_PACK_RESET()
9696
#error "incompatible variable type"
9797
#endif
9898

99-
#define BOOT_NUM_FIRMWARE_SIGNING_KEYS 3u
100-
#define BOOT_NUM_ROOT_SIGNING_KEYS 3u
101-
#define BOOT_FIRMWARE_SIG_M 2u
102-
#define BOOT_ROOT_SIG_M 2u
103-
#define BOOT_PUBKEY_LEN 64u
104-
#define BOOT_SIG_LEN 64u
105-
106-
#pragma GCC diagnostic push
107-
#pragma GCC diagnostic ignored "-Wpacked"
108-
#pragma GCC diagnostic ignored "-Wattributes"
109-
// Packed to make the layout more explicit.
110-
// Total size equals min erase granularity
111-
typedef uint32_t version_t;
112-
typedef union {
113-
struct __attribute__((__packed__)) {
114-
// `hardware_version` is deprecated/unused, as MPU prevents the firmware from easily reading
115-
// this.
116-
uint16_t hardware_version;
117-
uint8_t is_initialized[2];
118-
version_t signing_pubkeys_version;
119-
uint8_t signing_pubkeys
120-
[BOOT_PUBKEY_LEN *
121-
BOOT_NUM_FIRMWARE_SIGNING_KEYS]; // Keep after signing_pubkeys_version
122-
uint8_t root_signatures_of_signing_pubkeys[BOOT_SIG_LEN * BOOT_NUM_ROOT_SIGNING_KEYS];
123-
version_t firmware_version;
124-
uint8_t
125-
firmware_signatures[BOOT_SIG_LEN * BOOT_NUM_FIRMWARE_SIGNING_KEYS]; // Keep after
126-
// firmware_version
127-
uint8_t show_firmware_hash;
128-
} fields;
129-
uint8_t bytes[FLASH_BOOTDATA_LEN];
130-
} boot_data_t;
131-
132-
#pragma GCC diagnostic pop
13399
// Be sure to not overflow boot data area
134100
static_assert(sizeof(((boot_data_t*)0)->fields) <= FLASH_BOOTDATA_LEN, "boot_data_t too large");
135101
// Be sure signing pubkey data fits within a single chunk

src/memory/memory_shared.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,40 @@
2424
#error "Shared data chunk not correct length"
2525
#endif
2626

27+
#define BOOT_NUM_FIRMWARE_SIGNING_KEYS 3u
28+
#define BOOT_NUM_ROOT_SIGNING_KEYS 3u
29+
#define BOOT_FIRMWARE_SIG_M 2u
30+
#define BOOT_ROOT_SIG_M 2u
31+
#define BOOT_PUBKEY_LEN 64u
32+
#define BOOT_SIG_LEN 64u
33+
34+
#pragma GCC diagnostic push
35+
#pragma GCC diagnostic ignored "-Wpacked"
36+
#pragma GCC diagnostic ignored "-Wattributes"
37+
// Packed to make the layout more explicit.
38+
// Total size equals min erase granularity
39+
typedef uint32_t version_t;
40+
typedef union {
41+
struct __attribute__((__packed__)) {
42+
// `hardware_version` is deprecated/unused, as MPU prevents the firmware from easily reading
43+
// this.
44+
uint16_t hardware_version;
45+
uint8_t is_initialized[2];
46+
version_t signing_pubkeys_version;
47+
uint8_t signing_pubkeys
48+
[BOOT_PUBKEY_LEN *
49+
BOOT_NUM_FIRMWARE_SIGNING_KEYS]; // Keep after signing_pubkeys_version
50+
uint8_t root_signatures_of_signing_pubkeys[BOOT_SIG_LEN * BOOT_NUM_ROOT_SIGNING_KEYS];
51+
version_t firmware_version;
52+
uint8_t
53+
firmware_signatures[BOOT_SIG_LEN * BOOT_NUM_FIRMWARE_SIGNING_KEYS]; // Keep after
54+
// firmware_version
55+
uint8_t show_firmware_hash;
56+
} fields;
57+
uint8_t bytes[FLASH_BOOTDATA_LEN];
58+
} boot_data_t;
59+
#pragma GCC diagnostic pop
60+
2761
// CHUNK_SHARED: Shared data between the bootloader and firmware.
2862
// auto_enter: if sectrue_u8, bootloader mode is entered on reboot
2963
// upside_down: passes screen orientation to the bootloader

0 commit comments

Comments
 (0)