mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-08-01 11:28:20 +00:00
feat(core): respect manufacturing mode in power on sequence
[no changelog]
This commit is contained in:
parent
2e23349419
commit
a4eaf4dc27
@ -89,7 +89,22 @@ void failed_jump_to_firmware(void);
|
|||||||
CONFIDENTIAL volatile secbool dont_optimize_out_true = sectrue;
|
CONFIDENTIAL volatile secbool dont_optimize_out_true = sectrue;
|
||||||
CONFIDENTIAL void (*volatile firmware_jump_fn)(void) = failed_jump_to_firmware;
|
CONFIDENTIAL void (*volatile firmware_jump_fn)(void) = failed_jump_to_firmware;
|
||||||
|
|
||||||
static void drivers_init(secbool *touch_initialized) {
|
static secbool is_manufacturing_mode(void) {
|
||||||
|
unit_properties_init();
|
||||||
|
|
||||||
|
#if (defined TREZOR_MODEL_T3T1 || defined TREZOR_MODEL_T3W1)
|
||||||
|
// on T3T1 and T3W1, tester needs to run without touch and tamper, so making
|
||||||
|
// an exception until unit variant is written in OTP
|
||||||
|
const secbool manufacturing_mode =
|
||||||
|
unit_properties()->locked ? secfalse : sectrue;
|
||||||
|
#else
|
||||||
|
const secbool manufacturing_mode = secfalse;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return manufacturing_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void boot_sequence(secbool manufacturing_mode) {
|
||||||
#ifdef USE_BACKUP_RAM
|
#ifdef USE_BACKUP_RAM
|
||||||
backup_ram_init();
|
backup_ram_init();
|
||||||
#endif
|
#endif
|
||||||
@ -111,6 +126,10 @@ static void drivers_init(secbool *touch_initialized) {
|
|||||||
(cmd == BOOT_COMMAND_INSTALL_UPGRADE || cmd == BOOT_COMMAND_REBOOT ||
|
(cmd == BOOT_COMMAND_INSTALL_UPGRADE || cmd == BOOT_COMMAND_REBOOT ||
|
||||||
cmd == BOOT_COMMAND_SHOW_RSOD || cmd == BOOT_COMMAND_STOP_AND_WAIT);
|
cmd == BOOT_COMMAND_SHOW_RSOD || cmd == BOOT_COMMAND_STOP_AND_WAIT);
|
||||||
|
|
||||||
|
if (sectrue == manufacturing_mode && cmd != BOOT_COMMAND_POWER_OFF) {
|
||||||
|
turn_on = true;
|
||||||
|
}
|
||||||
|
|
||||||
while (!button_is_down(BTN_POWER) && !turn_on) {
|
while (!button_is_down(BTN_POWER) && !turn_on) {
|
||||||
pm_state_t state;
|
pm_state_t state;
|
||||||
pm_get_state(&state);
|
pm_get_state(&state);
|
||||||
@ -139,7 +158,10 @@ static void drivers_init(secbool *touch_initialized) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void drivers_init(secbool manufacturing_mode,
|
||||||
|
secbool *touch_initialized) {
|
||||||
random_delays_init();
|
random_delays_init();
|
||||||
#ifdef USE_PVD
|
#ifdef USE_PVD
|
||||||
pvd_init();
|
pvd_init();
|
||||||
@ -148,17 +170,6 @@ static void drivers_init(secbool *touch_initialized) {
|
|||||||
hash_processor_init();
|
hash_processor_init();
|
||||||
#endif
|
#endif
|
||||||
display_init(DISPLAY_RESET_CONTENT);
|
display_init(DISPLAY_RESET_CONTENT);
|
||||||
unit_properties_init();
|
|
||||||
|
|
||||||
#if (defined TREZOR_MODEL_T3T1 || defined TREZOR_MODEL_T3W1)
|
|
||||||
// on T3T1 and T3W1, tester needs to run without touch and tamper, so making
|
|
||||||
// an exception until unit variant is written in OTP
|
|
||||||
const secbool manufacturing_mode =
|
|
||||||
unit_properties()->locked ? secfalse : sectrue;
|
|
||||||
#else
|
|
||||||
const secbool manufacturing_mode = secfalse;
|
|
||||||
(void)manufacturing_mode; // suppress unused variable warning
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_TAMPER
|
#ifdef USE_TAMPER
|
||||||
tamper_init();
|
tamper_init();
|
||||||
@ -317,7 +328,11 @@ int bootloader_main(void) {
|
|||||||
|
|
||||||
system_init(&rsod_panic_handler);
|
system_init(&rsod_panic_handler);
|
||||||
|
|
||||||
drivers_init(&touch_initialized);
|
secbool manufacturing_mode = is_manufacturing_mode();
|
||||||
|
|
||||||
|
boot_sequence(manufacturing_mode);
|
||||||
|
|
||||||
|
drivers_init(manufacturing_mode, &touch_initialized);
|
||||||
|
|
||||||
ui_screen_boot_stage_1(false);
|
ui_screen_boot_stage_1(false);
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
// Defines boot command processed in bootloader on next reboot
|
// Defines boot command processed in bootloader on next reboot
|
||||||
typedef enum {
|
typedef enum {
|
||||||
// Normal boot sequence
|
// Default boot sequence
|
||||||
BOOT_COMMAND_NONE = 0x00000000,
|
BOOT_COMMAND_NONE = 0x00000000,
|
||||||
// Stop and wait for further instructions
|
// Stop and wait for further instructions
|
||||||
BOOT_COMMAND_STOP_AND_WAIT = 0x0FC35A96,
|
BOOT_COMMAND_STOP_AND_WAIT = 0x0FC35A96,
|
||||||
@ -35,6 +35,8 @@ typedef enum {
|
|||||||
BOOT_COMMAND_SHOW_RSOD = 0x7CD945A0,
|
BOOT_COMMAND_SHOW_RSOD = 0x7CD945A0,
|
||||||
// Reboot the device as if it was powered on
|
// Reboot the device as if it was powered on
|
||||||
BOOT_COMMAND_REBOOT = 0xA5C3D4E2,
|
BOOT_COMMAND_REBOOT = 0xA5C3D4E2,
|
||||||
|
// Power of the device
|
||||||
|
BOOT_COMMAND_POWER_OFF = 0x24EEE8828,
|
||||||
} boot_command_t;
|
} boot_command_t;
|
||||||
|
|
||||||
// Maximum size boot_args array
|
// Maximum size boot_args array
|
||||||
|
@ -217,7 +217,7 @@ __attribute__((noreturn)) void reboot_device(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((noreturn)) void reboot_to_off(void) {
|
__attribute__((noreturn)) void reboot_to_off(void) {
|
||||||
reboot_with_args(BOOT_COMMAND_NONE, NULL, 0);
|
reboot_with_args(BOOT_COMMAND_POWER_OFF, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((noreturn)) void reboot_or_halt_after_rsod(void) {
|
__attribute__((noreturn)) void reboot_or_halt_after_rsod(void) {
|
||||||
|
Loading…
Reference in New Issue
Block a user