diff --git a/core/embed/projects/boardloader/main.c b/core/embed/projects/boardloader/main.c
index b696b8cadf..fee3306205 100644
--- a/core/embed/projects/boardloader/main.c
+++ b/core/embed/projects/boardloader/main.c
@@ -103,14 +103,14 @@ static void drivers_deinit(void) {
#endif
}
-struct BoardCapabilities capabilities
+board_capabilities_t capabilities
__attribute__((section(".capabilities_section"))) = {
.header = CAPABILITIES_HEADER,
.model_tag = TAG_MODEL_NAME,
.model_length = sizeof(uint32_t),
.model_name = HW_MODEL,
.version_tag = TAG_BOARDLOADER_VERSION,
- .version_length = sizeof(struct BoardloaderVersion),
+ .version_length = sizeof(boardloader_version_t),
.version = {.version_major = VERSION_MAJOR,
.version_minor = VERSION_MINOR,
.version_patch = VERSION_PATCH,
diff --git a/core/embed/projects/prodtest/cmd/prodtest_boardloader.c b/core/embed/projects/prodtest/cmd/prodtest_boardloader.c
index bd53e498c8..a94f039527 100644
--- a/core/embed/projects/prodtest/cmd/prodtest_boardloader.c
+++ b/core/embed/projects/prodtest/cmd/prodtest_boardloader.c
@@ -31,8 +31,8 @@ static void prodtest_boardloader_version(cli_t* cli) {
cli_trace(cli, "Parsing boardloader capabilities...");
parse_boardloader_capabilities();
- const boardloader_version_t* v = get_boardloader_version();
- cli_ok(cli, "%d.%d.%d", v->version_major, v->version_minor, v->version_patch);
+ boardloader_version_t v = get_boardloader_version();
+ cli_ok(cli, "%d.%d.%d", v.version_major, v.version_minor, v.version_patch);
}
// clang-format off
diff --git a/core/embed/util/board_capabilities/inc/util/board_capabilities.h b/core/embed/util/board_capabilities/inc/util/board_capabilities.h
index 184aaecde9..0495b3692b 100644
--- a/core/embed/util/board_capabilities/inc/util/board_capabilities.h
+++ b/core/embed/util/board_capabilities/inc/util/board_capabilities.h
@@ -17,26 +17,33 @@
* along with this program. If not, see .
*/
-#ifndef __TREZORHAL_BOARD_CAPABILITIES_H__
-#define __TREZORHAL_BOARD_CAPABILITIES_H__
-
-/*
-Simple key-tag-length-value structure at fixed boardloader address.
-
-* header 4 bytes `TRZC`
-* each field is 4 bytes or multiple (because of alignment)
-* 4 bytes are
- * 1-byte tag+type - CapabilityTag
- * 1 byte length - counting from next byte forward
- * 0 or more bytes of data, doesn't have to be aligned
-
-Last tag must be terminator or all space used.
-*/
+#pragma once
#include
#ifdef KERNEL_MODE
+typedef struct __attribute__((packed)) {
+ uint8_t version_major;
+ uint8_t version_minor;
+ uint8_t version_patch;
+ uint8_t version_build;
+} boardloader_version_t;
+
+// Structure holding board capabilities.
+// Older boardloaders can have it missing or reordered.
+//
+// Simple key-tag-length-value structure at fixed boardloader address.
+//
+// header 4 bytes `TRZC`
+// each field is 4 bytes or multiple (because of alignment)
+// 4 bytes are
+// 1-byte tag+type - CapabilityTag
+// 1 byte length - counting from next byte forward
+// 0 or more bytes of data, doesn't have to be aligned
+//
+// Last tag must be terminator or all space used.
+
#define CAPABILITIES_HEADER "TRZC"
enum CapabilityTag {
@@ -46,38 +53,29 @@ enum CapabilityTag {
TAG_BOARDLOADER_VERSION = 0x03
};
-typedef struct __attribute__((packed)) BoardloaderVersion {
- uint8_t version_major;
- uint8_t version_minor;
- uint8_t version_patch;
- uint8_t version_build;
-} boardloader_version_t;
-
-/*
- * Structure of current boardloader. Older boardloaders can have it missing,
- * reordered.
- */
-struct __attribute__((packed)) BoardCapabilities {
+typedef struct __attribute__((packed)) {
uint8_t header[4];
uint8_t model_tag;
uint8_t model_length;
uint32_t model_name;
uint8_t version_tag;
uint8_t version_length;
- struct BoardloaderVersion version;
- enum CapabilityTag terminator_tag;
+ boardloader_version_t version;
+ uint8_t terminator_tag;
uint8_t terminator_length;
-};
+} board_capabilities_t;
-/*
- * Parse capabilities into RAM. Use while boardloader is accessible,
- * before MPU is active.
- */
+// Parses capabiilites from boardloader into RAM
+//
+// This function must be called before any other function
+// that uses the capabilities
void parse_boardloader_capabilities();
-const uint32_t get_board_name();
-const boardloader_version_t* get_boardloader_version();
+// Gets four bytes containing characters identifying the board
+// (e.g. `T3T1` for Trezor Safe 5)
+uint32_t get_board_name();
+
+// Gets the boardloader version
+boardloader_version_t get_boardloader_version();
#endif // KERNEL_MODE
-
-#endif
diff --git a/core/embed/util/board_capabilities/stm32/board_capabilities.c b/core/embed/util/board_capabilities/stm32/board_capabilities.c
index bb7d03955b..2b815ee0c6 100644
--- a/core/embed/util/board_capabilities/stm32/board_capabilities.c
+++ b/core/embed/util/board_capabilities/stm32/board_capabilities.c
@@ -27,13 +27,11 @@
static uint32_t board_name = 0;
-static struct BoardloaderVersion boardloader_version;
+static boardloader_version_t boardloader_version = {0};
const uint32_t get_board_name() { return board_name; }
-const boardloader_version_t *get_boardloader_version() {
- return &boardloader_version;
-}
+boardloader_version_t get_boardloader_version() { return boardloader_version; }
void parse_boardloader_capabilities() {
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_BOARDCAPS);