mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-20 21:48:14 +00:00
display logo on firmware boot
This commit is contained in:
parent
c53177fe89
commit
1d69ca4929
@ -50,6 +50,7 @@
|
|||||||
#if defined TREZOR_MODEL_R || defined TREZOR_MODEL_1
|
#if defined TREZOR_MODEL_R || defined TREZOR_MODEL_1
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "rust_ui.h"
|
||||||
|
|
||||||
#ifdef SYSTEM_VIEW
|
#ifdef SYSTEM_VIEW
|
||||||
#include "systemview.h"
|
#include "systemview.h"
|
||||||
@ -125,6 +126,8 @@ int main(void) {
|
|||||||
ensure(sectrue * (zkp_context_init() == 0), NULL);
|
ensure(sectrue * (zkp_context_init() == 0), NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
boot_firmware(0);
|
||||||
|
|
||||||
printf("CORE: Preparing stack\n");
|
printf("CORE: Preparing stack\n");
|
||||||
// Stack limit should be less than real stack size, so we have a chance
|
// Stack limit should be less than real stack size, so we have a chance
|
||||||
// to recover from limit hit.
|
// to recover from limit hit.
|
||||||
|
3
core/embed/rust/rust_ui.h
Normal file
3
core/embed/rust/rust_ui.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
void boot_firmware(uint16_t stage);
|
14
core/embed/rust/src/boot/mod.rs
Normal file
14
core/embed/rust/src/boot/mod.rs
Normal file
@ -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);
|
||||||
|
}
|
@ -20,6 +20,7 @@ mod trace;
|
|||||||
#[cfg(feature = "ui")]
|
#[cfg(feature = "ui")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
|
pub mod boot;
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
|
BIN
core/embed/rust/src/ui/model_tt/res/trezor_empty.toif
Normal file
BIN
core/embed/rust/src/ui/model_tt/res/trezor_empty.toif
Normal file
Binary file not shown.
@ -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_BACK: &[u8] = include_res!("model_tt/res/back.toif");
|
||||||
pub const ICON_CLICK: &[u8] = include_res!("model_tt/res/click.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_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.
|
// Large, color icons.
|
||||||
pub const IMAGE_WARN: &[u8] = include_res!("model_tt/res/warn.toif");
|
pub const IMAGE_WARN: &[u8] = include_res!("model_tt/res/warn.toif");
|
||||||
|
@ -72,6 +72,14 @@ def _from_pil_grayscale(pixels: Sequence[int]) -> bytes:
|
|||||||
data += struct.pack(">B", c)
|
data += struct.pack(">B", c)
|
||||||
return bytes(data)
|
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:
|
def _to_grayscale(data: bytes) -> bytes:
|
||||||
res = bytearray()
|
res = bytearray()
|
||||||
@ -161,6 +169,11 @@ def from_image(
|
|||||||
if image.size[0] % 2 != 0:
|
if image.size[0] % 2 != 0:
|
||||||
raise ValueError("Only even-width grayscale images are supported")
|
raise ValueError("Only even-width grayscale images are supported")
|
||||||
toif_data = _from_pil_grayscale(image.getdata())
|
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":
|
elif image.mode == "RGB":
|
||||||
toif_mode = firmware.ToifMode.full_color
|
toif_mode = firmware.ToifMode.full_color
|
||||||
toif_data = _from_pil_rgb(image.getdata())
|
toif_data = _from_pil_rgb(image.getdata())
|
||||||
|
Loading…
Reference in New Issue
Block a user