From cf00726152b048f37cbf23df84f13298d496a2e2 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Sun, 7 Apr 2024 13:34:12 +0200 Subject: [PATCH] feat(core): copy T2T1 bootloader UI for T3T1 --- .github/workflows/core.yml | 2 +- core/SConscript.bootloader | 2 + core/SConscript.bootloader_emu | 2 + core/embed/rust/Cargo.toml | 1 + core/embed/rust/src/ui/constant.rs | 6 + core/embed/rust/src/ui/display/loader/mod.rs | 8 +- core/embed/rust/src/ui/mod.rs | 3 + .../src/ui/model_mercury/bootloader/intro.rs | 113 +++++ .../src/ui/model_mercury/bootloader/menu.rs | 117 +++++ .../src/ui/model_mercury/bootloader/mod.rs | 320 +++++++++++++ .../ui/model_mercury/bootloader/welcome.rs | 60 +++ .../ui/model_mercury/component/bl_confirm.rs | 254 ++++++++++ .../src/ui/model_mercury/component/button.rs | 440 ++++++++++++++++++ .../src/ui/model_mercury/component/error.rs | 92 ++++ .../src/ui/model_mercury/component/frame.rs | 204 ++++++++ .../src/ui/model_mercury/component/loader.rs | 253 ++++++++++ .../src/ui/model_mercury/component/mod.rs | 18 + .../src/ui/model_mercury/component/result.rs | 168 +++++++ .../model_mercury/component/welcome_screen.rs | 81 ++++ .../rust/src/ui/model_mercury/constant.rs | 22 + core/embed/rust/src/ui/model_mercury/mod.rs | 33 ++ .../ui/model_mercury/res/arrow-right16.toif | Bin 0 -> 51 bytes .../src/ui/model_mercury/res/caret-up24.toif | Bin 0 -> 67 bytes .../src/ui/model_mercury/res/check16.toif | Bin 0 -> 55 bytes .../src/ui/model_mercury/res/check24.toif | Bin 0 -> 71 bytes .../src/ui/model_mercury/res/check40.toif | Bin 0 -> 87 bytes .../src/ui/model_mercury/res/circle48.toif | Bin 0 -> 264 bytes .../ui/model_mercury/res/device_name_T.toif | Bin 0 -> 489 bytes .../src/ui/model_mercury/res/download32.toif | Bin 0 -> 107 bytes .../src/ui/model_mercury/res/fg-check48.toif | Bin 0 -> 84 bytes .../rust/src/ui/model_mercury/res/fire24.toif | Bin 0 -> 176 bytes .../rust/src/ui/model_mercury/res/fire32.toif | Bin 0 -> 235 bytes .../rust/src/ui/model_mercury/res/fire40.toif | Bin 0 -> 285 bytes .../rust/src/ui/model_mercury/res/info32.toif | Bin 0 -> 217 bytes .../rust/src/ui/model_mercury/res/lock24.toif | Bin 0 -> 77 bytes .../src/ui/model_mercury/res/lock_empty.toif | Bin 0 -> 546 bytes .../src/ui/model_mercury/res/lock_full.toif | Bin 0 -> 393 bytes .../rust/src/ui/model_mercury/res/menu32.toif | Bin 0 -> 29 bytes .../src/ui/model_mercury/res/page-next.toif | Bin 0 -> 64 bytes .../src/ui/model_mercury/res/page-prev.toif | Bin 0 -> 58 bytes .../src/ui/model_mercury/res/refresh24.toif | Bin 0 -> 159 bytes .../rust/src/ui/model_mercury/res/start.toif | Bin 0 -> 641 bytes .../src/ui/model_mercury/res/warning40.toif | Bin 0 -> 258 bytes .../rust/src/ui/model_mercury/res/x24.toif | Bin 0 -> 74 bytes .../rust/src/ui/model_mercury/res/x32.toif | Bin 0 -> 84 bytes .../rust/src/ui/model_mercury/screens.rs | 20 + .../src/ui/model_mercury/theme/bootloader.rs | 281 +++++++++++ .../rust/src/ui/model_mercury/theme/mod.rs | 190 ++++++++ core/embed/rust/src/ui/ui_features.rs | 7 + 49 files changed, 2692 insertions(+), 5 deletions(-) create mode 100644 core/embed/rust/src/ui/model_mercury/bootloader/intro.rs create mode 100644 core/embed/rust/src/ui/model_mercury/bootloader/menu.rs create mode 100644 core/embed/rust/src/ui/model_mercury/bootloader/mod.rs create mode 100644 core/embed/rust/src/ui/model_mercury/bootloader/welcome.rs create mode 100644 core/embed/rust/src/ui/model_mercury/component/bl_confirm.rs create mode 100644 core/embed/rust/src/ui/model_mercury/component/button.rs create mode 100644 core/embed/rust/src/ui/model_mercury/component/error.rs create mode 100644 core/embed/rust/src/ui/model_mercury/component/frame.rs create mode 100644 core/embed/rust/src/ui/model_mercury/component/loader.rs create mode 100644 core/embed/rust/src/ui/model_mercury/component/mod.rs create mode 100644 core/embed/rust/src/ui/model_mercury/component/result.rs create mode 100644 core/embed/rust/src/ui/model_mercury/component/welcome_screen.rs create mode 100644 core/embed/rust/src/ui/model_mercury/constant.rs create mode 100644 core/embed/rust/src/ui/model_mercury/mod.rs create mode 100644 core/embed/rust/src/ui/model_mercury/res/arrow-right16.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/caret-up24.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/check16.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/check24.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/check40.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/circle48.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/device_name_T.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/download32.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/fg-check48.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/fire24.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/fire32.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/fire40.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/info32.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/lock24.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/lock_empty.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/lock_full.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/menu32.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/page-next.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/page-prev.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/refresh24.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/start.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/warning40.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/x24.toif create mode 100644 core/embed/rust/src/ui/model_mercury/res/x32.toif create mode 100644 core/embed/rust/src/ui/model_mercury/screens.rs create mode 100644 core/embed/rust/src/ui/model_mercury/theme/bootloader.rs create mode 100644 core/embed/rust/src/ui/model_mercury/theme/mod.rs diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml index 282d32732..3e3670356 100644 --- a/.github/workflows/core.yml +++ b/.github/workflows/core.yml @@ -118,7 +118,7 @@ jobs: submodules: recursive - uses: ./.github/actions/environment - run: nix-shell --run "poetry run make -C core build_bootloader_emu" - if: matrix.coins == 'universal' && matrix.model != 'T3T1' # FIXME T3T1 bootloader emulator + if: matrix.coins == 'universal' - run: nix-shell --run "poetry run make -C core build_unix_frozen" - run: cp core/build/unix/trezor-emu-core core/build/unix/trezor-emu-core-${{ matrix.model }}-${{ matrix.coins }} - uses: actions/upload-artifact@v4 diff --git a/core/SConscript.bootloader b/core/SConscript.bootloader index ba4c944f9..eaaf8c3c8 100644 --- a/core/SConscript.bootloader +++ b/core/SConscript.bootloader @@ -220,6 +220,8 @@ def cargo_build(): features = ["model_t1"] elif TREZOR_MODEL in ("R",): features = ["model_tr"] + elif TREZOR_MODEL in ("T3T1",): + features = ["model_mercury"] else: features = ["model_tt"] features.append("ui") diff --git a/core/SConscript.bootloader_emu b/core/SConscript.bootloader_emu index eac3ce228..9471cbb89 100644 --- a/core/SConscript.bootloader_emu +++ b/core/SConscript.bootloader_emu @@ -274,6 +274,8 @@ def cargo_build(): features = ["model_t1"] elif TREZOR_MODEL in ("R",): features = ["model_tr"] + elif TREZOR_MODEL in ("T3T1",): + features = ["model_mercury"] else: features = ["model_tt"] diff --git a/core/embed/rust/Cargo.toml b/core/embed/rust/Cargo.toml index bf10bf9db..2faab74a7 100644 --- a/core/embed/rust/Cargo.toml +++ b/core/embed/rust/Cargo.toml @@ -10,6 +10,7 @@ default = ["model_tt"] crypto = ["zeroize"] model_tt = ["jpeg"] model_tr = [] +model_mercury = ["jpeg", "dma2d"] micropython = [] protobuf = ["micropython"] ui = [] diff --git a/core/embed/rust/src/ui/constant.rs b/core/embed/rust/src/ui/constant.rs index 91fd83f70..3237db67a 100644 --- a/core/embed/rust/src/ui/constant.rs +++ b/core/embed/rust/src/ui/constant.rs @@ -1,6 +1,12 @@ //! Reexporting the `constant` module according to the //! current feature (Trezor model) +#[cfg(all( + feature = "model_mercury", + not(feature = "model_tr"), + not(feature = "model_tt") +))] +pub use super::model_mercury::constant::*; #[cfg(all(feature = "model_tr", not(feature = "model_tt")))] pub use super::model_tr::constant::*; #[cfg(feature = "model_tt")] diff --git a/core/embed/rust/src/ui/display/loader/mod.rs b/core/embed/rust/src/ui/display/loader/mod.rs index f87ff791e..3b780a57d 100644 --- a/core/embed/rust/src/ui/display/loader/mod.rs +++ b/core/embed/rust/src/ui/display/loader/mod.rs @@ -5,16 +5,16 @@ mod starry; use crate::ui::display::{Color, Icon}; -#[cfg(feature = "model_tt")] +#[cfg(any(feature = "model_tt", feature = "model_mercury"))] use crate::ui::display::loader::circular::{ loader_circular as determinate, loader_circular_indeterminate as indeterminate, }; -#[cfg(feature = "model_tt")] +#[cfg(any(feature = "model_tt", feature = "model_mercury"))] pub use crate::ui::display::loader::circular::{loader_circular_uncompress, LoaderDimensions}; -#[cfg(not(feature = "model_tt"))] +#[cfg(all(not(feature = "model_tt"), not(feature = "model_mercury")))] use crate::ui::display::loader::rectangular::loader_rectangular as determinate; -#[cfg(not(feature = "model_tt"))] +#[cfg(all(not(feature = "model_tt"), not(feature = "model_mercury")))] use crate::ui::display::loader::starry::loader_starry_indeterminate as indeterminate; pub use small::loader_small_indeterminate; diff --git a/core/embed/rust/src/ui/mod.rs b/core/embed/rust/src/ui/mod.rs index 9152755bc..fd8c51dac 100644 --- a/core/embed/rust/src/ui/mod.rs +++ b/core/embed/rust/src/ui/mod.rs @@ -14,6 +14,9 @@ pub mod util; pub mod layout; mod api; + +#[cfg(feature = "model_mercury")] +pub mod model_mercury; #[cfg(feature = "model_tr")] pub mod model_tr; #[cfg(feature = "model_tt")] diff --git a/core/embed/rust/src/ui/model_mercury/bootloader/intro.rs b/core/embed/rust/src/ui/model_mercury/bootloader/intro.rs new file mode 100644 index 000000000..91c8d9534 --- /dev/null +++ b/core/embed/rust/src/ui/model_mercury/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}, + }, +}; + +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