diff --git a/Makefile.loader b/Makefile.loader index 969ff863..e3eb03a5 100644 --- a/Makefile.loader +++ b/Makefile.loader @@ -59,6 +59,7 @@ OBJ_FW += $(addprefix $(BUILD_FW)/, \ loader/header.o \ loader/main.o \ extmod/modtrezorui/display.o \ + extmod/modtrezorui/inflate.o \ extmod/modtrezorui/font_bitmap.o \ trezorhal/common.o \ trezorhal/image.o \ diff --git a/micropython/extmod/modtrezorui/modtrezorui-display.h b/micropython/extmod/modtrezorui/modtrezorui-display.h index b0aa7547..61695043 100644 --- a/micropython/extmod/modtrezorui/modtrezorui-display.h +++ b/micropython/extmod/modtrezorui/modtrezorui-display.h @@ -94,7 +94,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_image(size_t n_args, const mp_obj_t *args) if (datalen != image.len - 12) { mp_raise_ValueError("Invalid size of data"); } - display_image(x, y, w, h, data + 12, image.len - 12); + display_image(x, y, w, h, data + 12, datalen); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_image_obj, 4, 4, mod_TrezorUi_Display_image); diff --git a/micropython/loader/main.c b/micropython/loader/main.c index b23443b3..44417e22 100644 --- a/micropython/loader/main.c +++ b/micropython/loader/main.c @@ -1,5 +1,7 @@ #include STM32_HAL_H +#include + #include "common.h" #include "display.h" #include "image.h" @@ -14,6 +16,17 @@ void pendsv_isr_handler(void) { __fatal_error("pendsv"); } +void display_vendor(const uint8_t *vimg) +{ + if (memcmp(vimg, "TOIf", 4) != 0) { + return; + } + uint16_t w = *(uint16_t *)(vimg + 4); + uint16_t h = *(uint16_t *)(vimg + 6); + uint32_t datalen = *(uint32_t *)(vimg + 8); + display_image(0, 0, w, h, vimg + 12, datalen); +} + void check_and_jump(void) { LOADER_PRINTLN("checking firmware"); @@ -32,7 +45,7 @@ void check_and_jump(void) if (image_check_signature((const uint8_t *)(FIRMWARE_START + vhdr.hdrlen))) { LOADER_PRINTLN("valid firmware image"); // TODO: remove debug wait - LOADER_PRINTLN("waiting 1 second"); + display_vendor(vhdr.vimg); HAL_Delay(1000); // end LOADER_PRINTLN("JUMP!");