mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
don't halt on broken firmware but stay in bootloader mode
This commit is contained in:
parent
e0e190b3dc
commit
259eeae26e
@ -111,22 +111,18 @@ void bootloader_loop(void)
|
|||||||
usbLoop();
|
usbLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_firmware_sanity(void)
|
int check_firmware_sanity(void)
|
||||||
{
|
{
|
||||||
int broken = 0;
|
|
||||||
if (memcmp((void *)FLASH_META_MAGIC, "TRZR", 4)) { // magic does not match
|
if (memcmp((void *)FLASH_META_MAGIC, "TRZR", 4)) { // magic does not match
|
||||||
broken++;
|
return 0;
|
||||||
}
|
}
|
||||||
if (*((uint32_t *)FLASH_META_CODELEN) < 4096) { // firmware reports smaller size than 4kB
|
if (*((uint32_t *)FLASH_META_CODELEN) < 4096) { // firmware reports smaller size than 4kB
|
||||||
broken++;
|
return 0;
|
||||||
}
|
}
|
||||||
if (*((uint32_t *)FLASH_META_CODELEN) > FLASH_TOTAL_SIZE - (FLASH_APP_START - FLASH_ORIGIN)) { // firmware reports bigger size than flash size
|
if (*((uint32_t *)FLASH_META_CODELEN) > FLASH_TOTAL_SIZE - (FLASH_APP_START - FLASH_ORIGIN)) { // firmware reports bigger size than flash size
|
||||||
broken++;
|
return 0;
|
||||||
}
|
|
||||||
if (broken) {
|
|
||||||
layoutDialog(&bmp_icon_error, NULL, NULL, NULL, "Firmware appears", "to be broken.", NULL, "Unplug your TREZOR", "and see our support", "page at mytrezor.com");
|
|
||||||
system_halt();
|
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t __stack_chk_guard;
|
uint32_t __stack_chk_guard;
|
||||||
@ -148,19 +144,20 @@ int main(void)
|
|||||||
uint16_t state = gpio_port_read(BTN_PORT);
|
uint16_t state = gpio_port_read(BTN_PORT);
|
||||||
if ((state & BTN_PIN_YES) == BTN_PIN_YES || (state & BTN_PIN_NO) == BTN_PIN_NO) {
|
if ((state & BTN_PIN_YES) == BTN_PIN_YES || (state & BTN_PIN_NO) == BTN_PIN_NO) {
|
||||||
|
|
||||||
check_firmware_sanity();
|
if (check_firmware_sanity()) {
|
||||||
|
|
||||||
oledClear();
|
oledClear();
|
||||||
oledDrawBitmap(40, 0, &bmp_logo64_empty);
|
oledDrawBitmap(40, 0, &bmp_logo64_empty);
|
||||||
oledRefresh();
|
oledRefresh();
|
||||||
|
|
||||||
uint8_t hash[32];
|
uint8_t hash[32];
|
||||||
if (!signatures_ok(hash)) {
|
if (!signatures_ok(hash)) {
|
||||||
show_unofficial_warning(hash);
|
show_unofficial_warning(hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
load_app();
|
||||||
}
|
}
|
||||||
|
|
||||||
load_app();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bootloader_loop();
|
bootloader_loop();
|
||||||
|
@ -22,14 +22,14 @@
|
|||||||
|
|
||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 7
|
#define VERSION_PATCH 8
|
||||||
|
|
||||||
#define STR(X) #X
|
#define STR(X) #X
|
||||||
#define VERSTR(X) STR(X)
|
#define VERSTR(X) STR(X)
|
||||||
|
|
||||||
#define VERSION_MAJOR_CHAR "\x01"
|
#define VERSION_MAJOR_CHAR "\x01"
|
||||||
#define VERSION_MINOR_CHAR "\x02"
|
#define VERSION_MINOR_CHAR "\x02"
|
||||||
#define VERSION_PATCH_CHAR "\x07"
|
#define VERSION_PATCH_CHAR "\x08"
|
||||||
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user