diff --git a/core/Makefile b/core/Makefile index ffb8893aa5..0107f0cb94 100644 --- a/core/Makefile +++ b/core/Makefile @@ -33,6 +33,7 @@ BOOTLOADER_QA ?= 0 BOOTLOADER_DEVEL ?= 0 DISABLE_OPTIGA ?= 0 TREZOR_MODEL ?= T +UI_LINCOLN_DEV ?= 0 TREZOR_MEMPERF ?= 0 ADDRESS_SANITIZER ?= 0 CMAKELISTS ?= 0 @@ -69,7 +70,12 @@ MODEL_FEATURE = model_tr else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),T3W1)) MCU = STM32U5 OPENOCD_TARGET = target/stm32u5x.cfg +# model_tt by default so far, lincoln if requested +ifeq ($(UI_LINCOLN_DEV),1) +MODEL_FEATURE = model_lincoln +else MODEL_FEATURE = model_tt +endif else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),DISC1)) MCU = STM32F4 OPENOCD_TARGET = target/stm32f4x.cfg @@ -151,7 +157,8 @@ 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)" \ + UI_LINCOLN_DEV="$(UI_LINCOLN_DEV)" SCONS_OPTS = -Q -j $(JOBS) ifeq ($(QUIET_MODE),1) diff --git a/core/embed/rust/Cargo.toml b/core/embed/rust/Cargo.toml index 83ecdc4b6e..25f15deda2 100644 --- a/core/embed/rust/Cargo.toml +++ b/core/embed/rust/Cargo.toml @@ -11,6 +11,7 @@ crypto = ["zeroize"] model_tt = ["jpeg"] model_tr = [] model_mercury = ["jpeg", "dma2d"] +model_lincoln = ["jpeg", "dma2d"] micropython = [] protobuf = ["micropython"] ui = [] diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs index 83e4022894..d93f1674b8 100644 --- a/core/embed/rust/build.rs +++ b/core/embed/rust/build.rs @@ -86,12 +86,24 @@ const DEFAULT_BINDGEN_MACROS_T3T1: &[&str] = &[ #[cfg(not(feature = "model_mercury"))] const DEFAULT_BINDGEN_MACROS_T3T1: &[&str] = &[]; +#[cfg(feature = "model_lincoln")] +const DEFAULT_BINDGEN_MACROS_T3W1: &[&str] = &[ + "-DSTM32U5", + "-DTREZOR_MODEL_T3W1", + "-DFLASH_BIT_ACCESS=0", // FIXME: fill in correct value + "-DFLASH_BLOCK_WORDS=4", + "-DTREZOR_BOARD=\"T3W1/boards/t3w1-unix.h\"", +]; +#[cfg(not(feature = "model_lincoln"))] +const DEFAULT_BINDGEN_MACROS_T3W1: &[&str] = &[]; + fn add_bindgen_macros<'a>(clang_args: &mut Vec<&'a str>, envvar: Option<&'a str>) { let default_macros = DEFAULT_BINDGEN_MACROS_COMMON .iter() .chain(DEFAULT_BINDGEN_MACROS_T2T1) .chain(DEFAULT_BINDGEN_MACROS_T2B1) - .chain(DEFAULT_BINDGEN_MACROS_T3T1); + .chain(DEFAULT_BINDGEN_MACROS_T3T1) + .chain(DEFAULT_BINDGEN_MACROS_T3W1); match envvar { Some(envvar) => clang_args.extend(envvar.split(',')), diff --git a/core/embed/rust/src/ui/constant.rs b/core/embed/rust/src/ui/constant.rs index 3237db67aa..ba394d5f26 100644 --- a/core/embed/rust/src/ui/constant.rs +++ b/core/embed/rust/src/ui/constant.rs @@ -1,10 +1,14 @@ //! Reexporting the `constant` module according to the //! current feature (Trezor model) +#[cfg(all( + feature = "model_lincoln", + not(any(feature = "model_mercury", feature = "model_tr", feature = "model_tt")) +))] +pub use super::model_lincoln::constant::*; #[cfg(all( feature = "model_mercury", - not(feature = "model_tr"), - not(feature = "model_tt") + not(any(feature = "model_tr", feature = "model_tt"),) ))] pub use super::model_mercury::constant::*; #[cfg(all(feature = "model_tr", not(feature = "model_tt")))] 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/mod.rs b/core/embed/rust/src/ui/mod.rs index 6ed81d9f91..4a06409d7a 100644 --- a/core/embed/rust/src/ui/mod.rs +++ b/core/embed/rust/src/ui/mod.rs @@ -17,6 +17,8 @@ pub mod layout; mod api; +#[cfg(feature = "model_lincoln")] +pub mod model_lincoln; #[cfg(feature = "model_mercury")] pub mod model_mercury; #[cfg(feature = "model_tr")] @@ -32,10 +34,15 @@ pub mod ui_firmware; pub use ui_common::CommonUI; +#[cfg(all( + feature = "model_lincoln", + not(any(feature = "model_mercury", feature = "model_tr", feature = "model_tt")) +))] +pub type ModelUI = crate::ui::model_lincoln::UILincoln; + #[cfg(all( feature = "model_mercury", - not(feature = "model_tr"), - not(feature = "model_tt") + not(any(feature = "model_tr", feature = "model_tt")) ))] pub type ModelUI = crate::ui::model_mercury::UIMercury; diff --git a/core/embed/rust/src/ui/model_lincoln/bootloader/intro.rs b/core/embed/rust/src/ui/model_lincoln/bootloader/intro.rs new file mode 100644 index 0000000000..816b14c848 --- /dev/null +++ b/core/embed/rust/src/ui/model_lincoln/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