1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

refactor(core): inject full model name from build script

so that we don't have to do awkward string operations when we need it

[no changelog]
This commit is contained in:
matejcik 2023-09-29 12:25:38 +02:00 committed by matejcik
parent b07f4d938a
commit c892d4b0ba
7 changed files with 15 additions and 1 deletions

View File

@ -281,6 +281,12 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorutils_bootloader_locked_obj,
STATIC mp_obj_str_t mod_trezorutils_revision_obj = { STATIC mp_obj_str_t mod_trezorutils_revision_obj = {
{&mp_type_bytes}, 0, sizeof(SCM_REVISION) - 1, (const byte *)SCM_REVISION}; {&mp_type_bytes}, 0, sizeof(SCM_REVISION) - 1, (const byte *)SCM_REVISION};
STATIC mp_obj_str_t mod_trezorutils_full_name_obj = {
{&mp_type_str},
0,
sizeof(MODEL_FULL_NAME) - 1,
(const byte *)MODEL_FULL_NAME};
/// SCM_REVISION: bytes /// SCM_REVISION: bytes
/// VERSION_MAJOR: int /// VERSION_MAJOR: int
/// VERSION_MINOR: int /// VERSION_MINOR: int
@ -289,6 +295,7 @@ STATIC mp_obj_str_t mod_trezorutils_revision_obj = {
/// USE_BACKLIGHT: bool /// USE_BACKLIGHT: bool
/// USE_OPTIGA: bool /// USE_OPTIGA: bool
/// MODEL: str /// MODEL: str
/// MODEL_FULL_NAME: str
/// INTERNAL_MODEL: str /// INTERNAL_MODEL: str
/// EMULATOR: bool /// EMULATOR: bool
/// BITCOIN_ONLY: bool /// BITCOIN_ONLY: bool
@ -333,6 +340,8 @@ STATIC const mp_rom_map_elem_t mp_module_trezorutils_globals_table[] = {
{MP_ROM_QSTR(MP_QSTR_USE_OPTIGA), mp_const_false}, {MP_ROM_QSTR(MP_QSTR_USE_OPTIGA), mp_const_false},
#endif #endif
{MP_ROM_QSTR(MP_QSTR_MODEL), MP_ROM_QSTR(MODEL_NAME_QSTR)}, {MP_ROM_QSTR(MP_QSTR_MODEL), MP_ROM_QSTR(MODEL_NAME_QSTR)},
{MP_ROM_QSTR(MP_QSTR_MODEL_FULL_NAME),
MP_ROM_PTR(&mod_trezorutils_full_name_obj)},
{MP_ROM_QSTR(MP_QSTR_INTERNAL_MODEL), {MP_ROM_QSTR(MP_QSTR_INTERNAL_MODEL),
MP_ROM_QSTR(MODEL_INTERNAL_NAME_QSTR)}, MP_ROM_QSTR(MODEL_INTERNAL_NAME_QSTR)},
#ifdef TREZOR_EMULATOR #ifdef TREZOR_EMULATOR

View File

@ -2,6 +2,7 @@
#define MODELS_MODEL_D001_H_ #define MODELS_MODEL_D001_H_
#define MODEL_NAME "T" #define MODEL_NAME "T"
#define MODEL_FULL_NAME "Trezor Model T"
#define MODEL_INTERNAL_NAME "D001" #define MODEL_INTERNAL_NAME "D001"
#define MODEL_INTERNAL_NAME_TOKEN T #define MODEL_INTERNAL_NAME_TOKEN T
#define MODEL_NAME_QSTR MP_QSTR_T #define MODEL_NAME_QSTR MP_QSTR_T

View File

@ -2,6 +2,7 @@
#define MODELS_MODEL_T1B1_H_ #define MODELS_MODEL_T1B1_H_
#define MODEL_NAME "1" #define MODEL_NAME "1"
#define MODEL_FULL_NAME "Trezor Model One"
#define MODEL_INTERNAL_NAME "T1B1" #define MODEL_INTERNAL_NAME "T1B1"
#define MODEL_INTERNAL_NAME_TOKEN T1B1 #define MODEL_INTERNAL_NAME_TOKEN T1B1
#define MODEL_NAME_QSTR MP_QSTR_1 #define MODEL_NAME_QSTR MP_QSTR_1

View File

@ -2,6 +2,7 @@
#define MODELS_MODEL_T2B1_H_ #define MODELS_MODEL_T2B1_H_
#define MODEL_NAME "R" #define MODEL_NAME "R"
#define MODEL_FULL_NAME "Trezor Model R"
#define MODEL_INTERNAL_NAME "T2B1" #define MODEL_INTERNAL_NAME "T2B1"
#define MODEL_INTERNAL_NAME_TOKEN T2B1 #define MODEL_INTERNAL_NAME_TOKEN T2B1
#define MODEL_NAME_QSTR MP_QSTR_R #define MODEL_NAME_QSTR MP_QSTR_R

View File

@ -2,6 +2,7 @@
#define MODELS_MODEL_T2T1_H_ #define MODELS_MODEL_T2T1_H_
#define MODEL_NAME "T" #define MODEL_NAME "T"
#define MODEL_FULL_NAME "Trezor Model T"
#define MODEL_INTERNAL_NAME "T2T1" #define MODEL_INTERNAL_NAME "T2T1"
#define MODEL_INTERNAL_NAME_TOKEN T2T1 #define MODEL_INTERNAL_NAME_TOKEN T2T1
#define MODEL_NAME_QSTR MP_QSTR_T #define MODEL_NAME_QSTR MP_QSTR_T

View File

@ -19,7 +19,7 @@ async def homescreen() -> None:
if storage.device.is_initialized(): if storage.device.is_initialized():
label = storage.device.get_label() label = storage.device.get_label()
else: else:
label = f"Trezor Model {utils.MODEL}" label = utils.MODEL_FULL_NAME
notification = None notification = None
notification_is_error = False notification_is_error = False

View File

@ -5,6 +5,7 @@ from trezorutils import ( # noqa: F401
EMULATOR, EMULATOR,
INTERNAL_MODEL, INTERNAL_MODEL,
MODEL, MODEL,
MODEL_FULL_NAME,
SCM_REVISION, SCM_REVISION,
UI_LAYOUT, UI_LAYOUT,
USE_BACKLIGHT, USE_BACKLIGHT,