From 31a937de1bd78d8d682f6ab40c66284079eefaee Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 3 Oct 2016 16:17:49 +0200 Subject: [PATCH] bootloader ui (work in progress) --- bootloader/Makefile.bootloader | 4 ++-- bootloader/bootloader.c | 17 ++++++++--------- bootloader/bootloader_trezor.h | 3 +++ bootloader/bootloader_ui.c | 28 ++++++++++++++++++++++++++++ bootloader/bootloader_ui.h | 11 +++++++++++ extmod/modtrezorui/display.h | 2 ++ vendor/micropython | 2 +- 7 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 bootloader/bootloader_trezor.h create mode 100644 bootloader/bootloader_ui.c create mode 100644 bootloader/bootloader_ui.h diff --git a/bootloader/Makefile.bootloader b/bootloader/Makefile.bootloader index 77eb9219c1..a47465e42b 100644 --- a/bootloader/Makefile.bootloader +++ b/bootloader/Makefile.bootloader @@ -78,6 +78,7 @@ LIBS += $(shell $(CC) -print-libgcc-file-name) SRC_C = \ bootloader.c \ + bootloader_ui.c \ system_stm32.c \ $(wildcard boards/$(BOARD)/*.c) @@ -129,6 +130,7 @@ SRC_USBDEV = $(addprefix $(USBDEV_DIR)/,\ SRC_MODUI = $(addprefix extmod/modtrezorui/,\ display.c \ + inflate.c \ font_robotomono_regular.c \ ) @@ -201,8 +203,6 @@ CDCINF_TEMPLATE = pybcdc.inf_template GEN_CDCINF_FILE = $(HEADER_BUILD)/pybcdc.inf GEN_CDCINF_HEADER = $(HEADER_BUILD)/pybcdc_inf.h -# List of sources for qstr extraction -SRC_QSTR += $(SRC_C) # Append any auto-generated sources that are needed by sources listed in # SRC_QSTR SRC_QSTR_AUTO_DEPS += $(GEN_CDCINF_HEADER) diff --git a/bootloader/bootloader.c b/bootloader/bootloader.c index a3c5a2bb02..abe532caba 100644 --- a/bootloader/bootloader.c +++ b/bootloader/bootloader.c @@ -1,6 +1,7 @@ #include STM32_HAL_H #include "display.h" +#include "bootloader_ui.h" // ### from main.c @@ -102,17 +103,15 @@ int main(void) { display_init(); display_clear(); - display_text(100, 120, "TREZOR", 6, FONT_MONO, 0xFFFF, 0x0000); - display_text(90, 140, "bootloader", 10, FONT_MONO, 0xFFFF, 0x0000); - display_backlight(255); + + screen_welcome(); + + for (;;) { + display_backlight(255); HAL_Delay(250); - display_backlight(0); + display_backlight(0); HAL_Delay(250); - display_backlight(100); - HAL_Delay(250); - display_backlight(0); - HAL_Delay(250); - display_backlight(255); + } __fatal_error("end"); diff --git a/bootloader/bootloader_trezor.h b/bootloader/bootloader_trezor.h new file mode 100644 index 0000000000..e0d18e0b03 --- /dev/null +++ b/bootloader/bootloader_trezor.h @@ -0,0 +1,3 @@ +static const uint8_t toi_trezor[] = { + 0xed, 0xd2, 0x4b, 0x6c, 0x1b, 0x45, 0x18, 0x07, 0xf0, 0xb1, 0xe3, 0x3c, 0x9a, 0x26, 0xb1, 0xcb, 0x05, 0xa1, 0x1e, 0xba, 0x0a, 0x12, 0x5c, 0x2a, 0xc5, 0x48, 0x70, 0x43, 0x24, 0x97, 0x5e, 0x38, 0x34, 0xa9, 0x78, 0x9c, 0x80, 0xf8, 0x42, 0xa5, 0x4a, 0x48, 0xc9, 0x09, 0xb8, 0xc5, 0x1c, 0x28, 0xe2, 0x94, 0x70, 0x43, 0x08, 0x48, 0x04, 0x48, 0x08, 0x21, 0x35, 0x15, 0x47, 0x54, 0x51, 0xa4, 0x22, 0xc4, 0xc3, 0x60, 0xab, 0xaa, 0x04, 0x87, 0x80, 0x2b, 0x21, 0x1e, 0x02, 0x81, 0x9d, 0xc4, 0x49, 0x5c, 0xbf, 0x3e, 0x76, 0x67, 0x66, 0x77, 0xc7, 0xeb, 0xdd, 0xb5, 0xbd, 0xbb, 0xdf, 0x46, 0xad, 0xbe, 0xff, 0xc1, 0x9e, 0xd9, 0x99, 0x9d, 0xdf, 0xce, 0xcc, 0xc7, 0x18, 0x85, 0x42, 0xa1, 0x50, 0x28, 0x14, 0x0a, 0x85, 0x42, 0xb9, 0x57, 0x33, 0x72, 0xe9,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x20, 0x80, 0xcb, 0xca, 0xb2, 0x2a, 0x55, 0x77, 0x42, 0xe9, 0xb4, 0xd8, 0x09, 0x50, 0x53, 0xb3, 0x5c, 0xbe, 0xfd, 0x8d, 0xa0, 0xee, 0xbc, 0xbc, 0x26, 0x6f, 0x57, 0x7c, 0x9a, 0x99, 0x0d, 0xcb, 0x1d, 0xea, 0x82, 0x7b, 0xdc, 0xb4, 0xdc, 0x84, 0x8f, 0x3b, 0xa3, 0x74, 0x75, 0xcf, 0x74, 0xa7, 0x8d, 0x7e, 0x23, 0xa8, 0x3b, 0x2a, 0xaf, 0xc9, 0xc7, 0x95, 0x95, 0x25, 0xab, 0xca, 0x72, 0x93, 0xc3, 0x5c, 0x70, 0x8f, 0x2b, 0xc0, 0x25, 0x5f, 0x77, 0x5c, 0xbd, 0x5d, 0xcb, 0x15, 0x55, 0xbf, 0x15, 0xd4, 0x5d, 0x17, 0xd7, 0xe4, 0xe7, 0x5a, 0xa5, 0xf5, 0x27, 0x53, 0xdd, 0xe5, 0x21, 0x2e, 0xf8, 0xb9, 0x42, 0xa1, 0xf0, 0x1d, 0x6f, 0xe9, 0x8d, 0xc2, 0x57, 0xfa, 0xff, 0x94, 0x68, 0x14, 0xec, 0xdc, 0x18, 0x53, 0x3a, 0xdf, 0xf2, 0xc9, 0xa3, 0x5f, 0x18, 0xdf, 0xfb, 0xa1, 0x58, 0xe3, 0x5d, 0xfd, 0xf1, 0x37, 0xfa, 0xff, 0xc9, 0x82, 0x6c, 0x60, 0x26, 0xf1, 0xa0, 0xc6, 0x28, 0x14, 0x0a, 0x85, 0x42, 0xa1, 0x50, 0x28, 0x14, 0xca, 0xbd, 0x92, 0xff, 0x01, +}; diff --git a/bootloader/bootloader_ui.c b/bootloader/bootloader_ui.c new file mode 100644 index 0000000000..33b8f55a49 --- /dev/null +++ b/bootloader/bootloader_ui.c @@ -0,0 +1,28 @@ +#include "display.h" +#include "bootloader_trezor.h" + +void screen_welcome(void) +{ + display_image(0, 0, 240, 240, toi_trezor, sizeof(toi_trezor)); + display_text(0, 240, "bootloader", 10, FONT_MONO, 0xFFFF, 0x0000); +} + +void screen_info(void) +{ +} + +void screen_upload_request(void) +{ +} + +void screen_upload_progress(int permil) +{ +} + +void screen_upload_success(void) +{ +} + +void screen_upload_abort(void) +{ +} diff --git a/bootloader/bootloader_ui.h b/bootloader/bootloader_ui.h new file mode 100644 index 0000000000..78364af5d7 --- /dev/null +++ b/bootloader/bootloader_ui.h @@ -0,0 +1,11 @@ +#ifndef __BOOTLOADER_UI_H__ +#define __BOOTLOADER_UI_H__ + +void screen_welcome(void); +void screen_info(void); +void screen_upload_request(void); +void screen_upload_progress(int permil); +void screen_upload_success(void); +void screen_upload_abort(void); + +#endif diff --git a/extmod/modtrezorui/display.h b/extmod/modtrezorui/display.h index cfbb7b52bd..613313f0ef 100644 --- a/extmod/modtrezorui/display.h +++ b/extmod/modtrezorui/display.h @@ -8,6 +8,8 @@ #ifndef __DISPLAY_H__ #define __DISPLAY_H__ +#include + #define DISPLAY_RESX 240 #define DISPLAY_RESY 240 diff --git a/vendor/micropython b/vendor/micropython index 26604dc1ac..fa1aa1bd97 160000 --- a/vendor/micropython +++ b/vendor/micropython @@ -1 +1 @@ -Subproject commit 26604dc1ac41b432e617f56f5a35cb53820e70a4 +Subproject commit fa1aa1bd97ee3ebfa65ee6ed8123f6bc9e2033d0