diff --git a/core/embed/models/D001/model_D001_layout.c b/core/embed/models/D001/model_D001_layout.c deleted file mode 120000 index 6851dc987..000000000 --- a/core/embed/models/D001/model_D001_layout.c +++ /dev/null @@ -1 +0,0 @@ -../T2T1/model_T2T1_layout.c \ No newline at end of file diff --git a/core/embed/models/T2T1/model_T2T1_layout.c b/core/embed/models/T2T1/model_T2T1_layout.c deleted file mode 100644 index bd39db70e..000000000 --- a/core/embed/models/T2T1/model_T2T1_layout.c +++ /dev/null @@ -1,102 +0,0 @@ -#include "flash.h" -#include "model.h" - -const flash_area_t STORAGE_AREAS[STORAGE_AREAS_COUNT] = { - { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = STORAGE_1_SECTOR_START, - .num_sectors = - STORAGE_1_SECTOR_END - STORAGE_1_SECTOR_START + 1, - }, - }, - { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = STORAGE_2_SECTOR_START, - .num_sectors = - STORAGE_2_SECTOR_END - STORAGE_2_SECTOR_START + 1, - }, - }, -}; - -const flash_area_t BOARDLOADER_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = BOARDLOADER_SECTOR_START, - .num_sectors = - BOARDLOADER_SECTOR_END - BOARDLOADER_SECTOR_START + 1, - }, -}; - -const flash_area_t TRANSLATIONS_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = ASSETS_SECTOR_START, - .num_sectors = ASSETS_SECTOR_END - ASSETS_SECTOR_START + 1, - }, -}; - -const flash_area_t BOOTLOADER_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = BOOTLOADER_SECTOR_START, - .num_sectors = BOOTLOADER_SECTOR_END - BOOTLOADER_SECTOR_START + 1, - }, -}; - -const flash_area_t FIRMWARE_AREA = { - .num_subareas = 2, - .subarea[0] = - { - .first_sector = FIRMWARE_P1_SECTOR_START, - .num_sectors = - FIRMWARE_P1_SECTOR_END - FIRMWARE_P1_SECTOR_START + 1, - }, - .subarea[1] = - { - .first_sector = FIRMWARE_P2_SECTOR_START, - .num_sectors = - FIRMWARE_P2_SECTOR_END - FIRMWARE_P2_SECTOR_START + 1, - }, -}; - -#ifdef SECRET_SECTOR_START -const flash_area_t SECRET_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = SECRET_SECTOR_START, - .num_sectors = SECRET_SECTOR_END - SECRET_SECTOR_START + 1, - }, -}; -#else -const flash_area_t SECRET_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = 0, - .num_sectors = 0, - - }, -}; -#endif - -const flash_area_t UNUSED_AREA = { - .num_subareas = 2, - .subarea[0] = - { - .first_sector = UNUSED_1_SECTOR_START, - .num_sectors = UNUSED_1_SECTOR_END - UNUSED_1_SECTOR_START + 1, - }, - .subarea[1] = - { - .first_sector = UNUSED_2_SECTOR_START, - .num_sectors = UNUSED_2_SECTOR_END - UNUSED_2_SECTOR_START + 1, - }, -}; diff --git a/core/embed/models/T3B1/model_T3B1_layout.c b/core/embed/models/T3B1/model_T3B1_layout.c deleted file mode 100644 index 29e2fa8c2..000000000 --- a/core/embed/models/T3B1/model_T3B1_layout.c +++ /dev/null @@ -1,82 +0,0 @@ -#include "flash.h" -#include "model.h" - -const flash_area_t STORAGE_AREAS[STORAGE_AREAS_COUNT] = { - { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = STORAGE_1_SECTOR_START, - .num_sectors = - STORAGE_1_SECTOR_END - STORAGE_1_SECTOR_START + 1, - }, - }, - { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = STORAGE_2_SECTOR_START, - .num_sectors = - STORAGE_2_SECTOR_END - STORAGE_2_SECTOR_START + 1, - }, - }, -}; - -const flash_area_t BOARDLOADER_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = BOARDLOADER_SECTOR_START, - .num_sectors = - BOARDLOADER_SECTOR_END - BOARDLOADER_SECTOR_START + 1, - }, -}; - -const flash_area_t BOOTLOADER_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = BOOTLOADER_SECTOR_START, - .num_sectors = BOOTLOADER_SECTOR_END - BOOTLOADER_SECTOR_START + 1, - }, -}; - -const flash_area_t FIRMWARE_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = FIRMWARE_SECTOR_START, - .num_sectors = FIRMWARE_SECTOR_END - FIRMWARE_SECTOR_START + 1, - }, -}; - -const flash_area_t SECRET_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = SECRET_SECTOR_START, - .num_sectors = SECRET_SECTOR_END - SECRET_SECTOR_START + 1, - }, -}; - -const flash_area_t BHK_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = BHK_SECTOR_START, - .num_sectors = BHK_SECTOR_END - BHK_SECTOR_START + 1, - }, -}; - -const flash_area_t TRANSLATIONS_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = ASSETS_SECTOR_START, - .num_sectors = ASSETS_SECTOR_END - ASSETS_SECTOR_START + 1, - }, -}; - -const flash_area_t UNUSED_AREA = { - .num_subareas = 0, -}; diff --git a/core/embed/models/T3T1/model_T3T1_layout.c b/core/embed/models/T3T1/model_T3T1_layout.c deleted file mode 100644 index 29e2fa8c2..000000000 --- a/core/embed/models/T3T1/model_T3T1_layout.c +++ /dev/null @@ -1,82 +0,0 @@ -#include "flash.h" -#include "model.h" - -const flash_area_t STORAGE_AREAS[STORAGE_AREAS_COUNT] = { - { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = STORAGE_1_SECTOR_START, - .num_sectors = - STORAGE_1_SECTOR_END - STORAGE_1_SECTOR_START + 1, - }, - }, - { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = STORAGE_2_SECTOR_START, - .num_sectors = - STORAGE_2_SECTOR_END - STORAGE_2_SECTOR_START + 1, - }, - }, -}; - -const flash_area_t BOARDLOADER_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = BOARDLOADER_SECTOR_START, - .num_sectors = - BOARDLOADER_SECTOR_END - BOARDLOADER_SECTOR_START + 1, - }, -}; - -const flash_area_t BOOTLOADER_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = BOOTLOADER_SECTOR_START, - .num_sectors = BOOTLOADER_SECTOR_END - BOOTLOADER_SECTOR_START + 1, - }, -}; - -const flash_area_t FIRMWARE_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = FIRMWARE_SECTOR_START, - .num_sectors = FIRMWARE_SECTOR_END - FIRMWARE_SECTOR_START + 1, - }, -}; - -const flash_area_t SECRET_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = SECRET_SECTOR_START, - .num_sectors = SECRET_SECTOR_END - SECRET_SECTOR_START + 1, - }, -}; - -const flash_area_t BHK_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = BHK_SECTOR_START, - .num_sectors = BHK_SECTOR_END - BHK_SECTOR_START + 1, - }, -}; - -const flash_area_t TRANSLATIONS_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = ASSETS_SECTOR_START, - .num_sectors = ASSETS_SECTOR_END - ASSETS_SECTOR_START + 1, - }, -}; - -const flash_area_t UNUSED_AREA = { - .num_subareas = 0, -}; diff --git a/core/embed/models/layout_common.h b/core/embed/models/layout_common.h index 7a9d72dc5..844fcd04a 100644 --- a/core/embed/models/layout_common.h +++ b/core/embed/models/layout_common.h @@ -11,15 +11,4 @@ #define FLASH_OTP_BLOCK_DEVICE_VARIANT 4 #define FLASH_OTP_BLOCK_FIRMWARE_VERSION 5 -#define STORAGE_AREAS_COUNT (2) - -extern const flash_area_t STORAGE_AREAS[STORAGE_AREAS_COUNT]; -extern const flash_area_t BOARDLOADER_AREA; -extern const flash_area_t SECRET_AREA; -extern const flash_area_t BHK_AREA; -extern const flash_area_t TRANSLATIONS_AREA; -extern const flash_area_t BOOTLOADER_AREA; -extern const flash_area_t FIRMWARE_AREA; -extern const flash_area_t UNUSED_AREA; - #endif diff --git a/core/embed/models/model.h b/core/embed/models/model.h index 9697bfd31..03c6b34a2 100644 --- a/core/embed/models/model.h +++ b/core/embed/models/model.h @@ -1,6 +1,7 @@ #ifndef MODELS_MODEL_H_ #define MODELS_MODEL_H_ +#include "layout.h" #include "layout_common.h" #if defined TREZOR_MODEL_T diff --git a/core/embed/trezorhal/layout.h b/core/embed/trezorhal/layout.h new file mode 100644 index 000000000..fd6e0114f --- /dev/null +++ b/core/embed/trezorhal/layout.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 TREZORHAL_LAYOUT_H_ +#define TREZORHAL_LAYOUT_H_ + +#include "flash_area.h" + +#define STORAGE_AREAS_COUNT (2) + +extern const flash_area_t STORAGE_AREAS[STORAGE_AREAS_COUNT]; +extern const flash_area_t BOARDLOADER_AREA; +extern const flash_area_t SECRET_AREA; +extern const flash_area_t BHK_AREA; +extern const flash_area_t TRANSLATIONS_AREA; +extern const flash_area_t BOOTLOADER_AREA; +extern const flash_area_t FIRMWARE_AREA; +extern const flash_area_t UNUSED_AREA; + +#endif // TREZORHAL_LAYOUT_H_ diff --git a/core/embed/models/T2B1/model_T2B1_layout.c b/core/embed/trezorhal/stm32f4/layout.c similarity index 100% rename from core/embed/models/T2B1/model_T2B1_layout.c rename to core/embed/trezorhal/stm32f4/layout.c index bd39db70e..3088b483f 100644 --- a/core/embed/models/T2B1/model_T2B1_layout.c +++ b/core/embed/trezorhal/stm32f4/layout.c @@ -32,15 +32,6 @@ const flash_area_t BOARDLOADER_AREA = { }, }; -const flash_area_t TRANSLATIONS_AREA = { - .num_subareas = 1, - .subarea[0] = - { - .first_sector = ASSETS_SECTOR_START, - .num_sectors = ASSETS_SECTOR_END - ASSETS_SECTOR_START + 1, - }, -}; - const flash_area_t BOOTLOADER_AREA = { .num_subareas = 1, .subarea[0] = @@ -87,6 +78,15 @@ const flash_area_t SECRET_AREA = { }; #endif +const flash_area_t TRANSLATIONS_AREA = { + .num_subareas = 1, + .subarea[0] = + { + .first_sector = ASSETS_SECTOR_START, + .num_sectors = ASSETS_SECTOR_END - ASSETS_SECTOR_START + 1, + }, +}; + const flash_area_t UNUSED_AREA = { .num_subareas = 2, .subarea[0] = diff --git a/core/embed/models/D002/model_D002_layout.c b/core/embed/trezorhal/stm32u5/layout.c similarity index 100% rename from core/embed/models/D002/model_D002_layout.c rename to core/embed/trezorhal/stm32u5/layout.c diff --git a/core/site_scons/models/D001/discovery.py b/core/site_scons/models/D001/discovery.py index 84592a758..a94353908 100644 --- a/core/site_scons/models/D001/discovery.py +++ b/core/site_scons/models/D001/discovery.py @@ -33,9 +33,6 @@ def configure( defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] - sources += [ - "embed/models/D001/model_D001_layout.c", - ] if "new_rendering" in features_wanted: sources += [ diff --git a/core/site_scons/models/D002/discovery2.py b/core/site_scons/models/D002/discovery2.py index 9a71eaa29..8ca76fb7b 100644 --- a/core/site_scons/models/D002/discovery2.py +++ b/core/site_scons/models/D002/discovery2.py @@ -40,9 +40,6 @@ def configure( defines += [ f"HW_REVISION={hw_revision}", ] - sources += [ - "embed/models/D002/model_D002_layout.c", - ] if "new_rendering" in features_wanted: sources += [ diff --git a/core/site_scons/models/T2B1/emulator.py b/core/site_scons/models/T2B1/emulator.py index 6936b34de..16a6137d6 100644 --- a/core/site_scons/models/T2B1/emulator.py +++ b/core/site_scons/models/T2B1/emulator.py @@ -44,6 +44,6 @@ def configure( sources += ["embed/trezorhal/unix/button.c"] features_available.append("button") - sources += ["embed/models/T2B1/model_T2B1_layout.c"] + sources += ["embed/trezorhal/stm32f4/layout.c"] return features_available diff --git a/core/site_scons/models/T2B1/trezor_r_v10.py b/core/site_scons/models/T2B1/trezor_r_v10.py index 1d8951e0c..2289d8fa4 100644 --- a/core/site_scons/models/T2B1/trezor_r_v10.py +++ b/core/site_scons/models/T2B1/trezor_r_v10.py @@ -38,9 +38,6 @@ def configure( defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] - sources += [ - "embed/models/T2B1/model_T2B1_layout.c", - ] if "new_rendering" in features_wanted: sources += ["embed/trezorhal/xdisplay_legacy.c"] diff --git a/core/site_scons/models/T2B1/trezor_r_v3.py b/core/site_scons/models/T2B1/trezor_r_v3.py index a8809aab6..c72a596f3 100644 --- a/core/site_scons/models/T2B1/trezor_r_v3.py +++ b/core/site_scons/models/T2B1/trezor_r_v3.py @@ -38,9 +38,6 @@ def configure( defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] - sources += [ - "embed/models/T2B1/model_T2B1_layout.c", - ] if "new_rendering" in features_wanted: sources += ["embed/trezorhal/xdisplay_legacy.c"] diff --git a/core/site_scons/models/T2B1/trezor_r_v4.py b/core/site_scons/models/T2B1/trezor_r_v4.py index 641ebd8ce..c578517c4 100644 --- a/core/site_scons/models/T2B1/trezor_r_v4.py +++ b/core/site_scons/models/T2B1/trezor_r_v4.py @@ -38,9 +38,6 @@ def configure( defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] - sources += [ - "embed/models/T2B1/model_T2B1_layout.c", - ] if "new_rendering" in features_wanted: sources += ["embed/trezorhal/xdisplay_legacy.c"] diff --git a/core/site_scons/models/T2B1/trezor_r_v6.py b/core/site_scons/models/T2B1/trezor_r_v6.py index 2f562f5df..6062ab7dc 100644 --- a/core/site_scons/models/T2B1/trezor_r_v6.py +++ b/core/site_scons/models/T2B1/trezor_r_v6.py @@ -38,9 +38,6 @@ def configure( defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] - sources += [ - "embed/models/T2B1/model_T2B1_layout.c", - ] if "new_rendering" in features_wanted: sources += ["embed/trezorhal/xdisplay_legacy.c"] diff --git a/core/site_scons/models/T2T1/emulator.py b/core/site_scons/models/T2T1/emulator.py index a35db0370..9d10e1c6b 100644 --- a/core/site_scons/models/T2T1/emulator.py +++ b/core/site_scons/models/T2T1/emulator.py @@ -56,6 +56,6 @@ def configure( features_available.append("backlight") - sources += ["embed/models/T2T1/model_T2T1_layout.c"] + sources += ["embed/trezorhal/stm32f4/layout.c"] return features_available diff --git a/core/site_scons/models/T2T1/trezor_t.py b/core/site_scons/models/T2T1/trezor_t.py index d35ab5152..b428bd05d 100644 --- a/core/site_scons/models/T2T1/trezor_t.py +++ b/core/site_scons/models/T2T1/trezor_t.py @@ -39,7 +39,6 @@ def configure( defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] sources += [ - "embed/models/T2T1/model_T2T1_layout.c", "embed/models/T2T1/compat_settings.c", ] diff --git a/core/site_scons/models/T3B1/emulator.py b/core/site_scons/models/T3B1/emulator.py index 4d8d8d3b0..493c3353d 100644 --- a/core/site_scons/models/T3B1/emulator.py +++ b/core/site_scons/models/T3B1/emulator.py @@ -44,6 +44,6 @@ def configure( sources += ["embed/trezorhal/unix/button.c"] features_available.append("button") - sources += ["embed/models/T3B1/model_T3B1_layout.c"] + sources += ["embed/trezorhal/stm32u5/layout.c"] return features_available diff --git a/core/site_scons/models/T3B1/trezor_t3b1_revB.py b/core/site_scons/models/T3B1/trezor_t3b1_revB.py index c20b056b7..3c5a5973b 100644 --- a/core/site_scons/models/T3B1/trezor_t3b1_revB.py +++ b/core/site_scons/models/T3B1/trezor_t3b1_revB.py @@ -39,9 +39,6 @@ def configure( defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={ord(hw_revision)}"] - sources += [ - "embed/models/T3B1/model_T3B1_layout.c", - ] if "new_rendering" in features_wanted: sources += ["embed/trezorhal/xdisplay_legacy.c"] diff --git a/core/site_scons/models/T3T1/emulator.py b/core/site_scons/models/T3T1/emulator.py index b2ba96833..e8173defe 100644 --- a/core/site_scons/models/T3T1/emulator.py +++ b/core/site_scons/models/T3T1/emulator.py @@ -65,6 +65,6 @@ def configure( features_available.append("backlight") - sources += ["embed/models/T3T1/model_T3T1_layout.c"] + sources += ["embed/trezorhal/stm32u5/layout.c"] return features_available diff --git a/core/site_scons/models/T3T1/trezor_t3t1_revE.py b/core/site_scons/models/T3T1/trezor_t3t1_revE.py index 1195a7143..412c8f77a 100644 --- a/core/site_scons/models/T3T1/trezor_t3t1_revE.py +++ b/core/site_scons/models/T3T1/trezor_t3t1_revE.py @@ -43,9 +43,6 @@ def configure( defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] - sources += [ - "embed/models/T3T1/model_T3T1_layout.c", - ] if "new_rendering" in features_wanted: sources += ["embed/trezorhal/xdisplay_legacy.c"] diff --git a/core/site_scons/models/T3T1/trezor_t3t1_v4.py b/core/site_scons/models/T3T1/trezor_t3t1_v4.py index 63e26c699..c6b712bb6 100644 --- a/core/site_scons/models/T3T1/trezor_t3t1_v4.py +++ b/core/site_scons/models/T3T1/trezor_t3t1_v4.py @@ -43,9 +43,6 @@ def configure( defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] - sources += [ - "embed/models/T3T1/model_T3T1_layout.c", - ] sources += [ f"embed/trezorhal/stm32u5/displays/{display}", ] diff --git a/core/site_scons/models/stm32f4_common.py b/core/site_scons/models/stm32f4_common.py index c90b334f1..9e3b4cbe1 100644 --- a/core/site_scons/models/stm32f4_common.py +++ b/core/site_scons/models/stm32f4_common.py @@ -48,6 +48,7 @@ def stm32f4_common_files(env, defines, sources, paths): "embed/trezorhal/stm32f4/flash.c", "embed/trezorhal/stm32f4/flash_otp.c", "embed/trezorhal/stm32f4/fwutils.c", + "embed/trezorhal/stm32f4/layout.c", "embed/trezorhal/stm32f4/lowlevel.c", "embed/trezorhal/stm32f4/monoctr.c", "embed/trezorhal/stm32f4/mpu.c", diff --git a/core/site_scons/models/stm32u5_common.py b/core/site_scons/models/stm32u5_common.py index c62c066fe..b69e88a32 100644 --- a/core/site_scons/models/stm32u5_common.py +++ b/core/site_scons/models/stm32u5_common.py @@ -57,6 +57,7 @@ def stm32u5_common_files(env, defines, sources, paths): "embed/trezorhal/stm32u5/flash.c", "embed/trezorhal/stm32u5/flash_otp.c", "embed/trezorhal/stm32u5/fwutils.c", + "embed/trezorhal/stm32u5/layout.c", "embed/trezorhal/stm32u5/lowlevel.c", "embed/trezorhal/stm32u5/hash_processor.c", "embed/trezorhal/stm32u5/monoctr.c",