1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-22 21:30:56 +00:00

bootloader: refactor fadeins/fadeouts

This commit is contained in:
Pavol Rusnak 2018-01-25 12:33:09 +01:00
parent 5538614a79
commit 117a3efbe2
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 28 additions and 9 deletions

View File

@ -146,11 +146,9 @@ void ui_screen_install_confirm(void)
void ui_screen_install(void) void ui_screen_install(void)
{ {
display_fade(BACKLIGHT_NORMAL, 0, 100);
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE); display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE);
display_loader(1000, -20, COLOR_BL_PROCESS, COLOR_WHITE, toi_icon_install, sizeof(toi_icon_install), COLOR_BLACK); display_loader(1000, -20, COLOR_BL_PROCESS, COLOR_WHITE, toi_icon_install, sizeof(toi_icon_install), COLOR_BLACK);
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, "Installing firmware", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0); display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, "Installing firmware", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
display_fade(0, BACKLIGHT_NORMAL, 100);
} }
void ui_screen_install_progress_erase(int pos, int len) void ui_screen_install_progress_erase(int pos, int len)
@ -184,11 +182,9 @@ void ui_screen_wipe_confirm(void)
void ui_screen_wipe(void) void ui_screen_wipe(void)
{ {
display_fade(BACKLIGHT_NORMAL, 0, 100);
display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE); display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_WHITE);
display_loader(1000, -20, COLOR_BL_PROCESS, COLOR_WHITE, toi_icon_wipe, sizeof(toi_icon_wipe), COLOR_BLACK); display_loader(1000, -20, COLOR_BL_PROCESS, COLOR_WHITE, toi_icon_wipe, sizeof(toi_icon_wipe), COLOR_BLACK);
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, "Wiping Device", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0); display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 24, "Wiping Device", -1, FONT_NORMAL, COLOR_BLACK, COLOR_WHITE, 0);
display_fade(0, BACKLIGHT_NORMAL, 100);
} }
void ui_screen_wipe_progress(int pos, int len) void ui_screen_wipe_progress(int pos, int len)

View File

@ -135,7 +135,9 @@ static secbool bootloader_usb_loop(const vendor_header * const vhdr, const image
send_user_abort(USB_IFACE_NUM, "Wipe cancelled"); send_user_abort(USB_IFACE_NUM, "Wipe cancelled");
break; break;
} }
ui_fadeout();
ui_screen_wipe(); ui_screen_wipe();
ui_fadein();
r = process_msg_WipeDevice(USB_IFACE_NUM, msg_size, buf); r = process_msg_WipeDevice(USB_IFACE_NUM, msg_size, buf);
if (r < 0) { // error if (r < 0) { // error
ui_screen_fail(); ui_screen_fail();
@ -160,7 +162,9 @@ static secbool bootloader_usb_loop(const vendor_header * const vhdr, const image
break; break;
} }
} }
ui_fadeout();
ui_screen_install(); ui_screen_install();
ui_fadein();
process_msg_FirmwareErase(USB_IFACE_NUM, msg_size, buf); process_msg_FirmwareErase(USB_IFACE_NUM, msg_size, buf);
break; break;
case 7: // FirmwareUpload case 7: // FirmwareUpload
@ -255,40 +259,58 @@ main_start:
image_header hdr; image_header hdr;
secbool firmware_present; secbool firmware_present;
// start the bootloader if user touched the screen or no firmware installed // detect whether the devices contains a firmware
firmware_present = load_vendor_header_keys((const uint8_t *)FIRMWARE_START, &vhdr); firmware_present = load_vendor_header_keys((const uint8_t *)FIRMWARE_START, &vhdr);
if (sectrue == firmware_present) { if (sectrue == firmware_present) {
firmware_present = load_image_header((const uint8_t *)(FIRMWARE_START + vhdr.hdrlen), FIRMWARE_IMAGE_MAGIC, FIRMWARE_IMAGE_MAXSIZE, vhdr.vsig_m, vhdr.vsig_n, vhdr.vpub, &hdr); firmware_present = load_image_header((const uint8_t *)(FIRMWARE_START + vhdr.hdrlen), FIRMWARE_IMAGE_MAGIC, FIRMWARE_IMAGE_MAXSIZE, vhdr.vsig_m, vhdr.vsig_n, vhdr.vpub, &hdr);
} }
// start the bootloader if no firmware found ...
if (firmware_present != sectrue) { if (firmware_present != sectrue) {
// show intro animation
// no ui_fadeout(); - we already start from black screen
ui_screen_first(); ui_screen_first();
ui_fadein(); ui_fadein();
hal_delay(1000);
ui_fadeout();
hal_delay(1000);
ui_fadeout();
ui_screen_second(); ui_screen_second();
ui_fadein(); ui_fadein();
hal_delay(1000);
ui_fadeout();
hal_delay(1000);
ui_fadeout();
ui_screen_third(); ui_screen_third();
ui_fadein(); ui_fadein();
// and start the usb loop
if (bootloader_usb_loop(NULL, NULL) != sectrue) { if (bootloader_usb_loop(NULL, NULL) != sectrue) {
return 1; return 1;
} }
} else } else
// ... or if user touched the screen on start
if (touched) { if (touched) {
// show firmware info with connect buttons
// no ui_fadeout(); - we already start from black screen
ui_screen_info(sectrue, &vhdr, &hdr); ui_screen_info(sectrue, &vhdr, &hdr);
ui_fadein(); ui_fadein();
secbool response = ui_button_response(); secbool response = ui_button_response();
ui_fadeout(); ui_fadeout();
// if cancel was pressed -> restart
if (sectrue != response) { if (sectrue != response) {
goto main_start; goto main_start;
} }
// show firmware info without connect buttons
ui_screen_info(secfalse, &vhdr, &hdr); ui_screen_info(secfalse, &vhdr, &hdr);
ui_fadein(); ui_fadein();
// and start the usb loop
if (bootloader_usb_loop(&vhdr, &hdr) != sectrue) { if (bootloader_usb_loop(&vhdr, &hdr) != sectrue) {
return 1; return 1;
} }
@ -314,6 +336,7 @@ main_start:
if ((vhdr.vtrust & VTRUST_ALL) != VTRUST_ALL) { if ((vhdr.vtrust & VTRUST_ALL) != VTRUST_ALL) {
// ui_fadeout(); // no fadeout - we start from black screen
ui_screen_boot(&vhdr, &hdr); ui_screen_boot(&vhdr, &hdr);
ui_fadein(); ui_fadein();