diff --git a/core/embed/boardloader/main.c b/core/embed/boardloader/main.c index 7099797b5..dc33f4fb3 100644 --- a/core/embed/boardloader/main.c +++ b/core/embed/boardloader/main.c @@ -322,9 +322,7 @@ int main(void) { display_deinit(DISPLAY_JUMP_BEHAVIOR); -#ifdef ENSURE_COMPATIBLE_SETTINGS ensure_compatible_settings(); -#endif mpu_reconfig(MPU_MODE_DISABLED); diff --git a/core/embed/bootloader/main.c b/core/embed/bootloader/main.c index bf66bef5a..fd1d83ea4 100644 --- a/core/embed/bootloader/main.c +++ b/core/embed/bootloader/main.c @@ -333,9 +333,7 @@ void real_jump_to_firmware(void) { display_deinit(DISPLAY_JUMP_BEHAVIOR); -#ifdef ENSURE_COMPATIBLE_SETTINGS ensure_compatible_settings(); -#endif mpu_reconfig(MPU_MODE_DISABLED); diff --git a/core/embed/models/T2T1/boards/trezor_t.h b/core/embed/models/T2T1/boards/trezor_t.h index 922f0d5df..55c54a223 100644 --- a/core/embed/models/T2T1/boards/trezor_t.h +++ b/core/embed/models/T2T1/boards/trezor_t.h @@ -55,11 +55,4 @@ #define SD_ENABLE_PORT GPIOC #define SD_ENABLE_PIN GPIO_PIN_0 -// Ensure compatible hardware settings before jumping to -// the different booting stage. This function is used to -// ensure backward compatibility with older versions of -// released bootloaders and firmware. -#define ENSURE_COMPATIBLE_SETTINGS -extern void ensure_compatible_settings(void); - #endif //_TREZOR_T_H diff --git a/core/embed/models/T2T1/compat_settings.c b/core/embed/models/T2T1/compat_settings.c deleted file mode 100644 index c8115cb93..000000000 --- a/core/embed/models/T2T1/compat_settings.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of the Trezor project, https://trezor.io/ - * - * Copyright (c) SatoshiLabs - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "startup_init.h" - -void ensure_compatible_settings(void) { - // Early version of bootloader on T2T1 expects 168 MHz core clock. - // So we need to set it here before handover to the bootloader. - set_core_clock(CLOCK_168_MHZ); -} diff --git a/core/embed/trezorhal/bootutils.h b/core/embed/trezorhal/bootutils.h index d7ba5cfb8..683d2fae4 100644 --- a/core/embed/trezorhal/bootutils.h +++ b/core/embed/trezorhal/bootutils.h @@ -60,4 +60,12 @@ void memset_reg(volatile void *start, volatile void *stop, uint32_t val); // memory and registers that could contain sensitive information. void jump_to(uint32_t address); +// Ensure compatible hardware settings before jumping to +// the different booting stage. This function is used to +// ensure backward compatibility with older versions of +// released bootloaders and firmware. +// +// Does nothing on almost all platforms. +void ensure_compatible_settings(void); + #endif // TREZORHAL_BOOTUTILS_H diff --git a/core/embed/trezorhal/stm32f4/bootutils.c b/core/embed/trezorhal/stm32f4/bootutils.c index d2a3e0d0e..f9bd6bb1a 100644 --- a/core/embed/trezorhal/stm32f4/bootutils.c +++ b/core/embed/trezorhal/stm32f4/bootutils.c @@ -30,6 +30,10 @@ #include "model.h" #include "mpu.h" +#ifdef TREZOR_MODEL_T +#include "stm32f4/startup_init.h" +#endif + #ifdef KERNEL_MODE #ifdef STM32U5 @@ -153,9 +157,7 @@ reboot_with_args(boot_command_t command, const void* args, size_t args_size) { NVIC_SystemReset(); #else display_deinit(DISPLAY_RESET_CONTENT); -#ifdef ENSURE_COMPATIBLE_SETTINGS ensure_compatible_settings(); -#endif mpu_reconfig(MPU_MODE_DISABLED); @@ -201,4 +203,12 @@ void __attribute__((noreturn)) secure_shutdown(void) { ; } +void ensure_compatible_settings(void) { +#ifdef TREZOR_MODEL_T + // Early version of bootloader on T2T1 expects 168 MHz core clock. + // So we need to set it here before handover to the bootloader. + set_core_clock(CLOCK_168_MHZ); +#endif +} + #endif // KERNEL_MODE diff --git a/core/embed/trezorhal/unix/bootutils.c b/core/embed/trezorhal/unix/bootutils.c index 1fe3afed8..8f8a0f687 100644 --- a/core/embed/trezorhal/unix/bootutils.c +++ b/core/embed/trezorhal/unix/bootutils.c @@ -62,3 +62,7 @@ void __attribute__((noreturn)) secure_shutdown(void) { exit(3); } + +void ensure_compatible_settings(void) { + // Left empty +} diff --git a/core/site_scons/models/T2T1/trezor_t.py b/core/site_scons/models/T2T1/trezor_t.py index 68b6b8e11..f187ff179 100644 --- a/core/site_scons/models/T2T1/trezor_t.py +++ b/core/site_scons/models/T2T1/trezor_t.py @@ -39,9 +39,6 @@ def configure( defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] - sources += [ - "embed/models/T2T1/compat_settings.c", - ] if "new_rendering" in features_wanted: sources += ["embed/trezorhal/xdisplay_legacy.c"]