Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix gen and style problems #3379

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/.changelog.d/2919.added
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Support interaction-less upgrade
Support interaction-less upgrade
2 changes: 1 addition & 1 deletion core/embed/bootloader/.changelog.d/2919.added
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Support interaction-less upgrade
Support interaction-less upgrade
6 changes: 2 additions & 4 deletions core/embed/bootloader/boot_internal.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef BOOT_INTERNAL_H
#define BOOT_INTERNAL_H

#include <stdint.h>
#include <boot_args.h>
#include <stdint.h>

// The 'g_boot_command' variable stores the 'command' passed to the
// function 'svc_reboot_to_bootloader()'. It may be one of the
Expand All @@ -12,10 +12,8 @@
// just powered up. The variable is set before the main() is called.
extern boot_command_t g_boot_command;


// The 'g_boot_args' array stores extra arguments passed
// The 'g_boot_args' array stores extra arguments passed
// function 'svc_reboot_to_bootloader()'
extern uint8_t g_boot_args[BOOT_ARGS_SIZE];


#endif // BOOT_INTERNAL_H
1 change: 0 additions & 1 deletion core/embed/bootloader/emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ boot_command_t g_boot_command = BOOT_COMMAND_NONE;
// Simulation of a boot args normally sitting at the BOOT_ARGS region
uint8_t g_boot_args[BOOT_ARGS_SIZE];


void set_core_clock(int) {}

int bootloader_main(void);
Expand Down
2 changes: 1 addition & 1 deletion core/embed/bootloader/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ static uint32_t chunk_size = 0;

__attribute__((section(".buf"))) uint32_t chunk_buffer[IMAGE_CHUNK_SIZE / 4];

#define CHUNK_BUFFER_PTR ((const uint8_t *const) & chunk_buffer)
#define CHUNK_BUFFER_PTR ((const uint8_t *const)&chunk_buffer)

/* we don't use secbool/sectrue/secfalse here as it is a nanopb api */
static bool _read_payload(pb_istream_t *stream, const pb_field_t *field,
Expand Down
27 changes: 9 additions & 18 deletions core/embed/rust/src/ui/model_tt/bootloader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,16 @@ extern "C" fn screen_install_confirm(
(l, r)
};

let mut frame = Confirm::new(
BLD_BG,
left,
right,
let mut frame = Confirm::new(BLD_BG, left, right, ConfirmTitle::Text(title), msg).with_info(
"FW FINGERPRINT",
fingerprint_str,
button_bld_menu(),
ConfirmTitle::Text(title),
msg,
alert,
Some(("FW FINGERPRINT", fingerprint_str)),
);

if let Some(alert) = alert {
frame = frame.with_alert(alert);
}

run(&mut frame)
}

Expand All @@ -203,16 +202,8 @@ extern "C" fn screen_wipe_confirm() -> u32 {
let right = Button::with_text("RESET").styled(button_wipe_confirm());
let left = Button::with_text("CANCEL").styled(button_wipe_cancel());

let mut frame = Confirm::new(
BLD_WIPE_COLOR,
left,
right,
button_bld_menu(),
ConfirmTitle::Icon(icon),
msg,
Some(alert),
None,
);
let mut frame =
Confirm::new(BLD_WIPE_COLOR, left, right, ConfirmTitle::Icon(icon), msg).with_alert(alert);

run(&mut frame)
}
Expand Down
51 changes: 29 additions & 22 deletions core/embed/rust/src/ui/model_tt/component/bl_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,42 +64,49 @@ where
bg_color: Color,
left_button: Button<&'static str>,
right_button: Button<&'static str>,
menu_button: ButtonStyleSheet,
title: ConfirmTitle<T>,
message: Label<T>,
alert: Option<Label<T>>,
info: Option<(T, T)>,
) -> Self {
Self {
bg: Pad::with_background(bg_color).with_clear(),
content_pad: Pad::with_background(bg_color),
bg_color,
title,
message: Child::new(message.vertically_centered()),
alert: alert.map(|alert| Child::new(alert.vertically_centered())),
left_button: Child::new(left_button),
right_button: Child::new(right_button),
info: info.map(|(title, text)| ConfirmInfo {
title: Child::new(
Label::left_aligned(title, text_title(bg_color)).vertically_centered(),
),
text: Child::new(
Label::left_aligned(text, text_fingerprint(bg_color)).vertically_centered(),
),
info_button: Child::new(
Button::with_icon(Icon::new(INFO32))
.styled(menu_button)
.with_expanded_touch_area(Insets::uniform(CORNER_BUTTON_TOUCH_EXPANSION)),
),
close_button: Child::new(
Button::with_icon(Icon::new(X32))
.styled(menu_button)
.with_expanded_touch_area(Insets::uniform(CORNER_BUTTON_TOUCH_EXPANSION)),
),
}),
alert: None,
info: None,
show_info: false,
}
}

