From 7670958fc5a13487c28ce25faaebaac8f971bca5 Mon Sep 17 00:00:00 2001 From: cepetr Date: Thu, 3 Oct 2024 10:27:40 +0200 Subject: [PATCH] refactor(core): remove set_core_clock from emulator [no changelog] --- core/embed/bootloader/emulator.c | 2 -- core/embed/bootloader/emulator.h | 3 --- core/embed/bootloader/main.c | 4 ---- core/embed/kernel/main.c | 4 ---- core/embed/trezorhal/stm32f4/platform.h | 2 -- core/embed/trezorhal/stm32f4/system.c | 6 ++++++ core/embed/trezorhal/stm32u5/platform.h | 8 -------- 7 files changed, 6 insertions(+), 23 deletions(-) diff --git a/core/embed/bootloader/emulator.c b/core/embed/bootloader/emulator.c index a2541419ab..f0b09f8302 100644 --- a/core/embed/bootloader/emulator.c +++ b/core/embed/bootloader/emulator.c @@ -20,8 +20,6 @@ uint8_t *FIRMWARE_START = 0; -void set_core_clock(int) {} - // used in fw emulator to raise python exception on exit void __attribute__((noreturn)) main_clean_exit() { exit(3); } diff --git a/core/embed/bootloader/emulator.h b/core/embed/bootloader/emulator.h index 0084e51d1d..d54b07d9da 100644 --- a/core/embed/bootloader/emulator.h +++ b/core/embed/bootloader/emulator.h @@ -1,8 +1,6 @@ #ifndef __EMULATOR_H__ #define __EMULATOR_H__ -#define CLOCK_180_MHZ 0 - #undef FIRMWARE_START #include @@ -11,7 +9,6 @@ extern uint8_t *FIRMWARE_START; void emulator_poll_events(void); -void set_core_clock(int); __attribute__((noreturn)) void jump_to(uint32_t address); #endif diff --git a/core/embed/bootloader/main.c b/core/embed/bootloader/main.c index 7e50044a3b..392e269344 100644 --- a/core/embed/bootloader/main.c +++ b/core/embed/bootloader/main.c @@ -361,10 +361,6 @@ int bootloader_main(void) { random_delays_init(); -#if defined TREZOR_MODEL_T - set_core_clock(CLOCK_180_MHZ); -#endif - #ifdef USE_HASH_PROCESSOR hash_processor_init(); #endif diff --git a/core/embed/kernel/main.c b/core/embed/kernel/main.c index fac2f12eaf..c26e2c7b1b 100644 --- a/core/embed/kernel/main.c +++ b/core/embed/kernel/main.c @@ -69,10 +69,6 @@ static void optiga_log_hex(const char *prefix, const uint8_t *data, #endif void drivers_init() { -#if defined TREZOR_MODEL_T - set_core_clock(CLOCK_180_MHZ); -#endif - #ifdef STM32U5 tamper_init(); #endif diff --git a/core/embed/trezorhal/stm32f4/platform.h b/core/embed/trezorhal/stm32f4/platform.h index c731465446..13542a9960 100644 --- a/core/embed/trezorhal/stm32f4/platform.h +++ b/core/embed/trezorhal/stm32f4/platform.h @@ -37,6 +37,4 @@ void jump_to(uint32_t address); void jump_to_with_flag(uint32_t address, uint32_t register_flag); void clear_otg_hs_memory(void); -extern uint32_t __stack_chk_guard; - #endif // TREZORHAL_STM32_H diff --git a/core/embed/trezorhal/stm32f4/system.c b/core/embed/trezorhal/stm32f4/system.c index abe59f1125..c206f59de1 100644 --- a/core/embed/trezorhal/stm32f4/system.c +++ b/core/embed/trezorhal/stm32f4/system.c @@ -23,6 +23,7 @@ #include "bootutils.h" #include "mpu.h" +#include "platform.h" #include "systask.h" #include "system.h" #include "systick.h" @@ -35,6 +36,11 @@ #ifdef KERNEL_MODE void system_init(systask_error_handler_t error_handler) { +#if defined(TREZOR_MODEL_T) && (!defined(BOARDLOADER)) + // Early boardloader versions on Model T initialized the CPU clock to 168MHz. + // We need to set it to the STM32F429's maximum - 180MHz. + set_core_clock(CLOCK_180_MHZ); +#endif mpu_init(); mpu_reconfig(MPU_MODE_DEFAULT); systask_scheduler_init(error_handler); diff --git a/core/embed/trezorhal/stm32u5/platform.h b/core/embed/trezorhal/stm32u5/platform.h index d5c9ffb6e5..0b24be25d7 100644 --- a/core/embed/trezorhal/stm32u5/platform.h +++ b/core/embed/trezorhal/stm32u5/platform.h @@ -29,19 +29,11 @@ #define FLASH_BURST_WORDS (8 * FLASH_QUADWORD_WORDS) #define FLASH_BURST_SIZE (FLASH_BURST_WORDS * sizeof(uint32_t)) -typedef enum { - CLOCK_160_MHZ = 0, -} clock_settings_t; - -void set_core_clock(clock_settings_t settings); - // the following functions are defined in util.s void memset_reg(volatile void *start, volatile void *stop, uint32_t val); void jump_to(uint32_t address); void jump_to_with_flag(uint32_t address, uint32_t register_flag); -extern uint32_t __stack_chk_guard; - void check_oem_keys(void); #endif // TREZORHAL_STM32_H