mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
fix(legacy): prevent handling RebootToBootloader recursing by flushing USB write
This commit is contained in:
parent
2bcbbec0a2
commit
199729e57a
1
legacy/firmware/.changelog.d/1985.fixed
Normal file
1
legacy/firmware/.changelog.d/1985.fixed
Normal file
@ -0,0 +1 @@
|
||||
Prevent recursing in handling RebootToBootloader by USB flush.
|
@ -360,8 +360,7 @@ void fsm_msgRebootToBootloader(void) {
|
||||
oledRefresh();
|
||||
fsm_sendSuccess(_("Rebooting"));
|
||||
// make sure the outgoing message is sent
|
||||
usbPoll();
|
||||
usbSleep(500);
|
||||
usbFlush(500);
|
||||
#if !EMULATOR
|
||||
svc_reboot_to_bootloader();
|
||||
#else
|
||||
|
@ -70,3 +70,5 @@ char usbTiny(char set) {
|
||||
tiny = set;
|
||||
return old;
|
||||
}
|
||||
|
||||
void usbFlush(uint32_t millis) { usbSleep(millis); }
|
||||
|
@ -457,3 +457,23 @@ void usbSleep(uint32_t millis) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usbFlush(uint32_t millis) {
|
||||
if (usbd_dev == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
static const uint8_t *data;
|
||||
data = msg_out_data();
|
||||
if (data) {
|
||||
while (usbd_ep_write_packet(usbd_dev, ENDPOINT_ADDRESS_MAIN_IN, data,
|
||||
USB_PACKET_SIZE) != USB_PACKET_SIZE) {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t start = timer_ms();
|
||||
|
||||
while ((timer_ms() - start) < millis) {
|
||||
asm("nop");
|
||||
}
|
||||
}
|
||||
|
@ -27,5 +27,6 @@ void usbPoll(void);
|
||||
void usbReconnect(void);
|
||||
char usbTiny(char set);
|
||||
void usbSleep(uint32_t millis);
|
||||
void usbFlush(uint32_t millis);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user