Skip to content
Closed
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
9 changes: 5 additions & 4 deletions core/embed/bootloader/bootui.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,12 @@ void ui_screen_install_confirm_newvendor_or_downgrade_wipe(char* new_version) {
// loop++;
// offset += split;
// } while (split);
display_bar_radius_ex(BOARD_OFFSET_X, 295, BUTTON_FULL_WIDTH, BUTTON_HEIGHT,
COLOR_BL_PANEL, COLOR_BL_BG, BUTTON_RADIUS);
// display_bar_radius_ex(BOARD_OFFSET_X, 295, BUTTON_FULL_WIDTH,
// BUTTON_HEIGHT,
// COLOR_BL_PANEL, COLOR_BL_BG, BUTTON_RADIUS);

display_text(MAX_DISPLAY_RESX / 2 + 25, 350, new_version, -1, FONT_NORMAL,
COLOR_BL_SUBTITLE, COLOR_BL_DARK);
// display_text(MAX_DISPLAY_RESX / 2 + 25, 350, new_version, -1, FONT_NORMAL,
// COLOR_BL_SUBTITLE, COLOR_BL_DARK);

ui_confirm_cancel_buttons("Cancel", "Install", COLOR_BL_DARK, COLOR_BL_FAIL);
}
Expand Down
6 changes: 6 additions & 0 deletions core/embed/bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ static secbool get_device_serial(char* serial, size_t len) {
}

static void usb_init_all(secbool usb21_landing) {
static bool usb_init_done = false;
if (usb_init_done) {
return;
}
usb_init_done = true;

usb_dev_info_t dev_info = {
.device_class = 0x00,
.device_subclass = 0x00,
Expand Down
2 changes: 2 additions & 0 deletions core/embed/emmc_wrapper/emmc_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,8 @@ static int update_firmware_from_file(uint8_t iface_num, const char* path, bool c
send_user_abort_nocheck(iface_num, "Firmware install cancelled");
return -4;
}
display_clear();
ui_statusbar_update();
}

// ui start install
Expand Down
73 changes: 38 additions & 35 deletions core/embed/trezorhal/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,44 +751,47 @@ secbool verify_firmware(vendor_header* const vhdr, image_header* const hdr,
EMMC_PATH_INFO path_info = {0};
uint32_t processed_len = 0;

ExecuteCheck_ADV(emmc_fs_path_info("0:data/fw_p2.bin", &path_info), true, {
if (error_msg != NULL)
strncpy(error_msg, "Firmware code invalid! (P2_EMMC_1)", error_msg_len);
return secfalse;
});
if (_hdr.codelen > fw_internal_size - (_vhdr.hdrlen + _hdr.hdrlen)) {
ExecuteCheck_ADV(emmc_fs_path_info("0:data/fw_p2.bin", &path_info), true, {
if (error_msg != NULL)
strncpy(error_msg, "Firmware code invalid! (P2_EMMC_1)", error_msg_len);
return secfalse;
});

if (path_info.size > fw_external_size) {
if (error_msg != NULL)
strncpy(error_msg, "Firmware file P2 too large!", error_msg_len);
return secfalse;
}
if (path_info.size > fw_external_size) {
if (error_msg != NULL)
strncpy(error_msg, "Firmware file P2 too large!", error_msg_len);
return secfalse;
}

ExecuteCheck_ADV(
emmc_fs_file_read("0:data/fw_p2.bin", 0,
(uint32_t*)FMC_SDRAM_FIRMWARE_P2_ADDRESS,
MAX(path_info.size, fw_external_size), &processed_len),
true, {
if (error_msg != NULL)
strncpy(error_msg, "Firmware code invalid! (P2_EMMC_2)",
error_msg_len);
return secfalse;
});
ExecuteCheck_ADV(
emmc_fs_file_read(
"0:data/fw_p2.bin", 0, (uint32_t*)FMC_SDRAM_FIRMWARE_P2_ADDRESS,
MAX(path_info.size, fw_external_size), &processed_len),
true, {
if (error_msg != NULL)
strncpy(error_msg, "Firmware code invalid! (P2_EMMC_2)",
error_msg_len);
return secfalse;
});

ExecuteCheck_ADV(
check_image_contents_ADV(
&_vhdr, &_hdr, (const uint8_t*)FMC_SDRAM_FIRMWARE_P2_ADDRESS,
(fw_internal_size - (_vhdr.hdrlen + _hdr.hdrlen)),
_hdr.codelen - (fw_internal_size - (_vhdr.hdrlen + _hdr.hdrlen)),
true),
sectrue, {
memset((uint8_t*)FMC_SDRAM_FIRMWARE_P2_ADDRESS, 0x00,
_hdr.codelen - (fw_internal_size -
(_vhdr.hdrlen +
_hdr.hdrlen))); // wipe the buffer if fail
if (error_msg != NULL)
strncpy(error_msg, "Firmware code invalid! (P2)", error_msg_len);
return secfalse;
});
}

ExecuteCheck_ADV(
check_image_contents_ADV(
&_vhdr, &_hdr, (const uint8_t*)FMC_SDRAM_FIRMWARE_P2_ADDRESS,
(fw_internal_size - (_vhdr.hdrlen + _hdr.hdrlen)),
_hdr.codelen - (fw_internal_size - (_vhdr.hdrlen + _hdr.hdrlen)),
true),
sectrue, {
memset((uint8_t*)FMC_SDRAM_FIRMWARE_P2_ADDRESS, 0x00,
_hdr.codelen -
(fw_internal_size -
(_vhdr.hdrlen + _hdr.hdrlen))); // wipe the buffer if fail
if (error_msg != NULL)
strncpy(error_msg, "Firmware code invalid! (P2)", error_msg_len);
return secfalse;
});
_code_valid = sectrue;
if (code_valid != NULL) *code_valid = _code_valid;

Expand Down
8 changes: 6 additions & 2 deletions core/embed/trezorhal/spi_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ uint32_t _spi_slave_poll_ex(uint8_t* buf, bool fido)

fifo_read_peek(&spi_fifo_in, header, sizeof(header));

if ( memcmp(header, "fid", 3) != 0 && header[0] != '?' )
{
fifo_flush(&spi_fifo_in);
return 0;
}

if ( fido )
{
if ( memcmp(header, "fid", 3) == 0 )
Expand All @@ -355,8 +361,6 @@ uint32_t _spi_slave_poll_ex(uint8_t* buf, bool fido)
}
}

fifo_flush(&spi_fifo_in);

return 0;
}

Expand Down
9 changes: 9 additions & 0 deletions core/src/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@
utils.RESTART_MAIN_LOOP = False


async def flush_fido_buffer():
from trezor import io

while True:
await loop.wait(io.SPI_FIDO_FACE | io.POLL_READ)


if not utils.BITCOIN_ONLY and usb.ENABLE_IFACE_WEBAUTHN:
import apps.webauthn

apps.webauthn.boot()
else:
loop.schedule(flush_fido_buffer())

if __debug__:
import apps.debug
Expand Down
Loading