From 6fc8d67f39f8e04560e2f4607afa2de38e26f79f Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Wed, 21 Jun 2023 15:27:19 +0200 Subject: [PATCH] feat(core): add emulator support for T3W1 [no changelog] --- core/SConscript.unix | 10 +++++++--- core/embed/trezorhal/unix/display-unix.c | 8 +++++++- core/embed/trezorhal/unix/display-unix.h | 8 ++++++++ core/embed/trezorhal/unix/flash.c | 3 ++- core/embed/unix/common.h | 0 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 core/embed/unix/common.h diff --git a/core/SConscript.unix b/core/SConscript.unix index f386543f1..808d93c81 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -7,7 +7,7 @@ import tools BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0') EVERYTHING = BITCOIN_ONLY != '1' TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') -DMA2D = TREZOR_MODEL in ('T', ) +DMA2D = TREZOR_MODEL in ('T', 'T3W1') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) if TREZOR_MODEL in ('DISC1', ): @@ -174,7 +174,7 @@ if FEATURE_FLAGS["SECP256K1_ZKP"]: SOURCE_MOD += [ 'embed/extmod/modtrezorio/modtrezorio.c', ] -if TREZOR_MODEL in ('T',): +if TREZOR_MODEL in ('T', 'T3W1'): SOURCE_MOD += [ 'embed/extmod/modtrezorio/ff.c', 'embed/extmod/modtrezorio/ffunicode.c', @@ -778,9 +778,13 @@ def cargo_build(): if DMA2D: features.append('dma2d') - if TREZOR_MODEL in ('T', 'T3W1'): + if TREZOR_MODEL in ('T'): features.append('touch') features.append('sd_card') + if TREZOR_MODEL in ('T3W1'): + features.append('touch') + features.append('button') + features.append('sd_card') if TREZOR_MODEL in ('R', '1'): features.append('button') diff --git a/core/embed/trezorhal/unix/display-unix.c b/core/embed/trezorhal/unix/display-unix.c index 86b26e514..49d1fbb78 100644 --- a/core/embed/trezorhal/unix/display-unix.c +++ b/core/embed/trezorhal/unix/display-unix.c @@ -57,6 +57,11 @@ #define TOUCH_OFFSET_X 36 #define TOUCH_OFFSET_Y 92 +#elif defined TREZOR_MODEL_T3W1 +#define WINDOW_WIDTH 400 +#define WINDOW_HEIGHT 600 +#define TOUCH_OFFSET_X 80 +#define TOUCH_OFFSET_Y 110 #else #error Unknown Trezor model #endif @@ -275,7 +280,8 @@ int display_orientation(int degrees) { if (degrees != DISPLAY_ORIENTATION) { #if defined TREZOR_MODEL_T if (degrees == 0 || degrees == 90 || degrees == 180 || degrees == 270) { -#elif defined TREZOR_MODEL_1 || defined TREZOR_MODEL_R +#elif defined TREZOR_MODEL_1 || defined TREZOR_MODEL_R || \ + defined TREZOR_MODEL_T3W1 if (degrees == 0 || degrees == 180) { #else #error Unknown Trezor model diff --git a/core/embed/trezorhal/unix/display-unix.h b/core/embed/trezorhal/unix/display-unix.h index d6cf2cc6b..13492d0a0 100644 --- a/core/embed/trezorhal/unix/display-unix.h +++ b/core/embed/trezorhal/unix/display-unix.h @@ -3,6 +3,14 @@ #include +#ifdef TREZOR_MODEL_T3W1 +#define MAX_DISPLAY_RESX 240 +#define MAX_DISPLAY_RESY 320 +#define DISPLAY_RESX 240 +#define DISPLAY_RESY 320 +#define TREZOR_FONT_BPP 4 +#endif + #ifdef TREZOR_MODEL_T // ILI9341V, GC9307 and ST7789V drivers support 240px x 320px display resolution #define MAX_DISPLAY_RESX 240 diff --git a/core/embed/trezorhal/unix/flash.c b/core/embed/trezorhal/unix/flash.c index c423addd3..ab9fa7f3f 100644 --- a/core/embed/trezorhal/unix/flash.c +++ b/core/embed/trezorhal/unix/flash.c @@ -56,7 +56,8 @@ static const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = { [9] = 0x080A0000, // - 0x080BFFFF | 128 KiB [10] = 0x080C0000, // - 0x080DFFFF | 128 KiB [11] = 0x080E0000, // - 0x080FFFFF | 128 KiB -#if defined TREZOR_MODEL_T || defined TREZOR_MODEL_R +#if defined TREZOR_MODEL_T || defined TREZOR_MODEL_R || \ + defined TREZOR_MODEL_T3W1 [12] = 0x08100000, // - 0x08103FFF | 16 KiB [13] = 0x08104000, // - 0x08107FFF | 16 KiB [14] = 0x08108000, // - 0x0810BFFF | 16 KiB diff --git a/core/embed/unix/common.h b/core/embed/unix/common.h new file mode 100644 index 000000000..e69de29bb