1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-03-08 03:07:03 +00:00

refactor(core): extract monotonic version to model specific headers

[no changelog]
This commit is contained in:
tychovrahe 2024-08-27 12:59:31 +02:00 committed by TychoVrahe
parent c1864a2a91
commit 395a4af9be
19 changed files with 72 additions and 21 deletions

View File

@ -26,7 +26,7 @@ g_header:
.byte FIX_VERSION_BUILD // fix_vbuild
.word HW_MODEL // type of the designated hardware
.byte HW_REVISION // revision of the designated hardware
.byte VERSION_MONOTONIC // monotonic version of the binary
.byte BOOTLOADER_MONOTONIC_VERSION // monotonic version of the binary
. = . + 2 // reserved
. = . + 512 // hash1 ... hash16
. = . + 415 // reserved

View File

@ -266,10 +266,12 @@ static secbool check_vendor_header_lock(const vendor_header *const vhdr) {
#if PRODUCTION && !defined STM32U5
static void check_bootloader_version(void) {
ensure(monoctr_write(MONOCTR_BOOTLOADER_VERSION, VERSION_MONOTONIC), NULL);
ensure(
monoctr_write(MONOCTR_BOOTLOADER_VERSION, BOOTLOADER_MONOTONIC_VERSION),
NULL);
uint8_t val = 0;
ensure(monoctr_read(MONOCTR_BOOTLOADER_VERSION, &val), NULL);
ensure(sectrue * (val == VERSION_MONOTONIC),
ensure(sectrue * (val == BOOTLOADER_MONOTONIC_VERSION),
"Bootloader downgrade protection");
}

View File

@ -1,3 +1,7 @@
#pragma once
#include "model_version.h"
#define VERSION_MAJOR 2
#define VERSION_MINOR 1
#define VERSION_PATCH 8
@ -10,9 +14,3 @@
#define FIX_VERSION_MINOR 0
#define FIX_VERSION_PATCH 0
#define FIX_VERSION_BUILD 0
#ifdef TREZOR_MODEL_R
#define VERSION_MONOTONIC 2
#else
#define VERSION_MONOTONIC 1
#endif

View File

@ -26,7 +26,7 @@ g_header:
.byte FIX_VERSION_BUILD // fix_vbuild
.word HW_MODEL // type of the designated hardware
.byte HW_REVISION // revision of the designated hardware
.byte VERSION_MONOTONIC // monotonic version
.byte BOOTLOADER_MONOTONIC_VERSION // monotonic version of the binary
. = . + 2 // reserved
. = . + 512 // hash1 ... hash16
. = . + 415 // reserved

View File

@ -1,3 +1,7 @@
#pragma once
#include "model_version.h"
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_PATCH 4
@ -10,5 +14,3 @@
#define FIX_VERSION_MINOR 0
#define FIX_VERSION_PATCH 0
#define FIX_VERSION_BUILD 0
#define VERSION_MONOTONIC 1

View File

@ -29,7 +29,7 @@ g_header:
.byte FIX_VERSION_BUILD // fix_vbuild
.word HW_MODEL // type of the designated hardware
.byte HW_REVISION // revision of the designated hardware
.byte VERSION_MONOTONIC // monotonic version of the binary
.byte FIRMWARE_MONOTONIC_VERSION // monotonic version of the binary
. = . + 2 // reserved
. = . + 512 // hash1 ... hash16

View File

@ -1,3 +1,7 @@
#pragma once
#include "model_version.h"
#define VERSION_MAJOR 2
#define VERSION_MINOR 8
#define VERSION_PATCH 2
@ -7,5 +11,3 @@
#define FIX_VERSION_MINOR 8
#define FIX_VERSION_PATCH 0
#define FIX_VERSION_BUILD 0
#define VERSION_MONOTONIC 1

View File

@ -0,0 +1,3 @@
#define BOOTLOADER_MONOTONIC_VERSION 1
#define FIRMWARE_MONOTONIC_VERSION 1

View File

@ -0,0 +1,3 @@
#define BOOTLOADER_MONOTONIC_VERSION 1
#define FIRMWARE_MONOTONIC_VERSION 1

View File

@ -0,0 +1,3 @@
#define BOOTLOADER_MONOTONIC_VERSION 1
#define FIRMWARE_MONOTONIC_VERSION 1

View File

@ -0,0 +1,3 @@
#define BOOTLOADER_MONOTONIC_VERSION 2
#define FIRMWARE_MONOTONIC_VERSION 1

View File

@ -0,0 +1,3 @@
#define BOOTLOADER_MONOTONIC_VERSION 1
#define FIRMWARE_MONOTONIC_VERSION 1

View File

@ -0,0 +1,3 @@
#define BOOTLOADER_MONOTONIC_VERSION 1
#define FIRMWARE_MONOTONIC_VERSION 1

View File

@ -0,0 +1,3 @@
#define BOOTLOADER_MONOTONIC_VERSION 1
#define FIRMWARE_MONOTONIC_VERSION 1

View File

@ -0,0 +1,22 @@
#ifndef MODELS_MODEL_H_
#define MODELS_MODEL_H_
#if defined TREZOR_MODEL_1
#include "T1B1/versions.h"
#elif defined TREZOR_MODEL_T
#include "T2T1/versions.h"
#elif defined TREZOR_MODEL_R
#include "T2B1/versions.h"
#elif defined TREZOR_MODEL_T3T1
#include "T3T1/versions.h"
#elif defined TREZOR_MODEL_T3B1
#include "T3B1/versions.h"
#elif defined TREZOR_MODEL_DISC1
#include "D001/versions.h"
#elif defined TREZOR_MODEL_DISC2
#include "D002/versions.h"
#else
#error Unknown Trezor model
#endif
#endif

View File

@ -26,7 +26,7 @@ g_header:
.byte FIX_VERSION_BUILD // fix_vbuild
.word HW_MODEL // type of the designated hardware
.byte HW_REVISION // revision of the designated hardware
.byte VERSION_MONOTONIC // monotonic version of the binary
.byte FIRMWARE_MONOTONIC_VERSION // monotonic version of the binary
. = . + 2 // reserved
. = . + 512 // hash1 ... hash16
. = . + 415 // reserved

View File

@ -1,3 +1,7 @@
#pragma once
#include "model_version.h"
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 9
@ -7,5 +11,3 @@
#define FIX_VERSION_MINOR 2
#define FIX_VERSION_PATCH 0
#define FIX_VERSION_BUILD 0
#define VERSION_MONOTONIC 1

View File

@ -26,7 +26,7 @@ g_header:
.byte FIX_VERSION_BUILD // fix_vbuild
.word HW_MODEL // type of the designated hardware
.byte HW_REVISION // revision of the designated hardware
.byte VERSION_MONOTONIC // monotonic version of the binary
.byte FIRMWARE_MONOTONIC_VERSION // monotonic version of the binary
. = . + 2 // reserved
. = . + 512 // hash1 ... hash16
. = . + 415 // reserved

View File

@ -1,3 +1,7 @@
#pragma once
#include "model_version.h"
#define VERSION_MAJOR 0
#define VERSION_MINOR 1
#define VERSION_PATCH 0
@ -7,5 +11,3 @@
#define FIX_VERSION_MINOR 1
#define FIX_VERSION_PATCH 0
#define FIX_VERSION_BUILD 0
#define VERSION_MONOTONIC 1