mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 17:38:39 +00:00
boardloader+bootloader: remove prints during normal operation
This commit is contained in:
parent
78f57d083c
commit
6693d61aa0
@ -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 (;;);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user