Skip to content

Commit ad3cb11

Browse files
committed
feat(core/bootloader): start the device on short press
[no changelog]
1 parent ba3056b commit ad3cb11

File tree

1 file changed

+9
-8
lines changed
  • core/embed/projects/bootloader

1 file changed

+9
-8
lines changed

core/embed/projects/bootloader/main.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static secbool is_manufacturing_mode(vendor_header *vhdr) {
117117
return manufacturing_mode;
118118
}
119119

120-
static secbool boot_sequence(secbool manufacturing_mode) {
120+
static secbool boot_sequence(void) {
121121
secbool stay_in_bootloader = secfalse;
122122

123123
#ifdef USE_BACKUP_RAM
@@ -149,7 +149,7 @@ static secbool boot_sequence(secbool manufacturing_mode) {
149149
(cmd == BOOT_COMMAND_INSTALL_UPGRADE || cmd == BOOT_COMMAND_REBOOT ||
150150
cmd == BOOT_COMMAND_SHOW_RSOD || cmd == BOOT_COMMAND_STOP_AND_WAIT);
151151

152-
if (sectrue == manufacturing_mode && cmd != BOOT_COMMAND_POWER_OFF) {
152+
if (cmd != BOOT_COMMAND_POWER_OFF) {
153153
turn_on = true;
154154
}
155155

@@ -159,14 +159,15 @@ static secbool boot_sequence(secbool manufacturing_mode) {
159159

160160
uint32_t press_start = 0;
161161
bool turn_on_locked = false;
162+
bool haptic_played = false;
162163
bool bld_locked = false;
163164

164165
while (!turn_on) {
165166
bool btn_down = button_is_down(BTN_POWER);
166167
if (btn_down) {
167168
if (press_start == 0) {
168169
press_start = systick_ms();
169-
turn_on_locked = false;
170+
turn_on_locked = true;
170171
bld_locked = false;
171172
}
172173

@@ -176,13 +177,13 @@ static secbool boot_sequence(secbool manufacturing_mode) {
176177
haptic_play(HAPTIC_BOOTLOADER_ENTRY);
177178
#endif
178179
bld_locked = true;
179-
} else if ((elapsed >= 1000 || manufacturing_mode == sectrue) &&
180-
!turn_on_locked) {
180+
}
181181
#ifdef USE_HAPTIC
182+
else if (elapsed >= 500 && !haptic_played) {
182183
haptic_play(HAPTIC_BUTTON_PRESS);
183-
#endif
184-
turn_on_locked = true;
184+
haptic_played = true;
185185
}
186+
#endif
186187
} else if (press_start != 0) {
187188
// Button just released
188189
if (bld_locked) {
@@ -460,7 +461,7 @@ int bootloader_main(void) {
460461

461462
secbool manufacturing_mode = is_manufacturing_mode(&vhdr);
462463

463-
secbool stay_in_bootloader = boot_sequence(manufacturing_mode);
464+
secbool stay_in_bootloader = boot_sequence();
464465

465466
drivers_init(manufacturing_mode, &touch_initialized);
466467

0 commit comments

Comments
 (0)