From c40bef41b739be459286f629dcefd18e637cacec Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Tue, 31 Oct 2023 10:34:54 +0100 Subject: [PATCH] chore(core): fix gen and style problems [no changelog] --- core/.changelog.d/2919.added | 2 +- core/embed/bootloader/.changelog.d/2919.added | 2 +- core/embed/bootloader/boot_internal.h | 6 +-- core/embed/bootloader/emulator.c | 1 - core/embed/bootloader/messages.c | 2 +- .../rust/src/ui/model_tt/bootloader/mod.rs | 27 ++++------ .../src/ui/model_tt/component/bl_confirm.rs | 51 +++++++++++-------- core/embed/rust/src/ui/model_tt/layout.rs | 17 +++---- core/embed/trezorhal/boot_args.h | 6 +-- core/embed/trezorhal/common.h | 2 - core/embed/trezorhal/stm32f4/supervise.c | 2 - core/mocks/generated/trezorutils.pyi | 1 - .../protob/messages-management.options | 2 +- python/.changelog.d/2919.added.2 | 2 +- 14 files changed, 54 insertions(+), 69 deletions(-) diff --git a/core/.changelog.d/2919.added b/core/.changelog.d/2919.added index 708f3fe44d2..a3bd005bab7 100644 --- a/core/.changelog.d/2919.added +++ b/core/.changelog.d/2919.added @@ -1 +1 @@ -Support interaction-less upgrade \ No newline at end of file +Support interaction-less upgrade diff --git a/core/embed/bootloader/.changelog.d/2919.added b/core/embed/bootloader/.changelog.d/2919.added index 708f3fe44d2..a3bd005bab7 100644 --- a/core/embed/bootloader/.changelog.d/2919.added +++ b/core/embed/bootloader/.changelog.d/2919.added @@ -1 +1 @@ -Support interaction-less upgrade \ No newline at end of file +Support interaction-less upgrade diff --git a/core/embed/bootloader/boot_internal.h b/core/embed/bootloader/boot_internal.h index 74fb1541afa..b5890382b38 100644 --- a/core/embed/bootloader/boot_internal.h +++ b/core/embed/bootloader/boot_internal.h @@ -1,8 +1,8 @@ #ifndef BOOT_INTERNAL_H #define BOOT_INTERNAL_H -#include #include +#include // The 'g_boot_command' variable stores the 'command' passed to the // function 'svc_reboot_to_bootloader()'. It may be one of the @@ -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 diff --git a/core/embed/bootloader/emulator.c b/core/embed/bootloader/emulator.c index 05b1c9ad40a..10bbcbdf774 100644 --- a/core/embed/bootloader/emulator.c +++ b/core/embed/bootloader/emulator.c @@ -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); diff --git a/core/embed/bootloader/messages.c b/core/embed/bootloader/messages.c index e93c938569c..96c2f3b48b9 100644 --- a/core/embed/bootloader/messages.c +++ b/core/embed/bootloader/messages.c @@ -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, diff --git a/core/embed/rust/src/ui/model_tt/bootloader/mod.rs b/core/embed/rust/src/ui/model_tt/bootloader/mod.rs index 1d44d66e1ac..5e2cf0a9bf4 100644 --- a/core/embed/rust/src/ui/model_tt/bootloader/mod.rs +++ b/core/embed/rust/src/ui/model_tt/bootloader/mod.rs @@ -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) } @@ -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) } diff --git a/core/embed/rust/src/ui/model_tt/component/bl_confirm.rs b/core/embed/rust/src/ui/model_tt/component/bl_confirm.rs index 4c434f707c7..4f1091aba1f 100644 --- a/core/embed/rust/src/ui/model_tt/component/bl_confirm.rs +++ b/core/embed/rust/src/ui/model_tt/component/bl_confirm.rs @@ -64,11 +64,8 @@ where bg_color: Color, left_button: Button<&'static str>, right_button: Button<&'static str>, - menu_button: ButtonStyleSheet, title: ConfirmTitle, message: Label, - alert: Option>, - info: Option<(T, T)>, ) -> Self { Self { bg: Pad::with_background(bg_color).with_clear(), @@ -76,30 +73,40 @@ where 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) -> 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 Component for Confirm diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index c2398096554..ca75443cc38 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -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) } diff --git a/core/embed/trezorhal/boot_args.h b/core/embed/trezorhal/boot_args.h index 44f7966cf35..d9ccd09e30b 100644 --- a/core/embed/trezorhal/boot_args.h +++ b/core/embed/trezorhal/boot_args.h @@ -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 @@ -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 diff --git a/core/embed/trezorhal/common.h b/core/embed/trezorhal/common.h index 6cc8e46eb2e..cb871b8d1ba 100644 --- a/core/embed/trezorhal/common.h +++ b/core/embed/trezorhal/common.h @@ -51,8 +51,6 @@ }) #endif - - void __attribute__((noreturn)) trezor_shutdown(void); void __attribute__((noreturn)) diff --git a/core/embed/trezorhal/stm32f4/supervise.c b/core/embed/trezorhal/stm32f4/supervise.c index f8a7067114d..0a52028e6dd 100644 --- a/core/embed/trezorhal/stm32f4/supervise.c +++ b/core/embed/trezorhal/stm32f4/supervise.c @@ -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; diff --git a/core/mocks/generated/trezorutils.pyi b/core/mocks/generated/trezorutils.pyi index 400aff2c509..73d9bda80bb 100644 --- a/core/mocks/generated/trezorutils.pyi +++ b/core/mocks/generated/trezorutils.pyi @@ -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 } diff --git a/legacy/firmware/protob/messages-management.options b/legacy/firmware/protob/messages-management.options index 122bad39642..bd28e3f444e 100644 --- a/legacy/firmware/protob/messages-management.options +++ b/legacy/firmware/protob/messages-management.options @@ -46,4 +46,4 @@ UnlockPath.mac max_size:32 UnlockedPathRequest.mac max_size:32 -RebootToBootloader.firmware_header type:FT_IGNORE \ No newline at end of file +RebootToBootloader.firmware_header type:FT_IGNORE diff --git a/python/.changelog.d/2919.added.2 b/python/.changelog.d/2919.added.2 index 3aa8b942474..cd2a54d2072 100644 --- a/python/.changelog.d/2919.added.2 +++ b/python/.changelog.d/2919.added.2 @@ -1 +1 @@ -trezorctl: Automatically go to bootloader when upgrading firmware \ No newline at end of file +trezorctl: Automatically go to bootloader when upgrading firmware