diff --git a/core/embed/firmware/main.c b/core/embed/firmware/main.c index 147441c0b9..b69af45c47 100644 --- a/core/embed/firmware/main.c +++ b/core/embed/firmware/main.c @@ -50,6 +50,7 @@ #if defined TREZOR_MODEL_R || defined TREZOR_MODEL_1 #include "button.h" #endif +#include "rust_ui.h" #ifdef SYSTEM_VIEW #include "systemview.h" @@ -125,6 +126,8 @@ int main(void) { ensure(sectrue * (zkp_context_init() == 0), NULL); #endif + boot_firmware(0); + printf("CORE: Preparing stack\n"); // Stack limit should be less than real stack size, so we have a chance // to recover from limit hit. diff --git a/core/embed/rust/rust_ui.h b/core/embed/rust/rust_ui.h new file mode 100644 index 0000000000..d3807cd4fe --- /dev/null +++ b/core/embed/rust/rust_ui.h @@ -0,0 +1,3 @@ +#include "common.h" + +void boot_firmware(uint16_t stage); diff --git a/core/embed/rust/src/boot/mod.rs b/core/embed/rust/src/boot/mod.rs new file mode 100644 index 0000000000..1750f4de09 --- /dev/null +++ b/core/embed/rust/src/boot/mod.rs @@ -0,0 +1,14 @@ + + +use crate::ui::display::icon; +use crate::ui::model_tt::theme::{ICON_TREZOR_EMPTY, BLUE, BLACK, WHITE}; +use crate::ui::constant; + + +#[no_mangle] +pub extern "C" fn boot_firmware( + stage: cty::uint16_t +) { + + icon(constant::screen().center(), ICON_TREZOR_EMPTY, WHITE, BLACK); +} diff --git a/core/embed/rust/src/lib.rs b/core/embed/rust/src/lib.rs index 2f63df12b4..bbd87b6a71 100644 --- a/core/embed/rust/src/lib.rs +++ b/core/embed/rust/src/lib.rs @@ -20,6 +20,7 @@ mod trace; #[cfg(feature = "ui")] #[macro_use] pub mod ui; +pub mod boot; #[cfg(feature = "debug")] #[panic_handler] diff --git a/core/embed/rust/src/ui/model_tt/res/trezor_empty.toif b/core/embed/rust/src/ui/model_tt/res/trezor_empty.toif new file mode 100644 index 0000000000..8ac9aae443 Binary files /dev/null and b/core/embed/rust/src/ui/model_tt/res/trezor_empty.toif differ diff --git a/core/embed/rust/src/ui/model_tt/theme.rs b/core/embed/rust/src/ui/model_tt/theme.rs index 957992e815..c3c7816bed 100644 --- a/core/embed/rust/src/ui/model_tt/theme.rs +++ b/core/embed/rust/src/ui/model_tt/theme.rs @@ -55,6 +55,7 @@ pub const ICON_SPACE: &[u8] = include_res!("model_tt/res/space.toif"); pub const ICON_BACK: &[u8] = include_res!("model_tt/res/back.toif"); pub const ICON_CLICK: &[u8] = include_res!("model_tt/res/click.toif"); pub const ICON_NEXT: &[u8] = include_res!("model_tt/res/next.toif"); +pub const ICON_TREZOR_EMPTY: &[u8] = include_res!("model_tt/res/trezor_empty.toif"); // Large, color icons. pub const IMAGE_WARN: &[u8] = include_res!("model_tt/res/warn.toif"); diff --git a/python/src/trezorlib/toif.py b/python/src/trezorlib/toif.py index d1e50fd310..b576993432 100644 --- a/python/src/trezorlib/toif.py +++ b/python/src/trezorlib/toif.py @@ -72,6 +72,14 @@ def _from_pil_grayscale(pixels: Sequence[int]) -> bytes: data += struct.pack(">B", c) return bytes(data) +def _from_pil_grayscale_alpha(pixels: Sequence[int]) -> bytes: + data = bytearray() + for i in range(0, len(pixels), 2): + left, right = pixels[i], pixels[i + 1] + c = (left[1] & 0xF0) | ((right[1] & 0xF0) >> 4) + data += struct.pack(">B", c) + return bytes(data) + def _to_grayscale(data: bytes) -> bytes: res = bytearray() @@ -161,6 +169,11 @@ def from_image( if image.size[0] % 2 != 0: raise ValueError("Only even-width grayscale images are supported") toif_data = _from_pil_grayscale(image.getdata()) + elif image.mode == "LA": + toif_mode = firmware.ToifMode.grayscale + if image.size[0] % 2 != 0: + raise ValueError("Only even-width grayscale images are supported") + toif_data = _from_pil_grayscale_alpha(image.getdata()) elif image.mode == "RGB": toif_mode = firmware.ToifMode.full_color toif_data = _from_pil_rgb(image.getdata())