mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
fix(core): unify error strings
This commit is contained in:
parent
38b6b9adc8
commit
ca5a68ebc5
@ -257,7 +257,7 @@ static void check_bootloader_version(void) {
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
ensure(sectrue * (0 == memcmp(bits, bits2, FLASH_OTP_BLOCK_SIZE)),
|
ensure(sectrue * (0 == memcmp(bits, bits2, FLASH_OTP_BLOCK_SIZE)),
|
||||||
"Bootloader downgraded");
|
"Bootloader downgrade protection");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -479,27 +479,27 @@ int bootloader_main(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ensure(read_vendor_header((const uint8_t *)FIRMWARE_START, &vhdr),
|
ensure(read_vendor_header((const uint8_t *)FIRMWARE_START, &vhdr),
|
||||||
"invalid vendor header");
|
"Firmware is corrupted");
|
||||||
|
|
||||||
ensure(check_vendor_header_keys(&vhdr), "invalid vendor header signature");
|
ensure(check_vendor_header_keys(&vhdr), "Firmware is corrupted");
|
||||||
|
|
||||||
ensure(check_vendor_header_lock(&vhdr), "unauthorized vendor keys");
|
ensure(check_vendor_header_lock(&vhdr), "Unauthorized vendor keys");
|
||||||
|
|
||||||
hdr = read_image_header((const uint8_t *)(FIRMWARE_START + vhdr.hdrlen),
|
hdr = read_image_header((const uint8_t *)(FIRMWARE_START + vhdr.hdrlen),
|
||||||
FIRMWARE_IMAGE_MAGIC, FIRMWARE_IMAGE_MAXSIZE);
|
FIRMWARE_IMAGE_MAGIC, FIRMWARE_IMAGE_MAXSIZE);
|
||||||
|
|
||||||
ensure(hdr == (const image_header *)(FIRMWARE_START + vhdr.hdrlen) ? sectrue
|
ensure(hdr == (const image_header *)(FIRMWARE_START + vhdr.hdrlen) ? sectrue
|
||||||
: secfalse,
|
: secfalse,
|
||||||
"invalid firmware header");
|
"Firmware is corrupted");
|
||||||
|
|
||||||
ensure(check_image_model(hdr), "wrong firmware model");
|
ensure(check_image_model(hdr), "Wrong firmware model");
|
||||||
|
|
||||||
ensure(check_image_header_sig(hdr, vhdr.vsig_m, vhdr.vsig_n, vhdr.vpub),
|
ensure(check_image_header_sig(hdr, vhdr.vsig_m, vhdr.vsig_n, vhdr.vpub),
|
||||||
"invalid firmware signature");
|
"Firmware is corrupted");
|
||||||
|
|
||||||
ensure(check_image_contents(hdr, IMAGE_HEADER_SIZE + vhdr.hdrlen,
|
ensure(check_image_contents(hdr, IMAGE_HEADER_SIZE + vhdr.hdrlen,
|
||||||
FIRMWARE_SECTORS, FIRMWARE_SECTORS_COUNT),
|
FIRMWARE_SECTORS, FIRMWARE_SECTORS_COUNT),
|
||||||
"invalid firmware hash");
|
"Firmware is corrupted");
|
||||||
|
|
||||||
// if all VTRUST flags are unset = ultimate trust => skip the procedure
|
// if all VTRUST flags are unset = ultimate trust => skip the procedure
|
||||||
|
|
||||||
@ -537,4 +537,4 @@ int bootloader_main(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardFault_Handler(void) { error_shutdown("INTERNAL ERROR!", "(HF)"); }
|
void HardFault_Handler(void) { error_shutdown("INTERNAL ERROR", "(HF)"); }
|
||||||
|
@ -184,7 +184,7 @@ int main(void) {
|
|||||||
// MicroPython default exception handler
|
// MicroPython default exception handler
|
||||||
|
|
||||||
void __attribute__((noreturn)) nlr_jump_fail(void *val) {
|
void __attribute__((noreturn)) nlr_jump_fail(void *val) {
|
||||||
error_shutdown("INTERNAL ERROR!", "(UE)");
|
error_shutdown("INTERNAL ERROR", "(UE)");
|
||||||
}
|
}
|
||||||
|
|
||||||
// interrupt handlers
|
// interrupt handlers
|
||||||
@ -192,19 +192,19 @@ void __attribute__((noreturn)) nlr_jump_fail(void *val) {
|
|||||||
void NMI_Handler(void) {
|
void NMI_Handler(void) {
|
||||||
// Clock Security System triggered NMI
|
// Clock Security System triggered NMI
|
||||||
if ((RCC->CIR & RCC_CIR_CSSF) != 0) {
|
if ((RCC->CIR & RCC_CIR_CSSF) != 0) {
|
||||||
error_shutdown("INTERNAL ERROR!", "(CS)");
|
error_shutdown("INTERNAL ERROR", "(CS)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardFault_Handler(void) { error_shutdown("INTERNAL ERROR!", "(HF)"); }
|
void HardFault_Handler(void) { error_shutdown("INTERNAL ERROR", "(HF)"); }
|
||||||
|
|
||||||
void MemManage_Handler_MM(void) { error_shutdown("INTERNAL ERROR!", "(MM)"); }
|
void MemManage_Handler_MM(void) { error_shutdown("INTERNAL ERROR", "(MM)"); }
|
||||||
|
|
||||||
void MemManage_Handler_SO(void) { error_shutdown("INTERNAL ERROR!", "(SO)"); }
|
void MemManage_Handler_SO(void) { error_shutdown("INTERNAL ERROR", "(SO)"); }
|
||||||
|
|
||||||
void BusFault_Handler(void) { error_shutdown("INTERNAL ERROR!", "(BF)"); }
|
void BusFault_Handler(void) { error_shutdown("INTERNAL ERROR", "(BF)"); }
|
||||||
|
|
||||||
void UsageFault_Handler(void) { error_shutdown("INTERNAL ERROR!", "(UF)"); }
|
void UsageFault_Handler(void) { error_shutdown("INTERNAL ERROR", "(UF)"); }
|
||||||
|
|
||||||
__attribute__((noreturn)) void reboot_to_bootloader() {
|
__attribute__((noreturn)) void reboot_to_bootloader() {
|
||||||
jump_to_with_flag(BOOTLOADER_START + IMAGE_HEADER_SIZE,
|
jump_to_with_flag(BOOTLOADER_START + IMAGE_HEADER_SIZE,
|
||||||
|
@ -19,7 +19,7 @@ pub fn __fatal_error(_expr: &str, _msg: &str, _file: &str, _line: u32, _func: &s
|
|||||||
|
|
||||||
#[cfg(not(feature = "bootloader"))]
|
#[cfg(not(feature = "bootloader"))]
|
||||||
pub fn __fatal_error(_expr: &str, msg: &str, _file: &str, _line: u32, _func: &str) -> ! {
|
pub fn __fatal_error(_expr: &str, msg: &str, _file: &str, _line: u32, _func: &str) -> ! {
|
||||||
screen_fatal_error("FATAL ERROR", msg, "PLEASE VISIT\nTREZOR.IO/RSOD");
|
screen_fatal_error("INTERNAL_ERROR", msg, "PLEASE VISIT\nTREZOR.IO/RSOD");
|
||||||
shutdown()
|
shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ extern "C" fn screen_wipe_success() {
|
|||||||
let mut frame = ResultScreen::new(
|
let mut frame = ResultScreen::new(
|
||||||
&RESULT_WIPE,
|
&RESULT_WIPE,
|
||||||
Icon::new(CHECK40),
|
Icon::new(CHECK40),
|
||||||
"Trezor reset\nsuccessfully.",
|
"Trezor reset\nsuccessfully",
|
||||||
RECONNECT_MESSAGE,
|
RECONNECT_MESSAGE,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
@ -332,7 +332,7 @@ extern "C" fn screen_wipe_fail() {
|
|||||||
let mut frame = ResultScreen::new(
|
let mut frame = ResultScreen::new(
|
||||||
&RESULT_WIPE,
|
&RESULT_WIPE,
|
||||||
Icon::new(WARNING40),
|
Icon::new(WARNING40),
|
||||||
"Trezor reset was\nnot successful.",
|
"Trezor reset was\nnot successful",
|
||||||
RECONNECT_MESSAGE,
|
RECONNECT_MESSAGE,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
@ -364,7 +364,7 @@ extern "C" fn screen_install_fail() {
|
|||||||
let mut frame = ResultScreen::new(
|
let mut frame = ResultScreen::new(
|
||||||
&RESULT_FW_INSTALL,
|
&RESULT_FW_INSTALL,
|
||||||
Icon::new(WARNING40),
|
Icon::new(WARNING40),
|
||||||
"Firmware installation was\nnot successful.",
|
"Firmware installation was not successful",
|
||||||
RECONNECT_MESSAGE,
|
RECONNECT_MESSAGE,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
@ -375,7 +375,7 @@ fn screen_install_success_bld(msg: &'static str, complete_draw: bool) {
|
|||||||
let mut frame = ResultScreen::new(
|
let mut frame = ResultScreen::new(
|
||||||
&RESULT_FW_INSTALL,
|
&RESULT_FW_INSTALL,
|
||||||
Icon::new(CHECK40),
|
Icon::new(CHECK40),
|
||||||
"Firmware installed\nsuccessfully.",
|
"Firmware installed\nsuccessfully",
|
||||||
msg,
|
msg,
|
||||||
complete_draw,
|
complete_draw,
|
||||||
);
|
);
|
||||||
@ -386,7 +386,7 @@ fn screen_install_success_initial(msg: &'static str, complete_draw: bool) {
|
|||||||
let mut frame = ResultScreen::new(
|
let mut frame = ResultScreen::new(
|
||||||
&RESULT_INITIAL,
|
&RESULT_INITIAL,
|
||||||
Icon::new(CHECK40),
|
Icon::new(CHECK40),
|
||||||
"Firmware installed\nsuccessfully.",
|
"Firmware installed\nsuccessfully",
|
||||||
msg,
|
msg,
|
||||||
complete_draw,
|
complete_draw,
|
||||||
);
|
);
|
||||||
|
@ -89,12 +89,12 @@ __fatal_error(const char *expr, const char *msg, const char *file, int line,
|
|||||||
#ifdef FANCY_FATAL_ERROR
|
#ifdef FANCY_FATAL_ERROR
|
||||||
char buf[256] = {0};
|
char buf[256] = {0};
|
||||||
mini_snprintf(buf, sizeof(buf), "%s: %d", file, line);
|
mini_snprintf(buf, sizeof(buf), "%s: %d", file, line);
|
||||||
screen_fatal_error_rust("FATAL ERROR", msg != NULL ? msg : buf,
|
screen_fatal_error_rust("INTERNAL ERROR", msg != NULL ? msg : buf,
|
||||||
"PLEASE VISIT\nTREZOR.IO/RSOD");
|
"PLEASE VISIT\nTREZOR.IO/RSOD");
|
||||||
display_refresh();
|
display_refresh();
|
||||||
#else
|
#else
|
||||||
display_print_color(COLOR_WHITE, COLOR_FATAL_ERROR);
|
display_print_color(COLOR_WHITE, COLOR_FATAL_ERROR);
|
||||||
display_printf("\nFATAL ERROR:\n");
|
display_printf("\nINTERNAL ERROR:\n");
|
||||||
if (expr) {
|
if (expr) {
|
||||||
display_printf("expr: %s\n", expr);
|
display_printf("expr: %s\n", expr);
|
||||||
}
|
}
|
||||||
|
@ -85,16 +85,18 @@ __fatal_error(const char *expr, const char *msg, const char *file, int line,
|
|||||||
msg = "Unknown error";
|
msg = "Unknown error";
|
||||||
char buf[256] = {0};
|
char buf[256] = {0};
|
||||||
snprintf(buf, sizeof(buf), "%s: %d", file, line);
|
snprintf(buf, sizeof(buf), "%s: %d", file, line);
|
||||||
screen_fatal_error_rust("FATAL ERROR", buf, "PLEASE VISIT\nTREZOR.IO/RSOD");
|
screen_fatal_error_rust("INTERNAL ERROR", buf,
|
||||||
|
"PLEASE VISIT\nTREZOR.IO/RSOD");
|
||||||
} else {
|
} else {
|
||||||
screen_fatal_error_rust("FATAL ERROR", msg, "PLEASE VISIT\nTREZOR.IO/RSOD");
|
screen_fatal_error_rust("INTERNAL ERROR", msg,
|
||||||
|
"PLEASE VISIT\nTREZOR.IO/RSOD");
|
||||||
}
|
}
|
||||||
|
|
||||||
display_refresh();
|
display_refresh();
|
||||||
#else
|
#else
|
||||||
display_print_color(COLOR_WHITE, COLOR_FATAL_ERROR);
|
display_print_color(COLOR_WHITE, COLOR_FATAL_ERROR);
|
||||||
display_printf("\nFATAL ERROR:\n");
|
display_printf("\nINTERNAL ERROR:\n");
|
||||||
printf("\nFATAL ERROR:\n");
|
printf("\nINTERNAL ERROR:\n");
|
||||||
if (expr) {
|
if (expr) {
|
||||||
display_printf("expr: %s\n", expr);
|
display_printf("expr: %s\n", expr);
|
||||||
printf("expr: %s\n", expr);
|
printf("expr: %s\n", expr);
|
||||||
|
Loading…
Reference in New Issue
Block a user