pub fn with_alert(mut self, alert: Label<T>) -> Self {
self.alert = Some(Child::new(alert.vertically_centered()));
self
}

pub fn with_info(mut self, title: T, text: T, menu_button: ButtonStyleSheet) -> Self {
self.info = Some(ConfirmInfo {
title: Child::new(
Label::left_aligned(title, text_title(self.bg_color)).vertically_centered(),
),
text: Child::new(
Label::left_aligned(text, text_fingerprint(self.bg_color)).vertically_centered(),
),
info_button: Child::new(
Button::with_icon(Icon::new(INFO32))
.styled(menu_button)
.with_expanded_touch_area(Insets::uniform(CORNER_BUTTON_TOUCH_EXPANSION)),
),
close_button: Child::new(
Button::with_icon(Icon::new(X32))
.styled(menu_button)
.with_expanded_touch_area(Insets::uniform(CORNER_BUTTON_TOUCH_EXPANSION)),
),
});
self
}
}

impl<T> Component for Confirm<T>
Expand Down
17 changes: 7 additions & 10 deletions core/embed/rust/src/ui/model_tt/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1616,16 +1616,13 @@ extern "C" fn new_confirm_firmware_update(
let left = Button::with_text("CANCEL").styled(theme::button_default());
let right = Button::with_text("INSTALL").styled(theme::button_confirm());

let obj = LayoutObj::new(Confirm::new(
theme::BG,
left,
right,
theme::button_moreinfo(),
ConfirmTitle::Text(title),
msg,
None,
Some(("FW FINGERPRINT".into(), fingerprint)),
))?;
let obj = LayoutObj::new(
Confirm::new(theme::BG, left, right, ConfirmTitle::Text(title), msg).with_info(
"FW FINGERPRINT".into(),
fingerprint,
theme::button_moreinfo(),
),
)?;
Ok(obj.into())
};
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
Expand Down
6 changes: 2 additions & 4 deletions core/embed/trezorhal/boot_args.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef TREZORHAL_BOOT_ARGS_H
#define TREZORHAL_BOOT_ARGS_H


// Defines boot command for 'svc_reboot_to_bootloader()' function
typedef enum {
// Normal boot sequence
Expand All @@ -12,9 +11,8 @@ typedef enum {
BOOT_COMMAND_INSTALL_UPGRADE = 0xFA4A5C8D,
} boot_command_t;

// Maximum size of extra arguments passed to
// Maximum size of extra arguments passed to
// 'svc_reboot_to_bootloader()' function
#define BOOT_ARGS_SIZE 256


#endif // TREZORHAL_BOOT_ARGS_H
#endif // TREZORHAL_BOOT_ARGS_H
2 changes: 0 additions & 2 deletions core/embed/trezorhal/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
})
#endif



void __attribute__((noreturn)) trezor_shutdown(void);

void __attribute__((noreturn))
Expand Down
2 changes: 0 additions & 2 deletions core/embed/trezorhal/stm32f4/supervise.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

#ifdef ARM_USER_MODE


// Saves extra parameters for the bootloader
static void _copy_boot_args(const void *args, size_t args_size) {

// symbols imported from the linker script
extern uint8_t boot_args_start;
extern uint8_t boot_args_end;
Expand Down
1 change: 0 additions & 1 deletion core/mocks/generated/trezorutils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def check_firmware_header(
Checks firmware image and vendor header and returns
{ "version": (major, minor, patch),
"vendor": string,
"full_trust": bool,
"fingerprint": bytes,
"hash": bytes
}
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/protob/messages-management.options
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ UnlockPath.mac max_size:32

UnlockedPathRequest.mac max_size:32

RebootToBootloader.firmware_header type:FT_IGNORE
RebootToBootloader.firmware_header type:FT_IGNORE
2 changes: 1 addition & 1 deletion python/.changelog.d/2919.added.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
trezorctl: Automatically go to bootloader when upgrading firmware
trezorctl: Automatically go to bootloader when upgrading firmware
Loading