1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 20:19:23 +00:00

refactor(core): simplify ensure_compatible_settings

[no changelog]
This commit is contained in:
cepetr 2024-10-31 21:15:18 +01:00 committed by cepetr
parent 80a67c647f
commit c997201754
8 changed files with 24 additions and 42 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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);
}

View File

@ -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

View File

@ -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

View File

@ -62,3 +62,7 @@ void __attribute__((noreturn)) secure_shutdown(void) {
exit(3);
}
void ensure_compatible_settings(void) {
// Left empty
}

View File

@ -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"]