fix(core): unify Features.revision reporting with legacy

pull/1629/head
Pavol Rusnak 3 years ago committed by matejcik
parent 00d4b0a4a9
commit 23aa69caea

@ -0,0 +1 @@
Unify Features.revision reporting with legacy

@ -42,8 +42,7 @@ FIRMWARE_P1_MAXSIZE = 786432
FIRMWARE_P2_MAXSIZE = 917504
FIRMWARE_MAXSIZE = 1703936
GITREV=$(shell git describe --always --dirty | tr '-' '_')
CFLAGS += -DGITREV=$(GITREV)
CFLAGS += -DSCM_REVISION='\"$(shell git rev-parse HEAD | sed 's:\(..\):\\x\1:g')\"'
TESTPATH = $(CURDIR)/../tests

@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "py/objstr.h"
#include "py/runtime.h"
#include "version.h"
@ -115,10 +116,13 @@ STATIC mp_obj_t mod_trezorutils_halt(size_t n_args, const mp_obj_t *args) {
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorutils_halt_obj, 0, 1,
mod_trezorutils_halt);
STATIC mp_obj_str_t mod_trezorutils_revision_obj = {
{&mp_type_bytes}, 0, sizeof(SCM_REVISION) - 1, (const byte *)SCM_REVISION};
#define PASTER(s) MP_QSTR_##s
#define MP_QSTR(s) PASTER(s)
/// GITREV: str
/// SCM_REVISION: bytes
/// VERSION_MAJOR: int
/// VERSION_MINOR: int
/// VERSION_PATCH: int
@ -132,7 +136,8 @@ STATIC const mp_rom_map_elem_t mp_module_trezorutils_globals_table[] = {
{MP_ROM_QSTR(MP_QSTR_memcpy), MP_ROM_PTR(&mod_trezorutils_memcpy_obj)},
{MP_ROM_QSTR(MP_QSTR_halt), MP_ROM_PTR(&mod_trezorutils_halt_obj)},
// various built-in constants
{MP_ROM_QSTR(MP_QSTR_GITREV), MP_ROM_QSTR(MP_QSTR(GITREV))},
{MP_ROM_QSTR(MP_QSTR_SCM_REVISION),
MP_ROM_PTR(&mod_trezorutils_revision_obj)},
{MP_ROM_QSTR(MP_QSTR_VERSION_MAJOR), MP_ROM_INT(VERSION_MAJOR)},
{MP_ROM_QSTR(MP_QSTR_VERSION_MINOR), MP_ROM_INT(VERSION_MINOR)},
{MP_ROM_QSTR(MP_QSTR_VERSION_PATCH), MP_ROM_INT(VERSION_PATCH)},

@ -52,8 +52,10 @@ __fatal_error(const char *expr, const char *msg, const char *file, int line,
if (func) {
display_printf("func: %s\n", func);
}
#ifdef GITREV
display_printf("rev : %s\n", XSTR(GITREV));
#ifdef SCM_REVISION
const uint8_t *rev = (const uint8_t *)SCM_REVISION;
display_printf("rev : %02x%02x%02x%02x%02x\n", rev[0], rev[1], rev[2], rev[3],
rev[4]);
#endif
display_printf("\nPlease contact Trezor support.\n");
shutdown();

@ -24,9 +24,6 @@
#include <stdint.h>
#include "secbool.h"
#define XSTR(s) STR(s)
#define STR(s) #s
#ifndef MIN_8bits
#define MIN_8bits(a, b) \
({ \

@ -58,9 +58,12 @@ __fatal_error(const char *expr, const char *msg, const char *file, int line,
display_printf("func: %s\n", func);
printf("func: %s\n", func);
}
#ifdef GITREV
display_printf("rev : %s\n", XSTR(GITREV));
printf("rev : %s\n", XSTR(GITREV));
#ifdef SCM_REVISION
const uint8_t *rev = (const uint8_t *)SCM_REVISION;
display_printf("rev : %02x%02x%02x%02x%02x\n", rev[0], rev[1], rev[2], rev[3],
rev[4]);
printf("rev : %02x%02x%02x%02x%02x\n", rev[0], rev[1], rev[2], rev[3],
rev[4]);
#endif
display_printf("\n\n\nHint:\nIsn't the emulator already running?\n");
printf("Hint:\nIsn't the emulator already running?\n");

@ -23,9 +23,6 @@
#include <stdint.h>
#include "secbool.h"
#define XSTR(s) STR(s)
#define STR(s) #s
#ifndef MIN
#define MIN(a, b) \
({ \

@ -32,7 +32,7 @@ def halt(msg: str | None = None) -> None:
"""
Halts execution.
"""
GITREV: str
SCM_REVISION: bytes
VERSION_MAJOR: int
VERSION_MINOR: int
VERSION_PATCH: int

@ -36,7 +36,7 @@ def get_features() -> Features:
major_version=utils.VERSION_MAJOR,
minor_version=utils.VERSION_MINOR,
patch_version=utils.VERSION_PATCH,
revision=utils.GITREV.encode(),
revision=utils.SCM_REVISION,
model=utils.MODEL,
device_id=storage.device.get_device_id(),
label=storage.device.get_label(),

@ -3,8 +3,8 @@ import sys
from trezorutils import ( # noqa: F401
BITCOIN_ONLY,
EMULATOR,
GITREV,
MODEL,
SCM_REVISION,
VERSION_MAJOR,
VERSION_MINOR,
VERSION_PATCH,

Loading…
Cancel
Save