diff --git a/core/embed/boardloader/main.c b/core/embed/boardloader/main.c
index dc33f4fb32..e429e0a483 100644
--- a/core/embed/boardloader/main.c
+++ b/core/embed/boardloader/main.c
@@ -17,20 +17,18 @@
* along with this program. If not, see .
*/
-#include
+#include
+#include
-#include TREZOR_BOARD
#include "board_capabilities.h"
#include "bootutils.h"
#include "buffers.h"
-#include "common.h"
#include "compiler_traits.h"
#include "display.h"
#include "display_draw.h"
#include "flash.h"
#include "flash_utils.h"
#include "image.h"
-#include "model.h"
#include "mpu.h"
#include "pvd.h"
#include "reset_flags.h"
@@ -38,6 +36,7 @@
#include "rsod.h"
#include "secret.h"
#include "system.h"
+#include "systick.h"
#include "terminal.h"
#ifdef USE_SD_CARD
@@ -59,7 +58,6 @@
#endif
#include "memzero.h"
-#include "model.h"
#include "monoctr.h"
#include "option_bytes.h"
#include "tamper.h"
diff --git a/core/embed/bootloader/bootui.c b/core/embed/bootloader/bootui.c
index cb1e2e320b..594202f083 100644
--- a/core/embed/bootloader/bootui.c
+++ b/core/embed/bootloader/bootui.c
@@ -17,9 +17,7 @@
* along with this program. If not, see .
*/
-#include
-
-#include TREZOR_BOARD
+#include
#include "bootui.h"
#include "colors.h"
diff --git a/core/embed/bootloader/bootui.h b/core/embed/bootloader/bootui.h
index 4b29f01532..a9922154af 100644
--- a/core/embed/bootloader/bootui.h
+++ b/core/embed/bootloader/bootui.h
@@ -20,10 +20,9 @@
#ifndef __BOOTUI_H__
#define __BOOTUI_H__
+#include
+
#include "image.h"
-#include "secbool.h"
-#include "stdbool.h"
-#include TREZOR_BOARD
typedef enum {
SCREEN_INTRO = 0,
diff --git a/core/embed/bootloader/emulator.c b/core/embed/bootloader/emulator.c
index 0fc61c68bb..ac6791182c 100644
--- a/core/embed/bootloader/emulator.c
+++ b/core/embed/bootloader/emulator.c
@@ -1,20 +1,20 @@
-#include
+#include
+#include
+
#include
#include
-#include TREZOR_BOARD
#include "bootargs.h"
#include "bootui.h"
-#include "common.h"
#include "display.h"
#include "flash.h"
#include "flash_otp.h"
-#include "model.h"
#include "rust_ui.h"
#ifdef USE_OPTIGA
#include "secret.h"
#endif
+#include "systick.h"
#include "emulator.h"
diff --git a/core/embed/bootloader/emulator.h b/core/embed/bootloader/emulator.h
index ee589acb55..aa90a93f82 100644
--- a/core/embed/bootloader/emulator.h
+++ b/core/embed/bootloader/emulator.h
@@ -1,10 +1,9 @@
#ifndef __EMULATOR_H__
#define __EMULATOR_H__
-#undef FIRMWARE_START
+#include
-#include
-#include
+#undef FIRMWARE_START
extern uint8_t *FIRMWARE_START;
diff --git a/core/embed/bootloader/main.c b/core/embed/bootloader/main.c
index fd1d83ea4d..553df46a47 100644
--- a/core/embed/bootloader/main.c
+++ b/core/embed/bootloader/main.c
@@ -17,12 +17,13 @@
* along with this program. If not, see .
*/
-#include
+#include
+#include
+
#include
#include "bootargs.h"
#include "bootutils.h"
-#include "common.h"
#include "display.h"
#include "display_utils.h"
#include "flash.h"
@@ -35,9 +36,9 @@
#include "pvd.h"
#include "random_delays.h"
#include "rsod.h"
-#include "secbool.h"
#include "secret.h"
#include "system.h"
+#include "systick.h"
#include "systimer.h"
#ifdef USE_DMA2D
@@ -66,7 +67,6 @@
#include "hash_processor.h"
#endif
-#include "model.h"
#include "usb.h"
#include "version.h"
diff --git a/core/embed/bootloader/messages.c b/core/embed/bootloader/messages.c
index 10cda4aff2..eeeb50c71b 100644
--- a/core/embed/bootloader/messages.c
+++ b/core/embed/bootloader/messages.c
@@ -17,7 +17,8 @@
* along with this program. If not, see .
*/
-#include
+#include
+#include
#include
#include
@@ -25,11 +26,9 @@
#include "messages.pb.h"
#include "bootargs.h"
-#include "common.h"
#include "flash.h"
#include "flash_utils.h"
#include "image.h"
-#include "secbool.h"
#include "secret.h"
#include "unit_properties.h"
#include "usb.h"
@@ -41,7 +40,6 @@
#include "version_check.h"
#include "memzero.h"
-#include "model.h"
#ifdef TREZOR_EMULATOR
#include "emulator.h"
diff --git a/core/embed/bootloader/messages.h b/core/embed/bootloader/messages.h
index ad8e3f4211..c8fcb34c56 100644
--- a/core/embed/bootloader/messages.h
+++ b/core/embed/bootloader/messages.h
@@ -20,10 +20,9 @@
#ifndef __MESSAGES_H__
#define __MESSAGES_H__
-#include
+#include
+
#include "image.h"
-#include "secbool.h"
-#include TREZOR_BOARD
#define USB_TIMEOUT 500
#define USB_PACKET_SIZE 64
diff --git a/core/embed/bootloader/version_check.c b/core/embed/bootloader/version_check.c
index ae7d225154..0d96c53513 100644
--- a/core/embed/bootloader/version_check.c
+++ b/core/embed/bootloader/version_check.c
@@ -17,13 +17,11 @@
* along with this program. If not, see .
*/
-#include
+#include
-#include "version_check.h"
-
-#include "error_handling.h"
#include "model_version.h"
#include "monoctr.h"
+#include "version_check.h"
void ensure_bootloader_min_version(void) {
monoctr_write(MONOCTR_BOOTLOADER_VERSION, BOOTLOADER_MONOTONIC_VERSION);
diff --git a/core/embed/bootloader/version_check.h b/core/embed/bootloader/version_check.h
index a7011808b5..4572d3c8ec 100644
--- a/core/embed/bootloader/version_check.h
+++ b/core/embed/bootloader/version_check.h
@@ -19,8 +19,7 @@
#pragma once
-#include
-#include "secbool.h"
+#include
// Protection against bootloader downgrade
diff --git a/core/embed/bootloader_ci/bootui.c b/core/embed/bootloader_ci/bootui.c
index 7b6a4e288e..580bc13646 100644
--- a/core/embed/bootloader_ci/bootui.c
+++ b/core/embed/bootloader_ci/bootui.c
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-#include
+#include
#include "bootui.h"
#include "display.h"
diff --git a/core/embed/bootloader_ci/bootui.h b/core/embed/bootloader_ci/bootui.h
index 4d71c5f8c7..b63cfc24b0 100644
--- a/core/embed/bootloader_ci/bootui.h
+++ b/core/embed/bootloader_ci/bootui.h
@@ -20,7 +20,7 @@
#ifndef __BOOTUI_H__
#define __BOOTUI_H__
-#include "secbool.h"
+#include
void ui_screen_welcome_third(void);
diff --git a/core/embed/bootloader_ci/main.c b/core/embed/bootloader_ci/main.c
index d44584f663..bc4a8d4782 100644
--- a/core/embed/bootloader_ci/main.c
+++ b/core/embed/bootloader_ci/main.c
@@ -17,11 +17,11 @@
* along with this program. If not, see .
*/
-#include
-#include
+#include
+#include
+#include
#include "bootutils.h"
-#include "common.h"
#include "display.h"
#include "display_draw.h"
#include "flash.h"
@@ -32,8 +32,8 @@
#include "random_delays.h"
#include "rng.h"
#include "rsod.h"
-#include "secbool.h"
#include "system.h"
+#include "systick.h"
#ifdef USE_TOUCH
#include "touch.h"
#endif
@@ -42,7 +42,6 @@
#include "bootui.h"
#include "messages.h"
-#include "model.h"
#include "version_check.h"
#ifdef USE_HASH_PROCESSOR
diff --git a/core/embed/bootloader_ci/messages.c b/core/embed/bootloader_ci/messages.c
index fd40c5fc33..e2b0a81d44 100644
--- a/core/embed/bootloader_ci/messages.c
+++ b/core/embed/bootloader_ci/messages.c
@@ -17,19 +17,17 @@
* along with this program. If not, see .
*/
-#include
+#include
+#include
#include
#include
#include
#include "messages.pb.h"
-#include "common.h"
#include "flash.h"
#include "flash_utils.h"
#include "image.h"
-#include "model.h"
-#include "secbool.h"
#include "usb.h"
#include "version.h"
diff --git a/core/embed/bootloader_ci/messages.h b/core/embed/bootloader_ci/messages.h
index 0937f60627..37656c5866 100644
--- a/core/embed/bootloader_ci/messages.h
+++ b/core/embed/bootloader_ci/messages.h
@@ -20,9 +20,9 @@
#ifndef __MESSAGES_H__
#define __MESSAGES_H__
-#include
+#include
+
#include "image.h"
-#include "secbool.h"
#define USB_TIMEOUT 500
#define USB_PACKET_SIZE 64
diff --git a/core/embed/extmod/modtrezorconfig/modtrezorconfig.c b/core/embed/extmod/modtrezorconfig/modtrezorconfig.c
index 10df09495e..c535b4c7ab 100644
--- a/core/embed/extmod/modtrezorconfig/modtrezorconfig.c
+++ b/core/embed/extmod/modtrezorconfig/modtrezorconfig.c
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-#include
+#include
#include "py/mphal.h"
#include "py/objstr.h"
@@ -27,7 +27,6 @@
#include "embed/extmod/trezorobj.h"
-#include "common.h"
#include "entropy.h"
#include "memzero.h"
#include "storage.h"
diff --git a/core/embed/extmod/modtrezorconfig/norcow_config.h b/core/embed/extmod/modtrezorconfig/norcow_config.h
index f9233cb7e2..e0bae4f4b7 100644
--- a/core/embed/extmod/modtrezorconfig/norcow_config.h
+++ b/core/embed/extmod/modtrezorconfig/norcow_config.h
@@ -20,9 +20,10 @@
#ifndef __NORCOW_CONFIG_H__
#define __NORCOW_CONFIG_H__
-#include TREZOR_BOARD
+#include
+#include
+
#include "flash.h"
-#include "model.h"
#define NORCOW_HEADER_LEN 0
#define NORCOW_SECTOR_COUNT 2
diff --git a/core/embed/extmod/modtrezorcrypto/crc.h b/core/embed/extmod/modtrezorcrypto/crc.h
index 34347b52de..2606b5f8f8 100644
--- a/core/embed/extmod/modtrezorcrypto/crc.h
+++ b/core/embed/extmod/modtrezorcrypto/crc.h
@@ -20,7 +20,7 @@
#ifndef __CRC_H__
#define __CRC_H__
-#include
+#include
uint32_t checksum_crc32(const uint8_t *data, uint32_t length, uint32_t crc);
diff --git a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto.c b/core/embed/extmod/modtrezorcrypto/modtrezorcrypto.c
index 13282bd93a..e8e16a76fe 100644
--- a/core/embed/extmod/modtrezorcrypto/modtrezorcrypto.c
+++ b/core/embed/extmod/modtrezorcrypto/modtrezorcrypto.c
@@ -17,16 +17,10 @@
* along with this program. If not, see .
*/
-#include
-#include
-#include
-
-#include "common.h"
+#include
#include "py/runtime.h"
-#include TREZOR_BOARD
-
#if MICROPY_PY_TREZORCRYPTO
static mp_obj_t ui_wait_callback = mp_const_none;
diff --git a/core/embed/extmod/modtrezorio/ff.c b/core/embed/extmod/modtrezorio/ff.c
index ae62e0efc2..3fe3754aae 100644
--- a/core/embed/extmod/modtrezorio/ff.c
+++ b/core/embed/extmod/modtrezorio/ff.c
@@ -21,7 +21,8 @@
/----------------------------------------------------------------------------*/
-#include
+#include
+
#include "ff.h" /* Declarations of FatFs API */
#include "diskio.h" /* Declarations of device I/O functions */
diff --git a/core/embed/extmod/modtrezorio/modtrezorio-poll.h b/core/embed/extmod/modtrezorio/modtrezorio-poll.h
index c07904e560..e7bbc6603e 100644
--- a/core/embed/extmod/modtrezorio/modtrezorio-poll.h
+++ b/core/embed/extmod/modtrezorio/modtrezorio-poll.h
@@ -17,11 +17,12 @@
* along with this program. If not, see .
*/
-#include
+#include
#include "button.h"
-#include "common.h"
#include "display.h"
+#include "systick.h"
+
#include "embed/extmod/trezorobj.h"
#ifdef TREZOR_EMULATOR
diff --git a/core/embed/extmod/modtrezorio/modtrezorio.c b/core/embed/extmod/modtrezorio/modtrezorio.c
index 74ad336ba7..75a5501c5e 100644
--- a/core/embed/extmod/modtrezorio/modtrezorio.c
+++ b/core/embed/extmod/modtrezorio/modtrezorio.c
@@ -17,7 +17,9 @@
* along with this program. If not, see .
*/
-#include
+#include
+
+#include
#include "py/mphal.h"
#include "py/objstr.h"
@@ -25,9 +27,6 @@
#if MICROPY_PY_TREZORIO
-#include
-
-#include TREZOR_BOARD
#include "button.h"
#include "touch.h"
#include "usb.h"
diff --git a/core/embed/extmod/modtrezorui/modtrezorui.c b/core/embed/extmod/modtrezorui/modtrezorui.c
index ce587d597b..e6a42cccac 100644
--- a/core/embed/extmod/modtrezorui/modtrezorui.c
+++ b/core/embed/extmod/modtrezorui/modtrezorui.c
@@ -17,9 +17,7 @@
* along with this program. If not, see .
*/
-#include
-#include
-#include
+#include
#include "py/runtime.h"
diff --git a/core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h b/core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h
index bf2887ca26..55fdfd3770 100644
--- a/core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h
+++ b/core/embed/extmod/modtrezorutils/modtrezorutils-meminfo.h
@@ -22,6 +22,8 @@
#else
+#include
+
#include "py/bc.h"
#include "py/gc.h"
#include "py/nlr.h"
@@ -36,9 +38,6 @@
#include "embed/rust/librust.h"
#include "embed/trezorhal/usb.h"
-#include
-#include
-
#define WORDS_PER_BLOCK ((MICROPY_BYTES_PER_GC_BLOCK) / MP_BYTES_PER_OBJ_WORD)
#define BYTES_PER_BLOCK (MICROPY_BYTES_PER_GC_BLOCK)
diff --git a/core/embed/extmod/modtrezorutils/modtrezorutils.c b/core/embed/extmod/modtrezorutils/modtrezorutils.c
index ca04f00b41..89a8ed3df3 100644
--- a/core/embed/extmod/modtrezorutils/modtrezorutils.c
+++ b/core/embed/extmod/modtrezorutils/modtrezorutils.c
@@ -17,6 +17,9 @@
* along with this program. If not, see .
*/
+#include
+#include
+
#include "py/objstr.h"
#include "py/runtime.h"
@@ -28,15 +31,11 @@
#include "embed/extmod/modtrezorutils/modtrezorutils-meminfo.h"
#include "embed/extmod/trezorobj.h"
-#include
#include "blake2s.h"
#include "bootutils.h"
-#include "error_handling.h"
#include "fwutils.h"
#include "unit_properties.h"
#include "usb.h"
-#include TREZOR_BOARD
-#include "model.h"
#if USE_OPTIGA && !defined(TREZOR_EMULATOR)
#include "secret.h"
diff --git a/core/embed/extmod/trezorobj.c b/core/embed/extmod/trezorobj.c
index 71166dec9c..44c07c038e 100644
--- a/core/embed/extmod/trezorobj.c
+++ b/core/embed/extmod/trezorobj.c
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-#include
+#include
#include "memzero.h"
#include "py/obj.h"
diff --git a/core/embed/firmware/main.c b/core/embed/firmware/main.c
index 99c29dba3d..d59ace6257 100644
--- a/core/embed/firmware/main.c
+++ b/core/embed/firmware/main.c
@@ -17,11 +17,7 @@
* along with this program. If not, see .
*/
-#include STM32_HAL_H
-
-#include
-#include
-#include
+#include
#include "py/builtin.h"
#include "py/compile.h"
@@ -36,10 +32,8 @@
#include "ports/stm32/gccollect.h"
#include "ports/stm32/pendsv.h"
-#include "error_handling.h"
#include "rsod.h"
#include "rust_ui_common.h"
-#include "secbool.h"
#include "systask.h"
#include "system.h"
diff --git a/core/embed/firmware/mphalport.c b/core/embed/firmware/mphalport.c
index 9509ca37d5..b3428c16a9 100644
--- a/core/embed/firmware/mphalport.c
+++ b/core/embed/firmware/mphalport.c
@@ -17,7 +17,8 @@
* along with this program. If not, see .
*/
-#include "common.h"
+#include
+
#include "py/mphal.h"
#include "systick.h"
diff --git a/core/embed/firmware/systemview.c b/core/embed/firmware/systemview.c
index c89c5b95d3..ca171d6569 100644
--- a/core/embed/firmware/systemview.c
+++ b/core/embed/firmware/systemview.c
@@ -19,9 +19,10 @@
#ifdef SYSTEM_VIEW
-#include "systemview.h"
-#include
+#include
+
#include "mpconfigport.h"
+#include "systemview.h"
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_SYSVIEW_Conf.h"
diff --git a/core/embed/kernel/main.c b/core/embed/kernel/main.c
index 47c8160ba5..b140a3c87c 100644
--- a/core/embed/kernel/main.c
+++ b/core/embed/kernel/main.c
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-#include
+#include
#include "applet.h"
#include "bl_check.h"
diff --git a/core/embed/lib/bl_check.c b/core/embed/lib/bl_check.c
index 02fd714806..3a62f6f8b7 100644
--- a/core/embed/lib/bl_check.c
+++ b/core/embed/lib/bl_check.c
@@ -17,15 +17,14 @@
* along with this program. If not, see .
*/
-#include
-#include
+#include
+#include
+
#include "blake2s.h"
#include "board_capabilities.h"
-#include "common.h"
#include "flash.h"
#include "image.h"
#include "memzero.h"
-#include "model.h"
#include "mpu.h"
#include "uzlib.h"
diff --git a/core/embed/lib/buffers.c b/core/embed/lib/buffers.c
index cbf53a322a..eddaef5607 100644
--- a/core/embed/lib/buffers.c
+++ b/core/embed/lib/buffers.c
@@ -17,8 +17,9 @@
* along with this program. If not, see .
*/
+#include
+
#include "buffers.h"
-#include "common.h"
#include "fonts/fonts.h"
#include "memzero.h"
diff --git a/core/embed/lib/buffers.h b/core/embed/lib/buffers.h
index 4203338a02..6eac01580d 100644
--- a/core/embed/lib/buffers.h
+++ b/core/embed/lib/buffers.h
@@ -20,11 +20,8 @@
#ifndef _BUFFERS_H
#define _BUFFERS_H
-#include
-
-#include "common.h"
-#include "model.h"
-#include TREZOR_BOARD
+#include
+#include
#define BUFFER_PIXELS DISPLAY_RESX
diff --git a/core/embed/lib/colors.h b/core/embed/lib/colors.h
index 1451959c76..7a92ca1761 100644
--- a/core/embed/lib/colors.h
+++ b/core/embed/lib/colors.h
@@ -20,8 +20,7 @@
#ifndef _COLORS_H
#define _COLORS_H
-#include "common.h"
-#include TREZOR_BOARD
+#include
#ifdef USE_RGB_COLORS
#define RGB16(R, G, B) ((R & 0xF8) << 8) | ((G & 0xFC) << 3) | ((B & 0xF8) >> 3)
diff --git a/core/embed/lib/common.h b/core/embed/lib/common.h
new file mode 100644
index 0000000000..a2f5826dc1
--- /dev/null
+++ b/core/embed/lib/common.h
@@ -0,0 +1,31 @@
+/*
+ * 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 .
+ */
+
+#ifndef LIB_COMMON_H
+
+// This header is included in storage modules that expect to find common
+// functions like `ensure()`, `error_shutdown()`, or `hal_delay()`.
+//
+// Do not include this header or add dependencies to it unless required by
+// storage.
+
+#include "error_handling.h"
+#include "systick.h"
+
+#endif // LIB_COMMON_H
diff --git a/core/embed/lib/display_draw.c b/core/embed/lib/display_draw.c
index 289b2ce16c..a90f3be3e5 100644
--- a/core/embed/lib/display_draw.c
+++ b/core/embed/lib/display_draw.c
@@ -19,23 +19,20 @@
#define _GNU_SOURCE
-#include "display_draw.h"
+#include
+
+#include
+
#include "buffers.h"
-#include "common.h"
+#include "display.h"
+#include "display_draw.h"
+#include "fonts/fonts.h"
+#include "memzero.h"
#ifdef USE_DMA2D
#include "dma2d.h"
#endif
-#include "fonts/fonts.h"
-
-#include
-#include
-
-#include "memzero.h"
-
-#include "display.h"
-
static struct {
int x, y;
} DISPLAY_OFFSET;
diff --git a/core/embed/lib/display_draw.h b/core/embed/lib/display_draw.h
index dcd046681d..0facb5db14 100644
--- a/core/embed/lib/display_draw.h
+++ b/core/embed/lib/display_draw.h
@@ -20,13 +20,10 @@
#ifndef __DISPLAY_DRAW_H__
#define __DISPLAY_DRAW_H__
-#include
-#include
-#include
+#include
#include "buffers.h"
#include "colors.h"
-#include TREZOR_BOARD
#include "fonts/fonts.h"
// provided by common
diff --git a/core/embed/lib/display_utils.c b/core/embed/lib/display_utils.c
index 81846e00e1..8fb4d12634 100644
--- a/core/embed/lib/display_utils.c
+++ b/core/embed/lib/display_utils.c
@@ -17,8 +17,10 @@
* along with this program. If not, see .
*/
-#include "common.h"
+#include
+
#include "display.h"
+#include "systick.h"
void display_fade(int start, int end, int delay) {
#ifdef USE_BACKLIGHT
diff --git a/core/embed/lib/error_handling.c b/core/embed/lib/error_handling.c
index 437dc439c0..6691d37e44 100644
--- a/core/embed/lib/error_handling.c
+++ b/core/embed/lib/error_handling.c
@@ -17,10 +17,8 @@
* along with this program. If not, see .
*/
-#include
-#include
+#include
-#include "error_handling.h"
#include "system.h"
#ifndef TREZOR_EMULATOR
diff --git a/core/embed/lib/flash_utils.c b/core/embed/lib/flash_utils.c
index 80112cf6c6..4e3c4bf346 100644
--- a/core/embed/lib/flash_utils.c
+++ b/core/embed/lib/flash_utils.c
@@ -17,14 +17,12 @@
* along with this program. If not, see .
*/
-#include TREZOR_BOARD
+#include
+#include
-#include "flash_utils.h"
-#include "common.h"
#include "flash_area.h"
-#include "model.h"
+#include "flash_utils.h"
#include "mpu.h"
-#include "secbool.h"
typedef struct {
const flash_area_t* area;
diff --git a/core/embed/lib/flash_utils.h b/core/embed/lib/flash_utils.h
index 04f14d8792..bd973fb9f5 100644
--- a/core/embed/lib/flash_utils.h
+++ b/core/embed/lib/flash_utils.h
@@ -20,7 +20,7 @@
#ifndef LIB_FLASH_UTILS_H
#define LIB_FLASH_UTILS_H
-#include "secbool.h"
+#include
#ifdef KERNEL_MODE
diff --git a/core/embed/lib/fonts/font_bitmap.h b/core/embed/lib/fonts/font_bitmap.h
index e9b9dd841d..f8ab8e384d 100644
--- a/core/embed/lib/fonts/font_bitmap.h
+++ b/core/embed/lib/fonts/font_bitmap.h
@@ -1,3 +1,3 @@
-#include
+#include
extern const uint8_t* const Font_Bitmap;
diff --git a/core/embed/lib/fonts/fonts.c b/core/embed/lib/fonts/fonts.c
index d2e6a73962..92617d9944 100644
--- a/core/embed/lib/fonts/fonts.c
+++ b/core/embed/lib/fonts/fonts.c
@@ -17,11 +17,9 @@
* along with this program. If not, see .
*/
+#include
+
#include "fonts.h"
-#include
-#include
-#include
-#include
#ifdef TRANSLATIONS
#include "librust_fonts.h"
#endif
diff --git a/core/embed/lib/fonts/fonts.h b/core/embed/lib/fonts/fonts.h
index 2e4405e903..fd4408103c 100644
--- a/core/embed/lib/fonts/fonts.h
+++ b/core/embed/lib/fonts/fonts.h
@@ -23,7 +23,6 @@
#include
#include "fonts/font_bitmap.h"
-#include TREZOR_BOARD
#ifdef USE_RGB_COLORS
#define TREZOR_FONT_BPP 4
diff --git a/core/embed/lib/gfx_bitblt.h b/core/embed/lib/gfx_bitblt.h
index f897d933b5..88f5815526 100644
--- a/core/embed/lib/gfx_bitblt.h
+++ b/core/embed/lib/gfx_bitblt.h
@@ -20,8 +20,7 @@
#ifndef GFX_BITBLT_H
#define GFX_BITBLT_H
-#include
-#include
+#include
#include "gfx_color.h"
diff --git a/core/embed/lib/gfx_color.h b/core/embed/lib/gfx_color.h
index 5cbfd9f1ca..c67998ae41 100644
--- a/core/embed/lib/gfx_color.h
+++ b/core/embed/lib/gfx_color.h
@@ -20,7 +20,7 @@
#ifndef GFX_COLOR_H
#define GFX_COLOR_H
-#include
+#include
#ifdef UI_COLOR_32BIT
#define GFX_COLOR_32BIT
diff --git a/core/embed/lib/gfx_draw.c b/core/embed/lib/gfx_draw.c
index 070a4b310c..ef73105854 100644
--- a/core/embed/lib/gfx_draw.c
+++ b/core/embed/lib/gfx_draw.c
@@ -17,8 +17,9 @@
* along with this program. If not, see .
*/
-#include
+#include
+#include "display.h"
#include "display_draw.h"
#include "fonts/fonts.h"
#include "gfx_draw.h"
diff --git a/core/embed/lib/image.c b/core/embed/lib/image.c
index 874e9d39e7..c2fd7bf863 100644
--- a/core/embed/lib/image.c
+++ b/core/embed/lib/image.c
@@ -17,14 +17,13 @@
* along with this program. If not, see .
*/
-#include
+#include
+#include
#include "ed25519-donna/ed25519.h"
-#include "common.h"
#include "flash.h"
#include "image.h"
-#include "model.h"
_Static_assert(VENDOR_HEADER_MAX_SIZE + IMAGE_HEADER_SIZE <= IMAGE_CHUNK_SIZE,
"The size of the firmware headers must be less than or equal to "
diff --git a/core/embed/lib/image.h b/core/embed/lib/image.h
index 9ca8c2209a..a2d02dd105 100644
--- a/core/embed/lib/image.h
+++ b/core/embed/lib/image.h
@@ -20,12 +20,12 @@
#ifndef __TREZORHAL_IMAGE_H__
#define __TREZORHAL_IMAGE_H__
-#include
+#include
+#include
+
#include "blake2s.h"
#include "flash.h"
#include "image_hash_conf.h"
-#include "model.h"
-#include "secbool.h"
#define VENDOR_HEADER_MAX_SIZE (64 * 1024)
#define IMAGE_HEADER_SIZE 0x400 // size of the bootloader or firmware header
diff --git a/core/embed/lib/image_hash_conf.h b/core/embed/lib/image_hash_conf.h
index e8108070c7..e7acaa3564 100644
--- a/core/embed/lib/image_hash_conf.h
+++ b/core/embed/lib/image_hash_conf.h
@@ -1,8 +1,8 @@
#ifndef LIB_IMAGE_HASH_H_
#define LIB_IMAGE_HASH_H_
-#include "model.h"
-#include TREZOR_BOARD
+#include
+#include
#ifdef IMAGE_HASH_SHA256
#include "sha2.h"
diff --git a/core/embed/lib/mini_printf.c b/core/embed/lib/mini_printf.c
index 907dc50c24..8360d7ddc0 100644
--- a/core/embed/lib/mini_printf.c
+++ b/core/embed/lib/mini_printf.c
@@ -43,8 +43,8 @@
*
*/
-#include
-#include
+#include
+
#include "mini_printf.h"
static unsigned int
diff --git a/core/embed/lib/mini_printf.h b/core/embed/lib/mini_printf.h
index b3a21eab17..66baf4e7b0 100644
--- a/core/embed/lib/mini_printf.h
+++ b/core/embed/lib/mini_printf.h
@@ -33,12 +33,14 @@
#ifndef __MINI_PRINTF__
#define __MINI_PRINTF__
+#include
+
+#include
+
#ifdef __cplusplus
extern "C" {
#endif
-#include
-
int mini_vsnprintf(char* buffer, unsigned int buffer_len, const char *fmt, va_list va) __attribute__ ((__format__ (__printf__, 3, 0)));
int mini_snprintf(char* buffer, unsigned int buffer_len, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
diff --git a/core/embed/lib/terminal.c b/core/embed/lib/terminal.c
index 70f3815351..79f5f300cb 100644
--- a/core/embed/lib/terminal.c
+++ b/core/embed/lib/terminal.c
@@ -17,11 +17,8 @@
* along with this program. If not, see .
*/
-#include TREZOR_BOARD
-
-#include
-#include
-#include
+#include
+#include
#include "display.h"
#include "fonts/fonts.h"
diff --git a/core/embed/lib/translations.c b/core/embed/lib/translations.c
index 5053538ef0..e9dcbb6c01 100644
--- a/core/embed/lib/translations.c
+++ b/core/embed/lib/translations.c
@@ -1,11 +1,9 @@
-#include "translations.h"
-#include
-#include
-#include
-#include "common.h"
+#include
+#include
+
#include "flash.h"
-#include "model.h"
#include "mpu.h"
+#include "translations.h"
#ifdef KERNEL_MODE
diff --git a/core/embed/lib/translations.h b/core/embed/lib/translations.h
index 9e823650b5..6ea3c42da0 100644
--- a/core/embed/lib/translations.h
+++ b/core/embed/lib/translations.h
@@ -20,8 +20,7 @@
#ifndef LIB_TRANSLATIONS_H
#define LIB_TRANSLATIONS_H
-#include
-#include
+#include
bool translations_write(const uint8_t* data, uint32_t offset, uint32_t len);
diff --git a/core/embed/trezorhal/common.h b/core/embed/lib/trezor_rtl.h
similarity index 77%
rename from core/embed/trezorhal/common.h
rename to core/embed/lib/trezor_rtl.h
index c231f82a0c..24f96875a3 100644
--- a/core/embed/trezorhal/common.h
+++ b/core/embed/lib/trezor_rtl.h
@@ -17,15 +17,22 @@
* along with this program. If not, see .
*/
-#ifndef __TREZORHAL_COMMON_H__
-#define __TREZORHAL_COMMON_H__
+#ifndef TREZOR_RTL_H
+#define TREZOR_RTL_H
-#include
-#include
-#include "secbool.h"
+// `trezor_rtl.h` consolidates common includes for implementation files
+// (.c files) and provides essential types and functions.
+//
+// Do not include `trezor_rtl.h` in interface headers to prevent global
+// namespace pollution; use `trezor_types.h` instead.
+
+#include
+
+#include
+#include
+#include
#include "error_handling.h"
-#include "systick.h"
#ifndef MIN_8bits
#define MIN_8bits(a, b) \
@@ -54,4 +61,4 @@
#define ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0]))
-#endif
+#endif // TREZOR_RTL_H
diff --git a/core/embed/lib/trezor_types.h b/core/embed/lib/trezor_types.h
new file mode 100644
index 0000000000..03aed8fa5f
--- /dev/null
+++ b/core/embed/lib/trezor_types.h
@@ -0,0 +1,35 @@
+/*
+ * 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 .
+ */
+
+#ifndef TREZOR_TYPES_H
+#define TREZOR_TYPES_H
+
+// `trezor_types.h` consolidates commonly needed includes for interface
+// header files and provides essential types required in most files.
+//
+// Avoid adding additional includes here unless absolutely necessary,
+// as it may pollute the global namespace across the project.
+
+#include
+#include
+#include
+
+#include "secbool.h"
+
+#endif // TREZOR_TYPES_H
diff --git a/core/embed/models/trezor_bsp.h b/core/embed/models/trezor_bsp.h
new file mode 100644
index 0000000000..d2e220c794
--- /dev/null
+++ b/core/embed/models/trezor_bsp.h
@@ -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 .
+ */
+
+#ifndef TREZOR_BSP_H
+#define TREZOR_BSP_H
+
+// Trezor 'board support package' (BSP) header file that includes
+// all necessary headers for the specific board including STM32 HAL and
+// pin definitions.
+//
+// This file should be only included by driver implementations and
+// should not be included by application code.
+
+#include TREZOR_BOARD
+
+#ifndef TREZOR_EMULATOR
+#include STM32_HAL_H
+#endif
+
+#endif // TREZOR_BOARD_H
diff --git a/core/embed/models/model.h b/core/embed/models/trezor_model.h
similarity index 100%
rename from core/embed/models/model.h
rename to core/embed/models/trezor_model.h
diff --git a/core/embed/prodtest/main.c b/core/embed/prodtest/main.c
index 8a68a3ed19..cbd888477b 100644
--- a/core/embed/prodtest/main.c
+++ b/core/embed/prodtest/main.c
@@ -17,17 +17,17 @@
* along with this program. If not, see .
*/
+#include // required by #ifdef STM32U5 below (see #4306 issue)
+#include
+#include
+
#include
#include
-#include
#include
-#include STM32_HAL_H
-
#include "board_capabilities.h"
#include "bootutils.h"
#include "button.h"
-#include "common.h"
#include "display.h"
#include "display_draw.h"
#include "display_utils.h"
@@ -35,15 +35,14 @@
#include "flash_otp.h"
#include "fwutils.h"
#include "image.h"
-#include "model.h"
#include "mpu.h"
#include "prodtest_common.h"
#include "random_delays.h"
#include "rsod.h"
#include "sbu.h"
#include "sdcard.h"
-#include "secbool.h"
#include "system.h"
+#include "systick.h"
#include "systimer.h"
#include "touch.h"
#include "usb.h"
@@ -246,13 +245,13 @@ static void test_display(const char *colors) {
static secbool test_btn_press(uint32_t deadline, uint32_t btn) {
while (button_read() != (btn | BTN_EVT_DOWN)) {
- if (HAL_GetTick() > deadline) {
+ if (systick_ms() > deadline) {
vcp_println("ERROR TIMEOUT");
return secfalse;
}
}
while (button_read() != (btn | BTN_EVT_UP)) {
- if (HAL_GetTick() > deadline) {
+ if (systick_ms() > deadline) {
vcp_println("ERROR TIMEOUT");
return secfalse;
}
@@ -281,7 +280,7 @@ static secbool test_btn_all(uint32_t deadline) {
if (left_pressed && right_pressed) {
break;
}
- if (HAL_GetTick() > deadline) {
+ if (systick_ms() > deadline) {
vcp_println("ERROR TIMEOUT");
return secfalse;
}
@@ -304,7 +303,7 @@ static secbool test_btn_all(uint32_t deadline) {
if (!left_pressed && !right_pressed) {
break;
}
- if (HAL_GetTick() > deadline) {
+ if (systick_ms() > deadline) {
vcp_println("ERROR TIMEOUT");
return secfalse;
}
@@ -317,21 +316,21 @@ static void test_button(const char *args) {
if (startswith(args, "LEFT ")) {
timeout = args[5] - '0';
- uint32_t deadline = HAL_GetTick() + timeout * 1000;
+ uint32_t deadline = systick_ms() + timeout * 1000;
secbool r = test_btn_press(deadline, BTN_LEFT);
if (r == sectrue) vcp_println("OK");
}
if (startswith(args, "RIGHT ")) {
timeout = args[6] - '0';
- uint32_t deadline = HAL_GetTick() + timeout * 1000;
+ uint32_t deadline = systick_ms() + timeout * 1000;
secbool r = test_btn_press(deadline, BTN_RIGHT);
if (r == sectrue) vcp_println("OK");
}
if (startswith(args, "BOTH ")) {
timeout = args[5] - '0';
- uint32_t deadline = HAL_GetTick() + timeout * 1000;
+ uint32_t deadline = systick_ms() + timeout * 1000;
secbool r = test_btn_all(deadline);
if (r == sectrue) vcp_println("OK");
}
@@ -341,16 +340,16 @@ static void test_button(const char *args) {
#ifdef USE_TOUCH
static secbool touch_click_timeout(uint32_t *touch, uint32_t timeout_ms) {
- uint32_t deadline = HAL_GetTick() + timeout_ms;
+ uint32_t deadline = systick_ms() + timeout_ms;
uint32_t r = 0;
while (touch_get_event())
;
while ((touch_get_event() & TOUCH_START) == 0) {
- if (HAL_GetTick() > deadline) return secfalse;
+ if (systick_ms() > deadline) return secfalse;
}
while (((r = touch_get_event()) & TOUCH_END) == 0) {
- if (HAL_GetTick() > deadline) return secfalse;
+ if (systick_ms() > deadline) return secfalse;
}
while (touch_get_event())
;
@@ -608,7 +607,7 @@ static void test_sd(void) {
vcp_println("ERROR sdcard_write_blocks (%d)", j);
goto power_off;
}
- HAL_Delay(1000);
+ systick_delay_ms(1000);
if (sectrue !=
sdcard_read_blocks(buf2, 0, BLOCK_SIZE / SDCARD_BLOCK_SIZE)) {
vcp_println("ERROR sdcard_read_blocks (%d)", j);
diff --git a/core/embed/prodtest/optiga_prodtest.c b/core/embed/prodtest/optiga_prodtest.c
index 577fb1fec0..a05484aebf 100644
--- a/core/embed/prodtest/optiga_prodtest.c
+++ b/core/embed/prodtest/optiga_prodtest.c
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-#include
+#include
#include "aes/aes.h"
#include "buffer.h"
@@ -33,8 +33,6 @@
#include "secret.h"
#include "sha2.h"
-#include TREZOR_BOARD
-
#ifdef USE_STORAGE_HWKEY
#include "secure_aes.h"
#endif
diff --git a/core/embed/prodtest/optiga_prodtest.h b/core/embed/prodtest/optiga_prodtest.h
index 375d642f0d..135403b565 100644
--- a/core/embed/prodtest/optiga_prodtest.h
+++ b/core/embed/prodtest/optiga_prodtest.h
@@ -20,9 +20,7 @@
#ifndef PRODTEST_OPTIGA_PRODTEST_H
#define PRODTEST_OPTIGA_PRODTEST_H
-#include
-#include
-#include
+#include
#define OID_CERT_INF (OPTIGA_OID_CERT + 0)
#define OID_CERT_DEV (OPTIGA_OID_CERT + 1)
diff --git a/core/embed/prodtest/prodtest_common.h b/core/embed/prodtest/prodtest_common.h
index 221e16cd6b..4c5fdb9e8f 100644
--- a/core/embed/prodtest/prodtest_common.h
+++ b/core/embed/prodtest/prodtest_common.h
@@ -20,8 +20,7 @@
#ifndef PRODTEST_COMMON_H
#define PRODTEST_COMMON_H
-#include
-#include
+#include
enum { VCP_IFACE = 0x00 };
diff --git a/core/embed/reflash/main.c b/core/embed/reflash/main.c
index 0e7ef45580..851834df9b 100644
--- a/core/embed/reflash/main.c
+++ b/core/embed/reflash/main.c
@@ -17,24 +17,18 @@
* along with this program. If not, see .
*/
-#include
-#include
-#include
-
-#include STM32_HAL_H
+#include
+#include
#include "bootutils.h"
-#include "common.h"
#include "display.h"
#include "display_draw.h"
#include "flash.h"
#include "image.h"
-#include "model.h"
#include "rng.h"
#include "rsod.h"
#include "sbu.h"
#include "sdcard.h"
-#include "secbool.h"
#include "system.h"
#include "systimer.h"
#include "terminal.h"
diff --git a/core/embed/rust/rust_ui.h b/core/embed/rust/rust_ui.h
index 897c6a3311..8a736eb04e 100644
--- a/core/embed/rust/rust_ui.h
+++ b/core/embed/rust/rust_ui.h
@@ -1,6 +1,2 @@
-#include
-
-#include "common.h"
-
#include "rust_ui_bootloader.h"
#include "rust_ui_common.h"
diff --git a/core/embed/rust/rust_ui_bootloader.h b/core/embed/rust/rust_ui_bootloader.h
index cdddb96a51..b0b4c22322 100644
--- a/core/embed/rust/rust_ui_bootloader.h
+++ b/core/embed/rust/rust_ui_bootloader.h
@@ -1,4 +1,4 @@
-#include "common.h"
+#include
uint32_t screen_install_confirm(const char* vendor_str, uint8_t vendor_str_len,
const char* version_str,
diff --git a/core/embed/rust/rust_ui_common.h b/core/embed/rust/rust_ui_common.h
index 6c8a8b7dec..b3af726a14 100644
--- a/core/embed/rust/rust_ui_common.h
+++ b/core/embed/rust/rust_ui_common.h
@@ -1,4 +1,4 @@
-#include "common.h"
+#include
void display_rsod_rust(const char* title, const char* message,
const char* footer);
diff --git a/core/embed/rust/trezorhal.h b/core/embed/rust/trezorhal.h
index 48ab14222f..014be2bd4a 100644
--- a/core/embed/rust/trezorhal.h
+++ b/core/embed/rust/trezorhal.h
@@ -1,8 +1,7 @@
-#include TREZOR_BOARD
+#include
#include "buffers.h"
#include "button.h"
-#include "common.h"
#include "display.h"
#include "display_draw.h"
#include "dma2d.h"
@@ -12,10 +11,10 @@
#include "fonts/fonts.h"
#include "gfx_bitblt.h"
#include "haptic.h"
-#include "model.h"
#include "rgb_led.h"
#include "secbool.h"
#include "storage.h"
+#include "systick.h"
#include "touch.h"
#include "translations.h"
#include "usb.h"
diff --git a/core/embed/trezorhal/applet.h b/core/embed/trezorhal/applet.h
index 72f859cd70..a7fc04f887 100644
--- a/core/embed/trezorhal/applet.h
+++ b/core/embed/trezorhal/applet.h
@@ -20,8 +20,7 @@
#ifndef TREZORHAL_APPLET_H
#define TREZORHAL_APPLET_H
-#include
-#include
+#include
#ifdef SYSCALL_DISPATCH
diff --git a/core/embed/trezorhal/bg_copy.h b/core/embed/trezorhal/bg_copy.h
index dac9383d79..8326f0254e 100644
--- a/core/embed/trezorhal/bg_copy.h
+++ b/core/embed/trezorhal/bg_copy.h
@@ -2,9 +2,7 @@
#ifndef TREZORHAL_BG_COPY_H
#define TREZORHAL_BG_COPY_H
-#include
-#include
-#include
+#include
#ifdef KERNEL_MODE
diff --git a/core/embed/trezorhal/board_capabilities.h b/core/embed/trezorhal/board_capabilities.h
index 8d1bf43a9b..184aaecde9 100644
--- a/core/embed/trezorhal/board_capabilities.h
+++ b/core/embed/trezorhal/board_capabilities.h
@@ -33,7 +33,7 @@ Simple key-tag-length-value structure at fixed boardloader address.
Last tag must be terminator or all space used.
*/
-#include
+#include
#ifdef KERNEL_MODE
diff --git a/core/embed/trezorhal/bootargs.h b/core/embed/trezorhal/bootargs.h
index 1cfc5b97e8..422fee0e47 100644
--- a/core/embed/trezorhal/bootargs.h
+++ b/core/embed/trezorhal/bootargs.h
@@ -20,8 +20,7 @@
#ifndef TREZORHAL_BOOTARGS_H
#define TREZORHAL_BOOTARGS_H
-#include
-#include
+#include
// Defines boot command processed in bootloader on next reboot
typedef enum {
diff --git a/core/embed/trezorhal/bootutils.h b/core/embed/trezorhal/bootutils.h
index 683d2fae42..10b069e913 100644
--- a/core/embed/trezorhal/bootutils.h
+++ b/core/embed/trezorhal/bootutils.h
@@ -20,8 +20,7 @@
#ifndef TREZORHAL_BOOTUTILS_H
#define TREZORHAL_BOOTUTILS_H
-#include
-#include
+#include
// Immediately resets the device and initiates the normal boot sequence.
void __attribute__((noreturn)) reboot_device(void);
diff --git a/core/embed/trezorhal/button.h b/core/embed/trezorhal/button.h
index fa54013bcb..0f77b436ba 100644
--- a/core/embed/trezorhal/button.h
+++ b/core/embed/trezorhal/button.h
@@ -20,7 +20,7 @@
#ifndef TREZORHAL_BUTTON_H
#define TREZORHAL_BUTTON_H
-#include
+#include
#define BTN_EVT_DOWN (1U << 24)
#define BTN_EVT_UP (1U << 25)
diff --git a/core/embed/trezorhal/display.h b/core/embed/trezorhal/display.h
index 34def49aa4..98afdf4fbc 100644
--- a/core/embed/trezorhal/display.h
+++ b/core/embed/trezorhal/display.h
@@ -24,10 +24,8 @@
#include
#else
-#include
-#include "common.h"
-
-#include TREZOR_BOARD
+#include
+#include
#ifdef DISPLAY_LEGACY_HEADER
#include DISPLAY_LEGACY_HEADER
diff --git a/core/embed/trezorhal/dma2d.h b/core/embed/trezorhal/dma2d.h
index 3f8d8f79b9..642e9e9ec4 100644
--- a/core/embed/trezorhal/dma2d.h
+++ b/core/embed/trezorhal/dma2d.h
@@ -20,7 +20,7 @@
#ifndef TREZORHAL_DMA2D_H
#define TREZORHAL_DMA2D_H
-#include "common.h"
+#include
void dma2d_init(void);
diff --git a/core/embed/trezorhal/entropy.h b/core/embed/trezorhal/entropy.h
index c71d0aab4f..290c2a1162 100644
--- a/core/embed/trezorhal/entropy.h
+++ b/core/embed/trezorhal/entropy.h
@@ -20,7 +20,7 @@
#ifndef TREZORHAL_ENTROPY_H
#define TREZORHAL_ENTROPY_H
-#include
+#include
#ifdef KERNEL_MODE
diff --git a/core/embed/trezorhal/flash.h b/core/embed/trezorhal/flash.h
index efcc610c37..0aeafae0be 100644
--- a/core/embed/trezorhal/flash.h
+++ b/core/embed/trezorhal/flash.h
@@ -20,11 +20,9 @@
#ifndef TREZORHAL_FLASH_H
#define TREZORHAL_FLASH_H
-#include
-#include
+#include
#include "flash_ll.h"
-#include "secbool.h"
void flash_init(void);
diff --git a/core/embed/trezorhal/flash_otp.h b/core/embed/trezorhal/flash_otp.h
index 56d05a237a..e1003b3609 100644
--- a/core/embed/trezorhal/flash_otp.h
+++ b/core/embed/trezorhal/flash_otp.h
@@ -1,7 +1,7 @@
#ifndef TREZORHAL_FLASH_OTP_H
#define TREZORHAL_FLASH_OTP_H
-#include
+#include
#ifdef KERNEL_MODE
diff --git a/core/embed/trezorhal/fwutils.h b/core/embed/trezorhal/fwutils.h
index f29bc5ff63..69c77a2f2c 100644
--- a/core/embed/trezorhal/fwutils.h
+++ b/core/embed/trezorhal/fwutils.h
@@ -20,9 +20,7 @@
#ifndef TREZORHAL_FWUTILS_H
#define TREZORHAL_FWUTILS_H
-#include
-
-#include "secbool.h"
+#include
// Callback function for firmware hash calculation.
typedef void (*firmware_hash_callback_t)(void* context, uint32_t progress,
diff --git a/core/embed/trezorhal/haptic.h b/core/embed/trezorhal/haptic.h
index 6cb60ee9bb..b6e1e26e3d 100644
--- a/core/embed/trezorhal/haptic.h
+++ b/core/embed/trezorhal/haptic.h
@@ -20,8 +20,7 @@
#ifndef TREZORHAL_HAPTIC_H
#define TREZORHAL_HAPTIC_H
-#include
-#include
+#include
typedef enum {
// Effect at the start of a button press
diff --git a/core/embed/trezorhal/hash_processor.h b/core/embed/trezorhal/hash_processor.h
index c7a84a4e68..3a7c6ddf9b 100644
--- a/core/embed/trezorhal/hash_processor.h
+++ b/core/embed/trezorhal/hash_processor.h
@@ -1,7 +1,7 @@
#ifndef TREZORHAL_HASH_PROCESSOR_H_
#define TREZORHAL_HASH_PROCESSOR_H_
-#include
+#include
#ifdef KERNEL_MODE
diff --git a/core/embed/trezorhal/i2c_bus.h b/core/embed/trezorhal/i2c_bus.h
index 2296a4d2c4..9163218b4a 100644
--- a/core/embed/trezorhal/i2c_bus.h
+++ b/core/embed/trezorhal/i2c_bus.h
@@ -20,9 +20,7 @@
#ifndef TREZORHAL_I2C_BUS_H
#define TREZORHAL_I2C_BUS_H
-#include
-#include
-#include
+#include
#ifdef KERNEL_MODE
diff --git a/core/embed/trezorhal/monoctr.h b/core/embed/trezorhal/monoctr.h
index e6394583f1..df6bd72032 100644
--- a/core/embed/trezorhal/monoctr.h
+++ b/core/embed/trezorhal/monoctr.h
@@ -22,13 +22,12 @@
#ifdef KERNEL_MODE
+#include
+
// Monoctr module provides monotonic counter functionality
#define MONOCTR_MAX_VALUE 63
-#include
-#include "secbool.h"
-
typedef enum {
MONOCTR_BOOTLOADER_VERSION = 0,
MONOCTR_FIRMWARE_VERSION = 1,
diff --git a/core/embed/trezorhal/mpu.h b/core/embed/trezorhal/mpu.h
index 657d311356..dfe887b147 100644
--- a/core/embed/trezorhal/mpu.h
+++ b/core/embed/trezorhal/mpu.h
@@ -20,7 +20,7 @@
#ifndef TREZORHAL_MPU_H
#define TREZORHAL_MPU_H
-#include
+#include
#ifdef KERNEL_MODE
diff --git a/core/embed/trezorhal/optiga.h b/core/embed/trezorhal/optiga.h
index b3a133a629..1195a0b245 100644
--- a/core/embed/trezorhal/optiga.h
+++ b/core/embed/trezorhal/optiga.h
@@ -20,9 +20,8 @@
#ifndef TREZORHAL_OPTIGA_H
#define TREZORHAL_OPTIGA_H
-#include
-#include
-#include
+#include
+
#include "optiga_common.h"
#include "storage.h"
diff --git a/core/embed/trezorhal/optiga/optiga.c b/core/embed/trezorhal/optiga/optiga.c
index d4fa2e2391..b7ad7154df 100644
--- a/core/embed/trezorhal/optiga/optiga.c
+++ b/core/embed/trezorhal/optiga/optiga.c
@@ -17,11 +17,12 @@
* along with this program. If not, see .
*/
-#include "optiga.h"
-#include
+#include
+
#include "hash_to_curve.h"
#include "hmac.h"
#include "memzero.h"
+#include "optiga.h"
#include "optiga_commands.h"
#include "optiga_transport.h"
#include "rand.h"
diff --git a/core/embed/trezorhal/optiga/optiga_commands.c b/core/embed/trezorhal/optiga/optiga_commands.c
index 1041adc887..e25f5b7cca 100644
--- a/core/embed/trezorhal/optiga/optiga_commands.c
+++ b/core/embed/trezorhal/optiga/optiga_commands.c
@@ -23,13 +23,14 @@
* https://github.com/Infineon/optiga-trust-m/blob/develop/documents/Infineon_I2C_Protocol_v2.03.pdf
*/
-#include "optiga_commands.h"
-#include
+#include
+
#include "der.h"
#include "ecdsa.h"
#include "hmac.h"
#include "memzero.h"
#include "nist256p1.h"
+#include "optiga_commands.h"
#include "optiga_transport.h"
#include "sha2.h"
diff --git a/core/embed/trezorhal/optiga/optiga_transport.c b/core/embed/trezorhal/optiga/optiga_transport.c
index 3ac1d82054..5a1413ea18 100644
--- a/core/embed/trezorhal/optiga/optiga_transport.c
+++ b/core/embed/trezorhal/optiga/optiga_transport.c
@@ -22,19 +22,19 @@
* https://github.com/Infineon/optiga-trust-m/blob/develop/documents/Infineon_I2C_Protocol_v2.03.pdf
*/
-#include "optiga_transport.h"
-#include
+#include
+#include
+
#include "aes/aesccm.h"
-#include "common.h"
#include "i2c_bus.h"
#include "memzero.h"
#include "optiga_hal.h"
+#include "optiga_transport.h"
+#include "systick.h"
#include "tls_prf.h"
#ifdef KERNEL_MODE
-#include TREZOR_BOARD
-
// Maximum possible packet size that can be transmitted.
#define OPTIGA_MAX_PACKET_SIZE (OPTIGA_DATA_REG_LEN - 5)
diff --git a/core/embed/trezorhal/optiga_commands.h b/core/embed/trezorhal/optiga_commands.h
index 61cd7d949f..5fbaecb54b 100644
--- a/core/embed/trezorhal/optiga_commands.h
+++ b/core/embed/trezorhal/optiga_commands.h
@@ -20,9 +20,8 @@
#ifndef TREZORHAL_OPTIGA_COMMANDS_H
#define TREZORHAL_OPTIGA_COMMANDS_H
-#include
-#include
-#include
+#include
+
#include "optiga_common.h"
// Data object identifiers.
diff --git a/core/embed/trezorhal/optiga_common.h b/core/embed/trezorhal/optiga_common.h
index 21d74aed68..6447e7ca1f 100644
--- a/core/embed/trezorhal/optiga_common.h
+++ b/core/embed/trezorhal/optiga_common.h
@@ -20,7 +20,7 @@
#ifndef TREZORHAL_OPTIGA_COMMON_H
#define TREZORHAL_OPTIGA_COMMON_H
-#include "secbool.h"
+#include
typedef enum _optiga_result {
OPTIGA_SUCCESS = 0, // Operation completed successfully.
diff --git a/core/embed/trezorhal/optiga_hal.h b/core/embed/trezorhal/optiga_hal.h
index e91bc03e2d..c744c1c09b 100644
--- a/core/embed/trezorhal/optiga_hal.h
+++ b/core/embed/trezorhal/optiga_hal.h
@@ -2,8 +2,7 @@
#ifndef CORE_OPTIGA_HAL_H
#define CORE_OPTIGA_HAL_H
-#include
-#include "secbool.h"
+#include
void optiga_hal_init(void);
diff --git a/core/embed/trezorhal/optiga_transport.h b/core/embed/trezorhal/optiga_transport.h
index 041c88250b..3d9b914f9c 100644
--- a/core/embed/trezorhal/optiga_transport.h
+++ b/core/embed/trezorhal/optiga_transport.h
@@ -20,9 +20,8 @@
#ifndef TREZORHAL_OPTIGA_TRANSPORT_H
#define TREZORHAL_OPTIGA_TRANSPORT_H
-#include
-#include
-#include
+#include
+
#include "optiga_common.h"
// Maximum data register length supported by OPTIGA.
diff --git a/core/embed/trezorhal/option_bytes.h b/core/embed/trezorhal/option_bytes.h
index 802db911ba..d48900a533 100644
--- a/core/embed/trezorhal/option_bytes.h
+++ b/core/embed/trezorhal/option_bytes.h
@@ -20,7 +20,7 @@
#ifndef TREZORHAL_OPTION_BYTES_H
#define TREZORHAL_OPTION_BYTES_H
-#include "secbool.h"
+#include
#ifdef KERNEL_MODE
diff --git a/core/embed/trezorhal/random_delays.h b/core/embed/trezorhal/random_delays.h
index 46d6e0e482..0c73f8b921 100644
--- a/core/embed/trezorhal/random_delays.h
+++ b/core/embed/trezorhal/random_delays.h
@@ -20,7 +20,7 @@
#ifndef TREZORHAL_RANDOM_DELAYS_H
#define TREZORHAL_RANDOM_DELAYS_H
-#include
+#include
/*
Random delay interrupts (RDI) is a contermeasure against side channel attacks.
diff --git a/core/embed/trezorhal/reset_flags.h b/core/embed/trezorhal/reset_flags.h
index 52ae40d557..ed294da9c5 100644
--- a/core/embed/trezorhal/reset_flags.h
+++ b/core/embed/trezorhal/reset_flags.h
@@ -20,7 +20,7 @@
#ifndef TREZORHAL_RESET_FLAGS_H
#define TREZORHAL_RESET_FLAGS_H
-#include "secbool.h"
+#include
#ifdef KERNEL_MODE
diff --git a/core/embed/trezorhal/rgb_led.h b/core/embed/trezorhal/rgb_led.h
index 1ad62d9b80..65158b5495 100644
--- a/core/embed/trezorhal/rgb_led.h
+++ b/core/embed/trezorhal/rgb_led.h
@@ -20,7 +20,7 @@
#ifndef TREZORHAL_RGB_LED_H
#define TREZORHAL_RGB_LED_H
-#include