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

refactor(core): introduce startup_init.c

[no changelog]
This commit is contained in:
cepetr 2024-10-04 11:21:32 +02:00 committed by cepetr
parent bfa3ea4e5e
commit f6647ab3b7
8 changed files with 67 additions and 13 deletions

View File

@ -1,4 +1,26 @@
/*
* 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 "platform.h"
#include "startup_init.h"
void ensure_compatible_settings(void) { set_core_clock(CLOCK_168_MHZ); }
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

@ -23,15 +23,6 @@
#include STM32_HAL_H
#include <stdint.h>
typedef enum {
CLOCK_180_MHZ = 0,
CLOCK_168_MHZ = 1,
CLOCK_120_MHZ = 2,
} 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);

View File

@ -19,6 +19,7 @@
#include STM32_HAL_H
#include "startup_init.h"
#include "platform.h"
#include "rng.h"
#include "systick.h"

View File

@ -0,0 +1,36 @@
/*
* 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/>.
*/
#ifndef TREZORHAL_STM32F4_STARTUP_INIT_H
#define TREZORHAL_STM32F4_STARTUP_INIT_H
#ifdef TREZOR_MODEL_T
typedef enum {
CLOCK_180_MHZ = 0,
CLOCK_168_MHZ = 1,
CLOCK_120_MHZ = 2,
} clock_settings_t;
// Alters core clock frequency
void set_core_clock(clock_settings_t settings);
#endif
#endif // TREZORHAL_STM32F4_STARTUP_INIT_H

View File

@ -29,6 +29,10 @@
#include "systick.h"
#include "systimer.h"
#if defined(TREZOR_MODEL_T) && (!defined(BOARDLOADER))
#include "startup_init.h"
#endif
#ifndef HardFault_IRQn
#define HardFault_IRQn (-13) // not defined in stm32lib/cmsis/stm32429xx.h
#endif

View File

@ -51,10 +51,10 @@ def stm32f4_common_files(env, defines, sources, paths):
"embed/trezorhal/stm32f4/lowlevel.c",
"embed/trezorhal/stm32f4/monoctr.c",
"embed/trezorhal/stm32f4/mpu.c",
"embed/trezorhal/stm32f4/platform.c",
"embed/trezorhal/stm32f4/random_delays.c",
"embed/trezorhal/stm32f4/rng.c",
"embed/trezorhal/stm32f4/secret.c",
"embed/trezorhal/stm32f4/startup_init.c",
"embed/trezorhal/stm32f4/syscall.c",
"embed/trezorhal/stm32f4/syscall_dispatch.c",
"embed/trezorhal/stm32f4/syscall_probe.c",

View File

@ -61,11 +61,11 @@ def stm32u5_common_files(env, defines, sources, paths):
"embed/trezorhal/stm32u5/hash_processor.c",
"embed/trezorhal/stm32u5/monoctr.c",
"embed/trezorhal/stm32u5/mpu.c",
"embed/trezorhal/stm32u5/platform.c",
"embed/trezorhal/stm32u5/random_delays.c",
"embed/trezorhal/stm32u5/rng.c",
"embed/trezorhal/stm32u5/secret.c",
"embed/trezorhal/stm32u5/secure_aes.c",
"embed/trezorhal/stm32u5/startup_init.c",
"embed/trezorhal/stm32u5/syscall.c",
"embed/trezorhal/stm32u5/syscall_dispatch.c",
"embed/trezorhal/stm32u5/syscall_probe.c",