mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 23:08:14 +00:00
bootloader: implement UI according to mockup
This commit is contained in:
parent
fdafae7d8d
commit
17c3d2b56f
BIN
assets/cross.png
Normal file
BIN
assets/cross.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
10
embed/bootloader/icon_cross.h
Normal file
10
embed/bootloader/icon_cross.h
Normal file
@ -0,0 +1,10 @@
|
||||
static const uint8_t icon_cross[] = {
|
||||
// magic
|
||||
'T', 'O', 'I', 'g',
|
||||
// width (16-bit), height (16-bit)
|
||||
0x40, 0x00, 0x40, 0x00,
|
||||
// compressed data length (32-bit)
|
||||
0xbb, 0x00, 0x00, 0x00,
|
||||
// compressed data
|
||||
0xed, 0x92, 0xb1, 0x0d, 0x84, 0x30, 0x0c, 0x45, 0x43, 0x2a, 0x4a, 0x7a, 0xae, 0xa0, 0xbf, 0x19, 0xd8, 0x87, 0xee, 0x56, 0xa0, 0xa2, 0x65, 0x96, 0xbb, 0x05, 0xd0, 0x4d, 0x40, 0xc1, 0x2e, 0x27, 0x24, 0x90, 0x7c, 0x26, 0x0e, 0xa2, 0x70, 0x92, 0xcf, 0x00, 0xf9, 0xd5, 0x97, 0xcc, 0x7f, 0xd8, 0x8e, 0x8d, 0xc9, 0xca, 0xba, 0x21, 0x3b, 0x5c, 0xbe, 0x6b, 0x74, 0xbd, 0xa5, 0xf7, 0x69, 0x6b, 0x5a, 0x74, 0x7d, 0xa2, 0xcd, 0xa7, 0x2c, 0x5b, 0x55, 0x2e, 0x66, 0xa2, 0x8f, 0xd8, 0x27, 0xd1, 0x5e, 0xa9, 0x0f, 0x5e, 0xe4, 0x01, 0x1c, 0xa7, 0x9f, 0xe6, 0x97, 0x44, 0xd2, 0x41, 0xcd, 0xa6, 0x0f, 0x0c, 0x30, 0x32, 0x80, 0xb1, 0x05, 0xc7, 0xd7, 0xd0, 0x80, 0x07, 0xe0, 0x6b, 0xcc, 0x23, 0x12, 0x77, 0x80, 0xbd, 0x3a, 0xfa, 0x5c, 0xc3, 0x1b, 0x72, 0x80, 0x78, 0x5c, 0x00, 0xf1, 0xb8, 0x00, 0x12, 0x71, 0x07, 0x48, 0xc4, 0x3d, 0xa0, 0x4f, 0x3c, 0xe2, 0x98, 0x8c, 0xc3, 0x3a, 0xe2, 0x83, 0xfe, 0xd0, 0x7c, 0x60, 0x3f, 0x68, 0xbf, 0xe0, 0x7d, 0xd0, 0xfb, 0x82, 0xfb, 0x40, 0xf7, 0x05, 0xee, 0x13, 0xde, 0xf7, 0xe4, 0xe3, 0x0e, 0xb0, 0x69, 0x7e, 0x2b, 0x7f, 0x97, 0x0e, 0x16, 0x5d, 0xb7, 0xc3, 0xe5, 0xbb, 0xc6, 0x64, 0x65, 0xdd, 0xd1, 0x1f,
|
||||
};
|
10
embed/bootloader/icon_tick.h
Normal file
10
embed/bootloader/icon_tick.h
Normal file
@ -0,0 +1,10 @@
|
||||
static const uint8_t icon_tick[] = {
|
||||
// magic
|
||||
'T', 'O', 'I', 'g',
|
||||
// width (16-bit), height (16-bit)
|
||||
0x40, 0x00, 0x40, 0x00,
|
||||
// compressed data length (32-bit)
|
||||
0x98, 0x00, 0x00, 0x00,
|
||||
// compressed data
|
||||
0x63, 0x60, 0x18, 0x05, 0xa3, 0x60, 0xe8, 0x01, 0x01, 0xfc, 0xd2, 0xd6, 0x37, 0xf1, 0x2a, 0x60, 0x79, 0xff, 0x7f, 0x02, 0x3e, 0x79, 0xbf, 0xff, 0xff, 0x1f, 0xe2, 0xd7, 0xfe, 0xff, 0x00, 0x7e, 0xed, 0xff, 0x0c, 0xf0, 0x68, 0xff, 0xff, 0xff, 0xff, 0x13, 0x02, 0xda, 0x1d, 0xf0, 0xdb, 0x3e, 0xb4, 0xb4, 0x33, 0xb5, 0xe1, 0xd7, 0x6e, 0xfb, 0x7f, 0x23, 0x5e, 0xdb, 0xf7, 0xff, 0xff, 0xad, 0x80, 0x47, 0x3b, 0xe3, 0xf9, 0xff, 0xff, 0x37, 0xe1, 0x73, 0x7c, 0xfe, 0x7f, 0xa8, 0x01, 0x38, 0x1c, 0xcf, 0x01, 0x8c, 0x90, 0x8d, 0xf8, 0xfc, 0xde, 0x0f, 0x34, 0x40, 0x00, 0x8f, 0xdf, 0x41, 0x06, 0x1c, 0xc4, 0x17, 0x74, 0x40, 0x03, 0xfe, 0x08, 0xe0, 0x09, 0x3a, 0xb0, 0x01, 0x76, 0x78, 0x42, 0x1e, 0x64, 0xc0, 0x7d, 0x3c, 0x21, 0x0f, 0x32, 0x00, 0x6f, 0xc4, 0xf5, 0xff, 0xc7, 0x9f, 0xea, 0x38, 0xf0, 0x6b, 0x07, 0x1b, 0x80, 0x2f, 0xde, 0x19, 0xd8, 0xf1, 0x6b, 0x67, 0x60, 0x88, 0xde, 0xcc, 0x30, 0x0a, 0x06, 0x1b, 0x00, 0x00,
|
||||
};
|
12
embed/bootloader/icon_tools.h
Normal file
12
embed/bootloader/icon_tools.h
Normal file
@ -0,0 +1,12 @@
|
||||
static const uint8_t icon_tools[] = {
|
||||
/*
|
||||
// magic
|
||||
'T', 'O', 'I', 'g',
|
||||
// width (16-bit), height (16-bit)
|
||||
0x18, 0x00, 0x18, 0x00,
|
||||
// compressed data length (32-bit)
|
||||
0xd0, 0x00, 0x00, 0x00,
|
||||
*/
|
||||
// compressed data
|
||||
0x5d, 0x90, 0x3d, 0x4e, 0x42, 0x51, 0x10, 0x85, 0xcf, 0x43, 0xe4, 0x4f, 0x62, 0xa8, 0x09, 0x21, 0x6f, 0x09, 0xd8, 0x58, 0x02, 0x15, 0xa5, 0xe0, 0x0a, 0x1e, 0x4b, 0xa0, 0xb3, 0x13, 0x5d, 0x81, 0xec, 0x00, 0xec, 0x6c, 0x4c, 0x64, 0x05, 0x10, 0x36, 0xf0, 0x96, 0x60, 0x41, 0x6d, 0x5e, 0xc1, 0x8f, 0x20, 0xf0, 0x3e, 0xe7, 0x5e, 0x2b, 0xb9, 0xc9, 0x9d, 0xf9, 0x72, 0xee, 0xcc, 0x99, 0xc9, 0x95, 0xfe, 0x9f, 0xb6, 0xdd, 0xdb, 0xb6, 0xc7, 0xe2, 0x4e, 0xaa, 0xb2, 0xf6, 0x1c, 0xf1, 0xa4, 0x19, 0x7d, 0x87, 0xc1, 0x90, 0x4d, 0x8e, 0x6f, 0x2f, 0x3f, 0xc2, 0x6b, 0x89, 0x0f, 0xa9, 0xa1, 0x02, 0x69, 0x47, 0x65, 0xd3, 0x2f, 0xd7, 0x56, 0x7d, 0x90, 0xae, 0xa0, 0x1f, 0x6d, 0x83, 0x84, 0x93, 0x94, 0x87, 0x1f, 0x56, 0x05, 0x30, 0x9b, 0x9a, 0x45, 0xe6, 0xd7, 0xbc, 0xc5, 0xfb, 0xfb, 0xd8, 0xf0, 0x14, 0xb6, 0x96, 0x2a, 0x92, 0x92, 0xbe, 0x7f, 0x3d, 0x2b, 0xea, 0x49, 0x09, 0xac, 0x9c, 0x7b, 0x37, 0x94, 0x5e, 0xc0, 0x6f, 0x53, 0x0f, 0x95, 0xf9, 0x84, 0x81, 0xe3, 0x5c, 0xa8, 0xa6, 0x35, 0xee, 0xfe, 0x36, 0xbe, 0x48, 0x38, 0xc2, 0xc8, 0xf3, 0x9d, 0x0d, 0x18, 0xbb, 0xe1, 0x52, 0x16, 0xf6, 0x2a, 0xc1, 0xc2, 0x35, 0xc3, 0x44, 0x8a, 0x4d, 0x90, 0x5a, 0xfe, 0xb9, 0xce, 0xd4, 0x62, 0x99, 0xb9, 0x33, 0xf0, 0xf5, 0xc1, 0x43, 0xc5, 0xa5, 0x9b, 0xb3, 0xff, 0xf8, 0x05,
|
||||
};
|
@ -11,13 +11,15 @@
|
||||
#include "version.h"
|
||||
#include "mini_printf.h"
|
||||
|
||||
#include "icon_cross.h"
|
||||
#include "icon_tick.h"
|
||||
#include "icon_tools.h"
|
||||
#include "messages.h"
|
||||
#include "style.h"
|
||||
|
||||
#define IMAGE_MAGIC 0x465A5254 // TRZF
|
||||
#define IMAGE_MAXSIZE (7 * 128 * 1024)
|
||||
|
||||
#define BACKLIGHT_NORMAL 150
|
||||
|
||||
void display_fade(int start, int end, int delay)
|
||||
{
|
||||
for (int i = 0; i < 100; i++) {
|
||||
@ -27,6 +29,31 @@ void display_fade(int start, int end, int delay)
|
||||
display_backlight(end);
|
||||
}
|
||||
|
||||
void display_header(const char *text)
|
||||
{
|
||||
display_bar(0, 0, 240, 32, COLOR_BL_ORANGE);
|
||||
display_icon(8, 4, 24, 24, icon_tools, sizeof(icon_tools), COLOR_BLACK, COLOR_BL_ORANGE);
|
||||
display_text(8 + 24 + 8, 23, text, -1, FONT_BOLD, COLOR_BLACK, COLOR_BL_ORANGE);
|
||||
}
|
||||
|
||||
void display_footer(const char *text, uint16_t color)
|
||||
{
|
||||
display_bar(0, 184, 240, 56, COLOR_BLACK);
|
||||
display_text_center(120, 220, text, -1, FONT_BOLD, color, COLOR_BLACK);
|
||||
}
|
||||
|
||||
void display_done(void)
|
||||
{
|
||||
display_loader(1000, 0, COLOR_BL_GREEN, COLOR_BLACK, icon_tick, sizeof(icon_tick), COLOR_WHITE);
|
||||
display_footer("Done", COLOR_BL_GREEN);
|
||||
}
|
||||
|
||||
void display_error(void)
|
||||
{
|
||||
display_loader(1000, 0, COLOR_BL_RED, COLOR_BLACK, icon_cross, sizeof(icon_cross), COLOR_WHITE);
|
||||
display_footer("Error", COLOR_BL_RED);
|
||||
}
|
||||
|
||||
void display_vendor(const uint8_t *vimg, const char *vstr, uint32_t vstr_len, uint32_t fw_version)
|
||||
{
|
||||
display_clear();
|
||||
@ -120,7 +147,7 @@ void bootloader_loop(void)
|
||||
ensure(0 == usb_init_all(), NULL);
|
||||
|
||||
display_clear();
|
||||
display_text_center(120, 30, "TREZOR Bootloader", -1, FONT_BOLD, COLOR_WHITE, COLOR_BLACK);
|
||||
display_header("TREZOR Bootloader");
|
||||
display_fade(0, BACKLIGHT_NORMAL, 1000);
|
||||
|
||||
uint8_t buf[USB_PACKET_SIZE];
|
||||
@ -145,35 +172,33 @@ void bootloader_loop(void)
|
||||
process_msg_Ping(USB_IFACE_NUM, msg_size, buf);
|
||||
break;
|
||||
case 5: // WipeDevice
|
||||
display_fade(BACKLIGHT_NORMAL, 0, 100);
|
||||
display_clear();
|
||||
display_text_center(120, 30, "Wiping Device", -1, FONT_BOLD, COLOR_WHITE, COLOR_BLACK);
|
||||
display_header("Wiping Device");
|
||||
display_footer("In progress ...", COLOR_WHITE);
|
||||
display_fade(0, BACKLIGHT_NORMAL, 100);
|
||||
r = process_msg_WipeDevice(USB_IFACE_NUM, msg_size, buf);
|
||||
if (r < 0) { // error
|
||||
display_clear();
|
||||
display_text_center(120, 30, "Error", -1, FONT_BOLD, COLOR_RED, COLOR_BLACK);
|
||||
display_loader(1000, 0, COLOR_RED, COLOR_BLACK, 0, 0, 0);
|
||||
display_error();
|
||||
} else { // success
|
||||
display_clear();
|
||||
display_text_center(120, 30, "Done", -1, FONT_BOLD, COLOR_GREEN, COLOR_BLACK);
|
||||
display_loader(1000, 0, COLOR_GREEN, COLOR_BLACK, 0, 0, 0);
|
||||
display_done();
|
||||
}
|
||||
break;
|
||||
case 6: // FirmwareErase
|
||||
display_fade(BACKLIGHT_NORMAL, 0, 100);
|
||||
display_clear();
|
||||
display_text_center(120, 30, "Updating Firmware", -1, FONT_BOLD, COLOR_WHITE, COLOR_BLACK);
|
||||
display_header("Updating Firmware");
|
||||
display_footer("In progress ...", COLOR_WHITE);
|
||||
display_fade(0, BACKLIGHT_NORMAL, 100);
|
||||
process_msg_FirmwareErase(USB_IFACE_NUM, msg_size, buf);
|
||||
break;
|
||||
case 7: // FirmwareUpload
|
||||
r = process_msg_FirmwareUpload(USB_IFACE_NUM, msg_size, buf);
|
||||
if (r < 0) { // error
|
||||
display_clear();
|
||||
display_text_center(120, 30, "Error", -1, FONT_BOLD, COLOR_RED, COLOR_BLACK);
|
||||
display_loader(1000, 0, COLOR_RED, COLOR_BLACK, 0, 0, 0);
|
||||
display_error();
|
||||
} else
|
||||
if (r == 0) { // last chunk received
|
||||
display_clear();
|
||||
display_text_center(120, 30, "Done", -1, FONT_BOLD, COLOR_GREEN, COLOR_BLACK);
|
||||
display_loader(1000, 0, COLOR_GREEN, COLOR_BLACK, 0, 0, 0);
|
||||
display_done();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -223,6 +248,14 @@ int main(void)
|
||||
touched = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
touched = true;
|
||||
|
||||
|
||||
|
||||
// start the bootloader if user touched the screen or no firmware installed
|
||||
if (touched || !vendor_parse_header((const uint8_t *)FIRMWARE_START, NULL)) {
|
||||
bootloader_loop();
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "version.h"
|
||||
|
||||
#include "messages.h"
|
||||
#include "style.h"
|
||||
|
||||
#define FIRMWARE_CHUNK_SIZE (128 * 1024)
|
||||
|
||||
@ -230,7 +231,7 @@ static uint32_t firmware_remaining, firmware_flashed, chunk_requested;
|
||||
|
||||
static void progress_erase(int pos, int len)
|
||||
{
|
||||
display_loader(250 * pos / len, 0, COLOR_WHITE, COLOR_BLACK, 0, 0, 0);
|
||||
display_loader(250 * pos / len, 0, COLOR_BL_BLUE, COLOR_BLACK, 0, 0, 0);
|
||||
}
|
||||
|
||||
void process_msg_FirmwareErase(uint8_t iface_num, uint32_t msg_size, uint8_t *buf)
|
||||
@ -291,7 +292,7 @@ static bool _read_payload(pb_istream_t *stream, const pb_field_t *field, void **
|
||||
chunk_size = stream->bytes_left;
|
||||
while (stream->bytes_left) {
|
||||
// print loader
|
||||
display_loader(250 + 750 * (firmware_flashed + chunk_written) / (firmware_flashed + firmware_remaining), 0, COLOR_WHITE, COLOR_BLACK, 0, 0, 0);
|
||||
display_loader(250 + 750 * (firmware_flashed + chunk_written) / (firmware_flashed + firmware_remaining), 0, COLOR_BL_BLUE, COLOR_BLACK, 0, 0, 0);
|
||||
memset(buf, 0xFF, sizeof(buf));
|
||||
// read data
|
||||
if (!pb_read(stream, (pb_byte_t *)buf, (stream->bytes_left > BUFSIZE) ? BUFSIZE : stream->bytes_left)) {
|
||||
@ -348,7 +349,7 @@ int process_msg_FirmwareUpload(uint8_t iface_num, uint32_t msg_size, uint8_t *bu
|
||||
|
||||
static void progress_wipe(int pos, int len)
|
||||
{
|
||||
display_loader(1000 * pos / len, 0, COLOR_WHITE, COLOR_BLACK, 0, 0, 0);
|
||||
display_loader(1000 * pos / len, 0, COLOR_BL_BLUE, COLOR_BLACK, 0, 0, 0);
|
||||
}
|
||||
|
||||
int process_msg_WipeDevice(uint8_t iface_num, uint32_t msg_size, uint8_t *buf)
|
||||
|
11
embed/bootloader/style.h
Normal file
11
embed/bootloader/style.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __STYLE_H__
|
||||
#define __STYLE_H__
|
||||
|
||||
#define BACKLIGHT_NORMAL 150
|
||||
|
||||
#define COLOR_BL_RED RGB16(0xE4, 0x57, 0x2E)
|
||||
#define COLOR_BL_GREEN RGB16(0x4C, 0xC1, 0x48)
|
||||
#define COLOR_BL_BLUE RGB16(0x21, 0x96, 0xF3)
|
||||
#define COLOR_BL_ORANGE RGB16(0xFF, 0x98, 0x00)
|
||||
|
||||
#endif
|
@ -29,24 +29,24 @@
|
||||
#define FONT_BOLD 2
|
||||
#endif
|
||||
|
||||
#define AVATAR_IMAGE_SIZE 144
|
||||
#define LOADER_ICON_SIZE 64
|
||||
#define AVATAR_IMAGE_SIZE 144
|
||||
#define LOADER_ICON_SIZE 64
|
||||
|
||||
#define RGB16(R, G, B) ((R & 0xF8) << 8) | ((G & 0xFC) << 3) | ((B & 0xF8) >> 3)
|
||||
|
||||
#define COLOR_WHITE RGB16(255, 255, 255)
|
||||
#define COLOR_GRAY128 RGB16(127, 127, 127)
|
||||
#define COLOR_GRAY64 RGB16(63, 63, 63)
|
||||
#define COLOR_BLACK RGB16(0, 0, 0)
|
||||
#define COLOR_WHITE RGB16(0xFF, 0xFF, 0xFF)
|
||||
#define COLOR_GRAY128 RGB16(0x7F, 0x7F, 0x7F)
|
||||
#define COLOR_GRAY64 RGB16(0x3F, 0x3F, 0x3F)
|
||||
#define COLOR_BLACK RGB16(0x00, 0x00, 0x00)
|
||||
|
||||
#define COLOR_RED RGB16(255, 0, 0)
|
||||
#define COLOR_RED128 RGB16(127, 0, 0)
|
||||
#define COLOR_RED RGB16(0xFF, 0x00, 0x00)
|
||||
#define COLOR_RED128 RGB16(0x7F, 0x00, 0x00)
|
||||
|
||||
#define COLOR_GREEN RGB16(0, 255, 0)
|
||||
#define COLOR_GREEN128 RGB16(0, 127, 0)
|
||||
#define COLOR_GREEN RGB16(0x00, 0xFF, 0x00)
|
||||
#define COLOR_GREEN128 RGB16(0x00, 0x7F, 0x00)
|
||||
|
||||
#define COLOR_BLUE RGB16(0, 0, 255)
|
||||
#define COLOR_BLUE128 RGB16(0, 0, 127)
|
||||
#define COLOR_BLUE RGB16(0x00, 0x00, 0xFF)
|
||||
#define COLOR_BLUE128 RGB16(0x00, 0x00, 0x7F)
|
||||
|
||||
// provided by port
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user