From 6693d61aa072d831d77ffad02a66892873ab1220 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Thu, 5 Oct 2017 20:18:35 +0200 Subject: [PATCH] boardloader+bootloader: remove prints during normal operation --- embed/boardloader/main.c | 26 +++++------------------- embed/bootloader/main.c | 23 +++------------------ embed/extmod/modtrezorui/display-stm32.h | 2 +- 3 files changed, 9 insertions(+), 42 deletions(-) diff --git a/embed/boardloader/main.c b/embed/boardloader/main.c index 08a94aba96..89011ac64b 100644 --- a/embed/boardloader/main.c +++ b/embed/boardloader/main.c @@ -16,20 +16,14 @@ void pendsv_isr_handler(void) { bool check_sdcard(void) { - display_printf("checking for SD card\n"); - if (!sdcard_is_present()) { - display_printf("no SD card found\n"); return false; } - display_printf("SD card found\n"); - sdcard_power_on(); uint64_t cap = sdcard_get_capacity_in_bytes(); if (cap < 1024 * 1024) { - display_printf("SD card too small\n"); sdcard_power_off(); return false; } @@ -41,10 +35,8 @@ bool check_sdcard(void) sdcard_power_off(); if (image_parse_header((const uint8_t *)buf, IMAGE_MAGIC, IMAGE_MAXSIZE, NULL)) { - display_printf("SD card header is valid\n"); return true; } else { - display_printf("SD card header is invalid\n"); return false; } } @@ -99,7 +91,8 @@ bool copy_sdcard(void) sdcard_power_off(); flash_lock(); - display_printf("done\n"); + display_printf("done\n\n"); + display_printf("Unplug the device and remove the SD card\n"); return true; } @@ -120,22 +113,15 @@ static const uint8_t * const BOARDLOADER_KEYS[] = { void check_and_jump(void) { - display_printf("checking bootloader\n"); - image_header hdr; - if (image_parse_header((const uint8_t *)BOOTLOADER_START, IMAGE_MAGIC, IMAGE_MAXSIZE, &hdr)) { - display_printf("valid bootloader header\n"); - } else { + if (!image_parse_header((const uint8_t *)BOOTLOADER_START, IMAGE_MAGIC, IMAGE_MAXSIZE, &hdr)) { display_printf("invalid bootloader header\n"); return; } if (image_check_signature((const uint8_t *)BOOTLOADER_START, &hdr, BOARDLOADER_KEY_M, BOARDLOADER_KEY_N, BOARDLOADER_KEYS)) { - display_printf("valid bootloader signature\n"); - display_printf("JUMP!\n"); jump_to(BOOTLOADER_START + HEADER_SIZE); - } else { display_printf("invalid bootloader signature\n"); } @@ -157,13 +143,11 @@ int main(void) __fatal_error("sdcard_init", __FILE__, __LINE__, __FUNCTION__); } - display_printf("TREZOR Boardloader %d.%d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_BUILD); - display_printf("==================\n"); - display_printf("starting boardloader\n"); - if (check_sdcard()) { if (!copy_sdcard()) { __fatal_error("HALT", __FILE__, __LINE__, __FUNCTION__); + } else { + for (;;); } } diff --git a/embed/bootloader/main.c b/embed/bootloader/main.c index 814f7ec953..8a3559e5b9 100644 --- a/embed/bootloader/main.c +++ b/embed/bootloader/main.c @@ -61,36 +61,24 @@ static const uint8_t * const BOOTLOADER_KEYS[] = { void check_and_jump(void) { - display_printf("checking vendor header\n"); - vendor_header vhdr; - if (vendor_parse_header((const uint8_t *)FIRMWARE_START, &vhdr)) { - display_printf("valid vendor header\n"); - } else { + if (!vendor_parse_header((const uint8_t *)FIRMWARE_START, &vhdr)) { display_printf("invalid vendor header\n"); return; } - if (vendor_check_signature((const uint8_t *)FIRMWARE_START, &vhdr, BOOTLOADER_KEY_M, BOOTLOADER_KEY_N, BOOTLOADER_KEYS)) { - display_printf("valid vendor header signature\n"); - } else { + if (!vendor_check_signature((const uint8_t *)FIRMWARE_START, &vhdr, BOOTLOADER_KEY_M, BOOTLOADER_KEY_N, BOOTLOADER_KEYS)) { display_printf("invalid vendor header signature\n"); return; } - display_printf("checking firmware header\n"); - image_header hdr; - if (image_parse_header((const uint8_t *)(FIRMWARE_START + vhdr.hdrlen), IMAGE_MAGIC, IMAGE_MAXSIZE, &hdr)) { - display_printf("valid firmware header\n"); - } else { + if (!image_parse_header((const uint8_t *)(FIRMWARE_START + vhdr.hdrlen), IMAGE_MAGIC, IMAGE_MAXSIZE, &hdr)) { display_printf("invalid firmware header\n"); return; } if (image_check_signature((const uint8_t *)(FIRMWARE_START + vhdr.hdrlen), &hdr, vhdr.vsig_m, vhdr.vsig_n, vhdr.vpub)) { - display_printf("valid firmware signature\n"); - display_vendor(vhdr.vimg, (const char *)vhdr.vstr, vhdr.vstr_len, hdr.version); if (vhdr.vtrust < 50) { touch_click(); @@ -98,7 +86,6 @@ void check_and_jump(void) hal_delay(1000); } jump_to(FIRMWARE_START + vhdr.hdrlen + HEADER_SIZE); - } else { display_printf("invalid firmware signature\n"); } @@ -216,10 +203,6 @@ int main(void) __fatal_error("touch_init", __FILE__, __LINE__, __FUNCTION__); } - display_printf("TREZOR Bootloader %d.%d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_BUILD); - display_printf("=================\n"); - display_printf("starting bootloader\n"); - uint32_t touched = 0; for (int i = 0; i < 10; i++) { touched |= touch_read(); diff --git a/embed/extmod/modtrezorui/display-stm32.h b/embed/extmod/modtrezorui/display-stm32.h index 9bf2df5aa2..4a20e83b78 100644 --- a/embed/extmod/modtrezorui/display-stm32.h +++ b/embed/extmod/modtrezorui/display-stm32.h @@ -139,6 +139,7 @@ void display_pwm_init(void) TIM_OC_InitStructure.OCIdleState = TIM_OCIDLESTATE_SET; TIM_OC_InitStructure.OCNIdleState = TIM_OCNIDLESTATE_SET; HAL_TIM_PWM_ConfigChannel(&TIM1_Handle, &TIM_OC_InitStructure, TIM_CHANNEL_1); + display_set_backlight(0); HAL_TIM_PWM_Start(&TIM1_Handle, TIM_CHANNEL_1); HAL_TIMEx_PWMN_Start(&TIM1_Handle, TIM_CHANNEL_1); } @@ -278,7 +279,6 @@ int display_init(void) { display_clear(); display_orientation(0); display_unsleep(); - display_backlight(255); return 0; }