From 3479cdf4d1f51fcc1492c699342ffb3e1563c299 Mon Sep 17 00:00:00 2001 From: obrusvit Date: Thu, 19 Dec 2024 16:38:30 +0100 Subject: [PATCH] feat(eckhart): initial commit - build - directory structure - bootloader UI and assets copied from delizia - FirmwareUI trait functions are empty - Python layout functions are copied from delizia except some of more complicated ones which raise NotImplemented for now --- core/Makefile | 2 +- core/embed/models/T3W1/config.mk | 2 +- core/embed/rust/Cargo.toml | 1 + core/embed/rust/src/ui/constant.rs | 13 +- core/embed/rust/src/ui/geometry.rs | 4 + .../src/ui/layout_eckhart/bootloader/intro.rs | 113 ++ .../src/ui/layout_eckhart/bootloader/menu.rs | 111 ++ .../src/ui/layout_eckhart/bootloader/mod.rs | 477 ++++++++ .../ui/layout_eckhart/bootloader/welcome.rs | 67 ++ .../ui/layout_eckhart/component/bl_confirm.rs | 248 ++++ .../src/ui/layout_eckhart/component/button.rs | 468 +++++++ .../src/ui/layout_eckhart/component/error.rs | 94 ++ .../src/ui/layout_eckhart/component/mod.rs | 12 + .../src/ui/layout_eckhart/component/result.rs | 188 +++ .../component/welcome_screen.rs | 65 + .../ui/layout_eckhart/component_msg_obj.rs | 34 + .../rust/src/ui/layout_eckhart/constant.rs | 24 + .../src/ui/layout_eckhart/cshape/loader.rs | 40 + .../rust/src/ui/layout_eckhart/cshape/mod.rs | 3 + .../rust/src/ui/layout_eckhart/flow/mod.rs | 1 + core/embed/rust/src/ui/layout_eckhart/mod.rs | 72 ++ .../res/bootloader/check24.toif | Bin 0 -> 111 bytes .../res/bootloader/check40.toif | Bin 0 -> 87 bytes .../res/bootloader/download24.png | Bin 0 -> 233 bytes .../res/bootloader/download24.toif | Bin 0 -> 91 bytes .../layout_eckhart/res/bootloader/fire24.toif | Bin 0 -> 176 bytes .../layout_eckhart/res/bootloader/fire32.toif | Bin 0 -> 235 bytes .../layout_eckhart/res/bootloader/fire40.toif | Bin 0 -> 285 bytes .../layout_eckhart/res/bootloader/info32.toif | Bin 0 -> 217 bytes .../layout_eckhart/res/bootloader/menu32.toif | Bin 0 -> 29 bytes .../res/bootloader/refresh24.toif | Bin 0 -> 159 bytes .../res/bootloader/warning40.toif | Bin 0 -> 258 bytes .../ui/layout_eckhart/res/bootloader/x24.toif | Bin 0 -> 74 bytes .../ui/layout_eckhart/res/bootloader/x32.toif | Bin 0 -> 84 bytes .../src/ui/layout_eckhart/res/lock_full.toif | Bin 0 -> 419 bytes .../src/ui/layout_eckhart/res/warning40.toif | Bin 0 -> 258 bytes .../rust/src/ui/layout_eckhart/screens.rs | 32 + .../src/ui/layout_eckhart/theme/backlight.rs | 50 + .../src/ui/layout_eckhart/theme/bootloader.rs | 263 ++++ .../rust/src/ui/layout_eckhart/theme/mod.rs | 67 ++ .../rust/src/ui/layout_eckhart/ui_firmware.rs | 481 ++++++++ core/embed/rust/src/ui/mod.rs | 23 +- .../upymod/modtrezorutils/modtrezorutils.c | 2 + core/site_scons/models/T3W1/__init__.py | 2 +- .../site_tools/micropython/__init__.py | 2 + core/site_scons/ui/__init__.py | 3 +- core/site_scons/ui/ui_eckhart.py | 24 + core/src/all_modules.py | 8 + core/src/trezor/ui/layouts/__init__.py | 2 + .../src/trezor/ui/layouts/eckhart/__init__.py | 1071 +++++++++++++++++ core/src/trezor/ui/layouts/eckhart/fido.py | 54 + .../src/trezor/ui/layouts/eckhart/recovery.py | 147 +++ core/src/trezor/ui/layouts/eckhart/reset.py | 356 ++++++ core/src/trezor/ui/layouts/fido.py | 2 + core/src/trezor/ui/layouts/recovery.py | 2 + core/src/trezor/ui/layouts/reset.py | 2 + python/src/trezorlib/cli/firmware.py | 1 + python/src/trezorlib/debuglink.py | 2 + tests/click_tests/test_lock.py | 3 +- tests/conftest.py | 1 + tests/device_tests/test_firmware_hash.py | 1 + tests/device_tests/test_language.py | 1 + 62 files changed, 4625 insertions(+), 16 deletions(-) create mode 100644 core/embed/rust/src/ui/layout_eckhart/bootloader/intro.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/bootloader/menu.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/bootloader/mod.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/bootloader/welcome.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/component/bl_confirm.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/component/button.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/component/error.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/component/mod.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/component/result.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/component/welcome_screen.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/component_msg_obj.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/constant.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/cshape/loader.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/cshape/mod.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/flow/mod.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/mod.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/check24.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/check40.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/download24.png create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/download24.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/fire24.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/fire32.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/fire40.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/info32.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/menu32.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/refresh24.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/warning40.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/x24.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/bootloader/x32.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/lock_full.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/res/warning40.toif create mode 100644 core/embed/rust/src/ui/layout_eckhart/screens.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/theme/backlight.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/theme/bootloader.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/theme/mod.rs create mode 100644 core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs create mode 100644 core/site_scons/ui/ui_eckhart.py create mode 100644 core/src/trezor/ui/layouts/eckhart/__init__.py create mode 100644 core/src/trezor/ui/layouts/eckhart/fido.py create mode 100644 core/src/trezor/ui/layouts/eckhart/recovery.py create mode 100644 core/src/trezor/ui/layouts/eckhart/reset.py diff --git a/core/Makefile b/core/Makefile index 3bca1bb31d..4fdd7cb1df 100644 --- a/core/Makefile +++ b/core/Makefile @@ -131,7 +131,7 @@ SCONS_VARS = \ TREZOR_EMULATOR_ASAN="$(ADDRESS_SANITIZER)" \ TREZOR_EMULATOR_DEBUGGABLE=$(TREZOR_EMULATOR_DEBUGGABLE) \ TREZOR_MEMPERF="$(TREZOR_MEMPERF)" \ - TREZOR_MODEL="$(TREZOR_MODEL)" + TREZOR_MODEL="$(TREZOR_MODEL)" \ SCONS_OPTS = -Q -j $(JOBS) ifeq ($(QUIET_MODE),1) diff --git a/core/embed/models/T3W1/config.mk b/core/embed/models/T3W1/config.mk index 61898195f3..b4542990a9 100644 --- a/core/embed/models/T3W1/config.mk +++ b/core/embed/models/T3W1/config.mk @@ -1,3 +1,3 @@ MCU = STM32U5 OPENOCD_TARGET = target/stm32u5x.cfg -LAYOUT_FEATURE = layout_bolt +LAYOUT_FEATURE = layout_eckhart diff --git a/core/embed/rust/Cargo.toml b/core/embed/rust/Cargo.toml index 8db6885bb5..e6505cd2ff 100644 --- a/core/embed/rust/Cargo.toml +++ b/core/embed/rust/Cargo.toml @@ -11,6 +11,7 @@ crypto = ["zeroize"] layout_bolt = [] layout_caesar = [] layout_delizia = [] +layout_eckhart = [] micropython = [] protobuf = ["micropython"] ui = [] diff --git a/core/embed/rust/src/ui/constant.rs b/core/embed/rust/src/ui/constant.rs index 059e3bebb4..65b3e5d366 100644 --- a/core/embed/rust/src/ui/constant.rs +++ b/core/embed/rust/src/ui/constant.rs @@ -3,11 +3,18 @@ #[cfg(all( feature = "layout_bolt", + not(feature = "layout_caesar"), not(feature = "layout_delizia"), - not(feature = "layout_caesar") + not(feature = "layout_eckhart") ))] pub use super::layout_bolt::constant::*; -#[cfg(all(feature = "layout_caesar", not(feature = "layout_delizia")))] +#[cfg(all( + feature = "layout_caesar", + not(feature = "layout_delizia"), + not(feature = "layout_eckhart") +))] pub use super::layout_caesar::constant::*; -#[cfg(feature = "layout_delizia")] +#[cfg(all(feature = "layout_delizia", not(feature = "layout_eckhart")))] pub use super::layout_delizia::constant::*; +#[cfg(feature = "layout_eckhart")] +pub use super::layout_eckhart::constant::*; diff --git a/core/embed/rust/src/ui/geometry.rs b/core/embed/rust/src/ui/geometry.rs index dde44132e4..f753e02170 100644 --- a/core/embed/rust/src/ui/geometry.rs +++ b/core/embed/rust/src/ui/geometry.rs @@ -30,6 +30,10 @@ const fn clamp(x: i16, min: i16, max: i16) -> i16 { /// Relative offset in 2D space, used for representing translation and /// dimensions of objects. Absolute positions on the screen are represented by /// the `Point` type. +/// +/// Coordinate system orientation: +/// * x-axis: negative values go left, positive values go right +/// * y-axis: negative values go up, positive values go down #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct Offset { pub x: i16, diff --git a/core/embed/rust/src/ui/layout_eckhart/bootloader/intro.rs b/core/embed/rust/src/ui/layout_eckhart/bootloader/intro.rs new file mode 100644 index 0000000000..816b14c848 --- /dev/null +++ b/core/embed/rust/src/ui/layout_eckhart/bootloader/intro.rs @@ -0,0 +1,113 @@ +use crate::{ + strutil::TString, + ui::{ + component::{Child, Component, Event, EventCtx, Label, Pad}, + constant::screen, + display::Icon, + geometry::{Alignment, Insets, Point, Rect}, + shape::Renderer, + }, +}; + +use super::super::{ + component::{Button, ButtonMsg::Clicked}, + constant::WIDTH, + theme::bootloader::{ + button_bld, button_bld_menu, text_title, BLD_BG, BUTTON_AREA_START, BUTTON_HEIGHT, + CONTENT_PADDING, CORNER_BUTTON_AREA, MENU32, TEXT_NORMAL, TEXT_WARNING, TITLE_AREA, + }, +}; + +#[repr(u32)] +#[derive(Copy, Clone, ToPrimitive)] +pub enum IntroMsg { + Menu = 1, + Host = 2, +} + +pub struct Intro<'a> { + bg: Pad, + title: Child>, + menu: Child