1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-25 09:22:33 +00:00

refactor(core): prepare for secure/non-secure memory layout

[no changelog]
This commit is contained in:
cepetr 2025-05-02 15:24:54 +02:00 committed by cepetr
parent 1a372b5019
commit a7466298ff
33 changed files with 946 additions and 651 deletions

View File

@ -471,7 +471,7 @@ env.Replace(
'-fstack-protector-all '
+ env.get('ENV')["CPU_CCFLAGS"] + CCFLAGS_MOD,
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
LINKFLAGS=['-Tbuild/firmware/memory.ld', '-Wl,--gc-sections', '-Wl,--print-memory-usage', '-Wl,-Map=build/firmware/firmware.map', '-Wl,--warn-common'],
LINKFLAGS=[f'-Tbuild/firmware/{env.get("ENV")["MEMORY_LAYOUT"]}', '-Wl,--gc-sections', '-Wl,--print-memory-usage', '-Wl,-Map=build/firmware/firmware.map', '-Wl,--warn-common'],
CPPPATH=ALLPATHS,
CPPDEFINES=[
'FIRMWARE',
@ -877,8 +877,8 @@ tools.embed_raw_binary(
env.Depends(obj_program, qstr_generated)
linkerscript_gen = env.Command(
target='memory.ld',
source=[f'embed/models/{TREZOR_MODEL}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='firmware')],
target=env.get("ENV")["MEMORY_LAYOUT"],
source=[f'embed/models/{TREZOR_MODEL}/{env.get("ENV")["MEMORY_LAYOUT"]}', env.get('ENV')['LINKER_SCRIPT'].format(target='firmware')],
action='$CAT $SOURCES > $TARGET',
)

View File

@ -308,7 +308,7 @@ env.Replace(
'-ffreestanding '
'-fstack-protector-all '
+ env.get('ENV')["CPU_CCFLAGS"] + CCFLAGS_MOD,
LINKFLAGS='-T build/kernel/memory.ld -Wl,--gc-sections -Wl,--print-memory-usage '
LINKFLAGS=f'-T build/kernel/{env.get("ENV")["MEMORY_LAYOUT"]} -Wl,--gc-sections -Wl,--print-memory-usage '
' -Wl,-Map=build/kernel/kernel.map -Wl,--warn-common -Wl,--undefined=__errno',
CPPPATH=ALLPATHS,
CPPDEFINES=[
@ -392,8 +392,8 @@ tools.embed_compressed_binary(
)
linkerscript_gen = env.Command(
target='memory.ld',
source=[f'embed/models/{TREZOR_MODEL}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='kernel')],
target=env.get("ENV")["MEMORY_LAYOUT"],
source=[f'embed/models/{TREZOR_MODEL}/{env.get("ENV")["MEMORY_LAYOUT"]}', env.get('ENV')['LINKER_SCRIPT'].format(target='kernel')],
action='$CAT $SOURCES > $TARGET',
)

View File

@ -0,0 +1,116 @@
/*
* 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/>.
*/
#pragma once
// SHARED WITH MAKEFILE
// common
#define FLASH_START 0x08000000
// FLASH layout
#define BOARDLOADER_START 0x08000000
#define BOARDLOADER_MAXSIZE (3 * 16 * 1024) // 48 kB
#define BOARDLOADER_SECTOR_START 0
#define BOARDLOADER_SECTOR_END 2
#define BOARDCAPS_START 0x0800BF00
#define BOARDCAPS_MAXSIZE 0x100
#define UNUSED_1_START 0x0800C000
#define UNUSED_1_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_1_SECTOR_START 3
#define UNUSED_1_SECTOR_END 3
#define STORAGE_1_START 0x08010000
#define STORAGE_1_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_1_SECTOR_START 4
#define STORAGE_1_SECTOR_END 4
#define BOOTLOADER_START 0x08020000
#define BOOTLOADER_MAXSIZE (1 * 128 * 1024) // 128 kB
#define BOOTLOADER_SECTOR_START 5
#define BOOTLOADER_SECTOR_END 5
#define FIRMWARE_START 0x08040000
#define FIRMWARE_MAXSIZE (13 * 128 * 1024) // 1664 kB
#define FIRMWARE_P1_START 0x08040000
#define FIRMWARE_P1_MAXSIZE (6 * 128 * 1024)
#define FIRMWARE_P1_SECTOR_START 6
#define FIRMWARE_P1_SECTOR_END 11
// part of firmware P1
#define KERNEL_START 0x08040000
#define KERNEL_MAXSIZE (4 * 128 * 1024)
#define ASSETS_START 0x08100000
#define ASSETS_MAXSIZE (3 * 16 * 1024) // 48 kB
#define ASSETS_SECTOR_START 12
#define ASSETS_SECTOR_END 14
#define UNUSED_2_START 0x0810C000
#define UNUSED_2_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_2_SECTOR_START 15
#define UNUSED_2_SECTOR_END 15
#define STORAGE_2_START 0x08110000
#define STORAGE_2_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_2_SECTOR_START 16
#define STORAGE_2_SECTOR_END 16
#define FIRMWARE_P2_START 0x08120000
#define FIRMWARE_P2_MAXSIZE (7 * 128 * 1024)
#define FIRMWARE_P2_SECTOR_START 17
#define FIRMWARE_P2_SECTOR_END 23
// Ram layout - shared boardloader, bootloader, prodtest
#define S_MAIN_STACK_START 0x10000000
#define S_MAIN_STACK_SIZE (16 * 1024)
#define S_FB1_RAM_START 0x10004000
#define S_FB1_RAM_SIZE (0)
#define S_MAIN_RAM_START 0x10004000
#define S_MAIN_RAM_SIZE (48 * 1024 - 0x100)
// RAM layout - kernel
#define K_MAIN_STACK_START 0x10000000
#define K_MAIN_STACK_SIZE (8 * 1024)
#define K_FB1_RAM_START 0x1000C000
#define K_FB1_RAM_SIZE (0)
#define K_MAIN_RAM_START 0x1000C000
#define K_MAIN_RAM_SIZE (16 * 1024 - 0x100)
// RAM layout - common
#define BOOTARGS_START 0x1000FF00
#define BOOTARGS_SIZE 0x100
#define DMABUF_RAM_START 0x20000000
#define DMABUF_RAM_SIZE (1 * 1024)
#define AUX1_RAM_START (0x20000400)
#define AUX1_RAM_SIZE (191 * 1024)
#define AUX2_RAM_START 0x10002000
#define AUX2_RAM_SIZE (40 * 1024)
// misc
#define CODE_ALIGNMENT 0x200
#define COREAPP_ALIGNMENT 0x200

View File

@ -1,8 +1,6 @@
/* Auto-generated file, do not edit.*/
FLASH_START = 0x8000000;
NORCOW_SECTOR_SIZE = 0x10000;
NORCOW_MIN_VERSION = 0x6;
BOARDLOADER_START = 0x8000000;
BOARDLOADER_MAXSIZE = 0xc000;
BOARDLOADER_SECTOR_START = 0x0;

View File

@ -1,5 +1,23 @@
#ifndef MODELS_MODEL_D001_H_
#define MODELS_MODEL_D001_H_
/*
* 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/>.
*/
#pragma once
#include "bootloaders/bootloader_hashes.h"
@ -28,102 +46,7 @@
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT
// SHARED WITH MAKEFILE
// common
#define FLASH_START 0x08000000
#define NORCOW_SECTOR_SIZE (1 * 64 * 1024) // 64 kB
#define NORCOW_MIN_VERSION 0x00000006
// FLASH layout
#define BOARDLOADER_START 0x08000000
#define BOARDLOADER_MAXSIZE (3 * 16 * 1024) // 48 kB
#define BOARDLOADER_SECTOR_START 0
#define BOARDLOADER_SECTOR_END 2
#define BOARDCAPS_START 0x0800BF00
#define BOARDCAPS_MAXSIZE 0x100
#define UNUSED_1_START 0x0800C000
#define UNUSED_1_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_1_SECTOR_START 3
#define UNUSED_1_SECTOR_END 3
#define STORAGE_1_START 0x08010000
#define STORAGE_1_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_1_SECTOR_START 4
#define STORAGE_1_SECTOR_END 4
#define BOOTLOADER_START 0x08020000
#define BOOTLOADER_MAXSIZE (1 * 128 * 1024) // 128 kB
#define BOOTLOADER_SECTOR_START 5
#define BOOTLOADER_SECTOR_END 5
#define FIRMWARE_START 0x08040000
#define FIRMWARE_MAXSIZE (13 * 128 * 1024) // 1664 kB
#define FIRMWARE_P1_START 0x08040000
#define FIRMWARE_P1_MAXSIZE (6 * 128 * 1024)
#define FIRMWARE_P1_SECTOR_START 6
#define FIRMWARE_P1_SECTOR_END 11
// part of firmware P1
#define KERNEL_START 0x08040000
#define KERNEL_MAXSIZE (4 * 128 * 1024)
#define ASSETS_START 0x08100000
#define ASSETS_MAXSIZE (3 * 16 * 1024) // 48 kB
#define ASSETS_SECTOR_START 12
#define ASSETS_SECTOR_END 14
#define UNUSED_2_START 0x0810C000
#define UNUSED_2_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_2_SECTOR_START 15
#define UNUSED_2_SECTOR_END 15
#define STORAGE_2_START 0x08110000
#define STORAGE_2_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_2_SECTOR_START 16
#define STORAGE_2_SECTOR_END 16
#define FIRMWARE_P2_START 0x08120000
#define FIRMWARE_P2_MAXSIZE (7 * 128 * 1024)
#define FIRMWARE_P2_SECTOR_START 17
#define FIRMWARE_P2_SECTOR_END 23
// Ram layout - shared boardloader, bootloader, prodtest
#define S_MAIN_STACK_START 0x10000000
#define S_MAIN_STACK_SIZE (16 * 1024)
#define S_FB1_RAM_START 0x10004000
#define S_FB1_RAM_SIZE (0)
#define S_MAIN_RAM_START 0x10004000
#define S_MAIN_RAM_SIZE (48 * 1024 - 0x100)
// RAM layout - kernel
#define K_MAIN_STACK_START 0x10000000
#define K_MAIN_STACK_SIZE (8 * 1024)
#define K_FB1_RAM_START 0x1000C000
#define K_FB1_RAM_SIZE (0)
#define K_MAIN_RAM_START 0x1000C000
#define K_MAIN_RAM_SIZE (16 * 1024 - 0x100)
// RAM layout - common
#define BOOTARGS_START 0x1000FF00
#define BOOTARGS_SIZE 0x100
#define DMABUF_RAM_START 0x20000000
#define DMABUF_RAM_SIZE (1 * 1024)
#define AUX1_RAM_START (0x20000400)
#define AUX1_RAM_SIZE (191 * 1024)
#define AUX2_RAM_START 0x10002000
#define AUX2_RAM_SIZE (40 * 1024)
// misc
#define CODE_ALIGNMENT 0x200
#define COREAPP_ALIGNMENT 0x200
#endif
#include "memory.h"

View File

@ -0,0 +1,91 @@
/*
* 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/>.
*/
#pragma once
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
// misc
#define FLASH_START 0x0C004000
// FLASH layout
#define SECRET_START 0x0C000000
#define SECRET_MAXSIZE (2 * 8 * 1024) // 8 kB
#define SECRET_SECTOR_START 0x0
#define SECRET_SECTOR_END 0x1
// overlaps with secret
#define BHK_START 0x0C002000
#define BHK_MAXSIZE (1 * 8 * 1024) // 8 kB
#define BHK_SECTOR_START 0x1
#define BHK_SECTOR_END 0x1
#define BOARDLOADER_START 0x0C004000
#define BOARDLOADER_MAXSIZE (8 * 8 * 1024) // 64 kB
#define BOARDLOADER_SECTOR_START 0x2
#define BOARDLOADER_SECTOR_END 0x9
#define BOARDCAPS_START 0x0C013F00
#define BOARDCAPS_MAXSIZE 0x100
#define BOOTLOADER_START 0x0C014000
#define BOOTLOADER_MAXSIZE (24 * 8 * 1024) // 192 kB
#define BOOTLOADER_SECTOR_START 0x0A
#define BOOTLOADER_SECTOR_END 0x21
#define FIRMWARE_START 0x0C044000
#define FIRMWARE_MAXSIZE (430 * 8 * 1024) // 3440 kB
#define FIRMWARE_SECTOR_START 0x22
#define FIRMWARE_SECTOR_END 0x1CF
#define KERNEL_START 0x0C044000
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
#define STORAGE_1_START 0x0C3A0000
#define STORAGE_1_MAXSIZE (16 * 8 * 1024) // 128 kB
#define STORAGE_1_SECTOR_START 0x1D0
#define STORAGE_1_SECTOR_END 0x1DF
#define STORAGE_2_START 0x0C3C0000
#define STORAGE_2_MAXSIZE (16 * 8 * 1024) // 128 kB
#define STORAGE_2_SECTOR_START 0x1E0
#define STORAGE_2_SECTOR_END 0x1EF
#define ASSETS_START 0x0C3E0000
#define ASSETS_MAXSIZE (16 * 8 * 1024) // 128 kB
#define ASSETS_SECTOR_START 0x1F0
#define ASSETS_SECTOR_END 0x1FF
// RAM layout
#define BOOTARGS_START 0x30000000
#define BOOTARGS_SIZE 0x200
#define FB1_RAM_START 0x30000200
#define FB1_RAM_SIZE (768 * 1024 - 512)
#define MAIN_RAM_START 0x300C0000
#define MAIN_RAM_SIZE (64 * 1024)
#define FB2_RAM_START 0x300D0000
#define FB2_RAM_SIZE (768 * 1024)
#define AUX1_RAM_START 0x30190000
#define AUX1_RAM_SIZE (896 * 1024)
// misc
#define CODE_ALIGNMENT 0x400
#define COREAPP_ALIGNMENT 0x2000

View File

@ -1,8 +1,6 @@
/* Auto-generated file, do not edit.*/
FLASH_START = 0xc004000;
NORCOW_SECTOR_SIZE = 0x20000;
NORCOW_MIN_VERSION = 0x6;
SECRET_START = 0xc000000;
SECRET_MAXSIZE = 0x4000;
SECRET_SECTOR_START = 0x0;

View File

@ -1,5 +1,23 @@
#ifndef MODELS_MODEL_DISC2_H_
#define MODELS_MODEL_DISC2_H_
/*
* 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/>.
*/
#pragma once
#include <rtl/sizedefs.h>
#include "bootloaders/bootloader_hashes.h"
@ -30,77 +48,7 @@
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
// misc
#define FLASH_START 0x0C004000
#define NORCOW_SECTOR_SIZE (16 * 8 * 1024) // 128 kB
#define NORCOW_MIN_VERSION 0x00000006
// FLASH layout
#define SECRET_START 0x0C000000
#define SECRET_MAXSIZE (2 * 8 * 1024) // 8 kB
#define SECRET_SECTOR_START 0x0
#define SECRET_SECTOR_END 0x1
// overlaps with secret
#define BHK_START 0x0C002000
#define BHK_MAXSIZE (1 * 8 * 1024) // 8 kB
#define BHK_SECTOR_START 0x1
#define BHK_SECTOR_END 0x1
#define BOARDLOADER_START 0x0C004000
#define BOARDLOADER_MAXSIZE (8 * 8 * 1024) // 64 kB
#define BOARDLOADER_SECTOR_START 0x2
#define BOARDLOADER_SECTOR_END 0x9
#define BOARDCAPS_START 0x0C013F00
#define BOARDCAPS_MAXSIZE 0x100
#define BOOTLOADER_START 0x0C014000
#define BOOTLOADER_MAXSIZE (24 * 8 * 1024) // 192 kB
#define BOOTLOADER_SECTOR_START 0x0A
#define BOOTLOADER_SECTOR_END 0x21
#define FIRMWARE_START 0x0C044000
#define FIRMWARE_MAXSIZE (430 * 8 * 1024) // 3440 kB
#define FIRMWARE_SECTOR_START 0x22
#define FIRMWARE_SECTOR_END 0x1CF
#define KERNEL_START 0x0C044000
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
#define STORAGE_1_START 0x0C3A0000
#define STORAGE_1_MAXSIZE (16 * 8 * 1024) // 128 kB
#define STORAGE_1_SECTOR_START 0x1D0
#define STORAGE_1_SECTOR_END 0x1DF
#define STORAGE_2_START 0x0C3C0000
#define STORAGE_2_MAXSIZE (16 * 8 * 1024) // 128 kB
#define STORAGE_2_SECTOR_START 0x1E0
#define STORAGE_2_SECTOR_END 0x1EF
#define ASSETS_START 0x0C3E0000
#define ASSETS_MAXSIZE (16 * 8 * 1024) // 128 kB
#define ASSETS_SECTOR_START 0x1F0
#define ASSETS_SECTOR_END 0x1FF
// RAM layout
#define BOOTARGS_START 0x30000000
#define BOOTARGS_SIZE 0x200
#define FB1_RAM_START 0x30000200
#define FB1_RAM_SIZE (768 * 1024 - 512)
#define MAIN_RAM_START 0x300C0000
#define MAIN_RAM_SIZE (64 * 1024)
#define FB2_RAM_START 0x300D0000
#define FB2_RAM_SIZE (768 * 1024)
#define AUX1_RAM_START 0x30190000
#define AUX1_RAM_SIZE (896 * 1024)
// misc
#define CODE_ALIGNMENT 0x400
#define COREAPP_ALIGNMENT 0x2000
#endif
#include "memory.h"

View File

@ -0,0 +1,122 @@
/*
* 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/>.
*/
#pragma once
// SHARED WITH MAKEFILE
// common
#define FLASH_START 0x08000000
#define NORCOW_SECTOR_SIZE (1 * 64 * 1024) // 64 kB
// FLASH layout
#define BOARDLOADER_START 0x08000000
#define BOARDLOADER_MAXSIZE (3 * 16 * 1024) // 48 kB
#define BOARDLOADER_SECTOR_START 0
#define BOARDLOADER_SECTOR_END 2
#define BOARDCAPS_START 0x0800BF00
#define BOARDCAPS_MAXSIZE 0x100
#define UNUSED_1_START 0x0800C000
#define UNUSED_1_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_1_SECTOR_START 3
#define UNUSED_1_SECTOR_END 3
#define STORAGE_1_START 0x08010000
#define STORAGE_1_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_1_SECTOR_START 4
#define STORAGE_1_SECTOR_END 4
#define BOOTLOADER_START 0x08020000
#define BOOTLOADER_MAXSIZE (1 * 128 * 1024) // 128 kB
#define BOOTLOADER_SECTOR_START 5
#define BOOTLOADER_SECTOR_END 5
#define FIRMWARE_START 0x08040000
#define FIRMWARE_MAXSIZE (13 * 128 * 1024) // 1664 kB
#define FIRMWARE_P1_START 0x08040000
#define FIRMWARE_P1_MAXSIZE (6 * 128 * 1024)
#define FIRMWARE_P1_SECTOR_START 6
#define FIRMWARE_P1_SECTOR_END 11
// part of firmware P1
#define KERNEL_START 0x08040000
#define KERNEL_MAXSIZE (4 * 128 * 1024)
#define SECRET_START 0x08100000
#define SECRET_MAXSIZE (1 * 16 * 1024) // 16 kB
#define SECRET_SECTOR_START 12
#define SECRET_SECTOR_END 12
#define ASSETS_START 0x08104000
#define ASSETS_MAXSIZE (2 * 16 * 1024) // 32 kB
#define ASSETS_SECTOR_START 13
#define ASSETS_SECTOR_END 14
#define UNUSED_2_START 0x0810C000
#define UNUSED_2_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_2_SECTOR_START 15
#define UNUSED_2_SECTOR_END 15
#define STORAGE_2_START 0x08110000
#define STORAGE_2_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_2_SECTOR_START 16
#define STORAGE_2_SECTOR_END 16
#define FIRMWARE_P2_START 0x08120000
#define FIRMWARE_P2_MAXSIZE (7 * 128 * 1024)
#define FIRMWARE_P2_SECTOR_START 17
#define FIRMWARE_P2_SECTOR_END 23
// Ram layout - shared boardloader, bootloader, prodtest
#define S_MAIN_STACK_START 0x10000000
#define S_MAIN_STACK_SIZE (16 * 1024)
#define S_FB1_RAM_START 0x10004000
#define S_FB1_RAM_SIZE (8 * 1024)
#define S_MAIN_RAM_START 0x10006000
#define S_MAIN_RAM_SIZE (40 * 1024 - 0x100)
// RAM layout - kernel
#define K_MAIN_STACK_START 0x10000000
#define K_MAIN_STACK_SIZE (8 * 1024)
#define K_FB1_RAM_START 0x1000A000
#define K_FB1_RAM_SIZE (8 * 1024)
#define K_MAIN_RAM_START 0x1000C000
#define K_MAIN_RAM_SIZE (16 * 1024 - 0x100)
// RAM layout - common
#define BOOTARGS_START 0x1000FF00
#define BOOTARGS_SIZE 0x100
#define DMABUF_RAM_START 0x20000000
#define DMABUF_RAM_SIZE (1 * 1024)
#define AUX1_RAM_START (0x20000400)
#define AUX1_RAM_SIZE (191 * 1024)
#define AUX2_RAM_START 0x10002000
#define AUX2_RAM_SIZE (32 * 1024)
// misc
#define CODE_ALIGNMENT 0x200
#define COREAPP_ALIGNMENT 0x200

View File

@ -2,7 +2,6 @@
FLASH_START = 0x8000000;
NORCOW_SECTOR_SIZE = 0x10000;
NORCOW_MIN_VERSION = 0x3;
BOARDLOADER_START = 0x8000000;
BOARDLOADER_MAXSIZE = 0xc000;
BOARDLOADER_SECTOR_START = 0x0;

View File

@ -1,5 +1,23 @@
#ifndef MODELS_MODEL_T2B1_H_
#define MODELS_MODEL_T2B1_H_
/*
* 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/>.
*/
#pragma once
#include "bootloaders/bootloader_hashes.h"
@ -29,107 +47,7 @@
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
#define RSOD_INFINITE_LOOP 1
// SHARED WITH MAKEFILE
// common
#define FLASH_START 0x08000000
#define NORCOW_SECTOR_SIZE (1 * 64 * 1024) // 64 kB
#define NORCOW_MIN_VERSION 0x00000003
// FLASH layout
#define BOARDLOADER_START 0x08000000
#define BOARDLOADER_MAXSIZE (3 * 16 * 1024) // 48 kB
#define BOARDLOADER_SECTOR_START 0
#define BOARDLOADER_SECTOR_END 2
#define BOARDCAPS_START 0x0800BF00
#define BOARDCAPS_MAXSIZE 0x100
#define UNUSED_1_START 0x0800C000
#define UNUSED_1_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_1_SECTOR_START 3
#define UNUSED_1_SECTOR_END 3
#define STORAGE_1_START 0x08010000
#define STORAGE_1_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_1_SECTOR_START 4
#define STORAGE_1_SECTOR_END 4
#define BOOTLOADER_START 0x08020000
#define BOOTLOADER_MAXSIZE (1 * 128 * 1024) // 128 kB
#define BOOTLOADER_SECTOR_START 5
#define BOOTLOADER_SECTOR_END 5
#define FIRMWARE_START 0x08040000
#define FIRMWARE_MAXSIZE (13 * 128 * 1024) // 1664 kB
#define FIRMWARE_P1_START 0x08040000
#define FIRMWARE_P1_MAXSIZE (6 * 128 * 1024)
#define FIRMWARE_P1_SECTOR_START 6
#define FIRMWARE_P1_SECTOR_END 11
// part of firmware P1
#define KERNEL_START 0x08040000
#define KERNEL_MAXSIZE (4 * 128 * 1024)
#define SECRET_START 0x08100000
#define SECRET_MAXSIZE (1 * 16 * 1024) // 16 kB
#define SECRET_SECTOR_START 12
#define SECRET_SECTOR_END 12
#define ASSETS_START 0x08104000
#define ASSETS_MAXSIZE (2 * 16 * 1024) // 32 kB
#define ASSETS_SECTOR_START 13
#define ASSETS_SECTOR_END 14
#define UNUSED_2_START 0x0810C000
#define UNUSED_2_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_2_SECTOR_START 15
#define UNUSED_2_SECTOR_END 15
#define STORAGE_2_START 0x08110000
#define STORAGE_2_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_2_SECTOR_START 16
#define STORAGE_2_SECTOR_END 16
#define FIRMWARE_P2_START 0x08120000
#define FIRMWARE_P2_MAXSIZE (7 * 128 * 1024)
#define FIRMWARE_P2_SECTOR_START 17
#define FIRMWARE_P2_SECTOR_END 23
// Ram layout - shared boardloader, bootloader, prodtest
#define S_MAIN_STACK_START 0x10000000
#define S_MAIN_STACK_SIZE (16 * 1024)
#define S_FB1_RAM_START 0x10004000
#define S_FB1_RAM_SIZE (8 * 1024)
#define S_MAIN_RAM_START 0x10006000
#define S_MAIN_RAM_SIZE (40 * 1024 - 0x100)
// RAM layout - kernel
#define K_MAIN_STACK_START 0x10000000
#define K_MAIN_STACK_SIZE (8 * 1024)
#define K_FB1_RAM_START 0x1000A000
#define K_FB1_RAM_SIZE (8 * 1024)
#define K_MAIN_RAM_START 0x1000C000
#define K_MAIN_RAM_SIZE (16 * 1024 - 0x100)
// RAM layout - common
#define BOOTARGS_START 0x1000FF00
#define BOOTARGS_SIZE 0x100
#define DMABUF_RAM_START 0x20000000
#define DMABUF_RAM_SIZE (1 * 1024)
#define AUX1_RAM_START (0x20000400)
#define AUX1_RAM_SIZE (191 * 1024)
#define AUX2_RAM_START 0x10002000
#define AUX2_RAM_SIZE (32 * 1024)
// misc
#define CODE_ALIGNMENT 0x200
#define COREAPP_ALIGNMENT 0x200
#endif
#include "memory.h"

View File

@ -0,0 +1,117 @@
/*
* 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/>.
*/
#pragma once
// SHARED WITH MAKEFILE
// common
#define FLASH_START 0x08000000
#define NORCOW_SECTOR_SIZE (1 * 64 * 1024) // 64 kB
// FLASH layout
#define BOARDLOADER_START 0x08000000
#define BOARDLOADER_MAXSIZE (3 * 16 * 1024) // 48 kB
#define BOARDLOADER_SECTOR_START 0
#define BOARDLOADER_SECTOR_END 2
#define BOARDCAPS_START 0x0800BF00
#define BOARDCAPS_MAXSIZE 0x100
#define UNUSED_1_START 0x0800C000
#define UNUSED_1_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_1_SECTOR_START 3
#define UNUSED_1_SECTOR_END 3
#define STORAGE_1_START 0x08010000
#define STORAGE_1_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_1_SECTOR_START 4
#define STORAGE_1_SECTOR_END 4
#define BOOTLOADER_START 0x08020000
#define BOOTLOADER_MAXSIZE (1 * 128 * 1024) // 128 kB
#define BOOTLOADER_SECTOR_START 5
#define BOOTLOADER_SECTOR_END 5
#define FIRMWARE_START 0x08040000
#define FIRMWARE_MAXSIZE (13 * 128 * 1024) // 1664 kB
#define FIRMWARE_P1_START 0x08040000
#define FIRMWARE_P1_MAXSIZE (6 * 128 * 1024)
#define FIRMWARE_P1_SECTOR_START 6
#define FIRMWARE_P1_SECTOR_END 11
// part of firmware P1
#define KERNEL_START 0x08040000
#define KERNEL_MAXSIZE (4 * 128 * 1024)
#define ASSETS_START 0x08100000
#define ASSETS_MAXSIZE (3 * 16 * 1024) // 48 kB
#define ASSETS_SECTOR_START 12
#define ASSETS_SECTOR_END 14
#define UNUSED_2_START 0x0810C000
#define UNUSED_2_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_2_SECTOR_START 15
#define UNUSED_2_SECTOR_END 15
#define STORAGE_2_START 0x08110000
#define STORAGE_2_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_2_SECTOR_START 16
#define STORAGE_2_SECTOR_END 16
#define FIRMWARE_P2_START 0x08120000
#define FIRMWARE_P2_MAXSIZE (7 * 128 * 1024)
#define FIRMWARE_P2_SECTOR_START 17
#define FIRMWARE_P2_SECTOR_END 23
// Ram layout - shared boardloader, bootloader, prodtest
#define S_MAIN_STACK_START 0x10000000
#define S_MAIN_STACK_SIZE (16 * 1024)
#define S_FB1_RAM_START 0x10004000
#define S_FB1_RAM_SIZE (0)
#define S_MAIN_RAM_START 0x10004000
#define S_MAIN_RAM_SIZE (48 * 1024 - 0x100)
// RAM layout - kernel
#define K_MAIN_STACK_START 0x10000000
#define K_MAIN_STACK_SIZE (8 * 1024)
#define K_FB1_RAM_START 0x1000C000
#define K_FB1_RAM_SIZE (0)
#define K_MAIN_RAM_START 0x1000C000
#define K_MAIN_RAM_SIZE (16 * 1024 - 0x100)
// RAM layout - common
#define BOOTARGS_START 0x1000FF00
#define BOOTARGS_SIZE 0x100
#define DMABUF_RAM_START 0x20000000
#define DMABUF_RAM_SIZE (1 * 1024)
#define AUX1_RAM_START (0x20000400)
#define AUX1_RAM_SIZE (191 * 1024)
#define AUX2_RAM_START 0x10002000
#define AUX2_RAM_SIZE (40 * 1024)
// misc
#define CODE_ALIGNMENT 0x200
#define COREAPP_ALIGNMENT 0x200

View File

@ -2,7 +2,6 @@
FLASH_START = 0x8000000;
NORCOW_SECTOR_SIZE = 0x10000;
NORCOW_MIN_VERSION = 0x0;
BOARDLOADER_START = 0x8000000;
BOARDLOADER_MAXSIZE = 0xc000;
BOARDLOADER_SECTOR_START = 0x0;

View File

@ -1,5 +1,23 @@
#ifndef MODELS_MODEL_T2T1_H_
#define MODELS_MODEL_T2T1_H_
/*
* 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/>.
*/
#pragma once
#include "bootloaders/bootloader_hashes.h"
@ -29,102 +47,7 @@
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
#define RSOD_INFINITE_LOOP 1
// SHARED WITH MAKEFILE
// common
#define FLASH_START 0x08000000
#define NORCOW_SECTOR_SIZE (1 * 64 * 1024) // 64 kB
#define NORCOW_MIN_VERSION 0x00000000
// FLASH layout
#define BOARDLOADER_START 0x08000000
#define BOARDLOADER_MAXSIZE (3 * 16 * 1024) // 48 kB
#define BOARDLOADER_SECTOR_START 0
#define BOARDLOADER_SECTOR_END 2
#define BOARDCAPS_START 0x0800BF00
#define BOARDCAPS_MAXSIZE 0x100
#define UNUSED_1_START 0x0800C000
#define UNUSED_1_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_1_SECTOR_START 3
#define UNUSED_1_SECTOR_END 3
#define STORAGE_1_START 0x08010000
#define STORAGE_1_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_1_SECTOR_START 4
#define STORAGE_1_SECTOR_END 4
#define BOOTLOADER_START 0x08020000
#define BOOTLOADER_MAXSIZE (1 * 128 * 1024) // 128 kB
#define BOOTLOADER_SECTOR_START 5
#define BOOTLOADER_SECTOR_END 5
#define FIRMWARE_START 0x08040000
#define FIRMWARE_MAXSIZE (13 * 128 * 1024) // 1664 kB
#define FIRMWARE_P1_START 0x08040000
#define FIRMWARE_P1_MAXSIZE (6 * 128 * 1024)
#define FIRMWARE_P1_SECTOR_START 6
#define FIRMWARE_P1_SECTOR_END 11
// part of firmware P1
#define KERNEL_START 0x08040000
#define KERNEL_MAXSIZE (4 * 128 * 1024)
#define ASSETS_START 0x08100000
#define ASSETS_MAXSIZE (3 * 16 * 1024) // 48 kB
#define ASSETS_SECTOR_START 12
#define ASSETS_SECTOR_END 14
#define UNUSED_2_START 0x0810C000
#define UNUSED_2_MAXSIZE (1 * 16 * 1024) // 16 kB
#define UNUSED_2_SECTOR_START 15
#define UNUSED_2_SECTOR_END 15
#define STORAGE_2_START 0x08110000
#define STORAGE_2_MAXSIZE (1 * 64 * 1024) // 64 kB
#define STORAGE_2_SECTOR_START 16
#define STORAGE_2_SECTOR_END 16
#define FIRMWARE_P2_START 0x08120000
#define FIRMWARE_P2_MAXSIZE (7 * 128 * 1024)
#define FIRMWARE_P2_SECTOR_START 17
#define FIRMWARE_P2_SECTOR_END 23
// Ram layout - shared boardloader, bootloader, prodtest
#define S_MAIN_STACK_START 0x10000000
#define S_MAIN_STACK_SIZE (16 * 1024)
#define S_FB1_RAM_START 0x10004000
#define S_FB1_RAM_SIZE (0)
#define S_MAIN_RAM_START 0x10004000
#define S_MAIN_RAM_SIZE (48 * 1024 - 0x100)
// RAM layout - kernel
#define K_MAIN_STACK_START 0x10000000
#define K_MAIN_STACK_SIZE (8 * 1024)
#define K_FB1_RAM_START 0x1000C000
#define K_FB1_RAM_SIZE (0)
#define K_MAIN_RAM_START 0x1000C000
#define K_MAIN_RAM_SIZE (16 * 1024 - 0x100)
// RAM layout - common
#define BOOTARGS_START 0x1000FF00
#define BOOTARGS_SIZE 0x100
#define DMABUF_RAM_START 0x20000000
#define DMABUF_RAM_SIZE (1 * 1024)
#define AUX1_RAM_START (0x20000400)
#define AUX1_RAM_SIZE (191 * 1024)
#define AUX2_RAM_START 0x10002000
#define AUX2_RAM_SIZE (40 * 1024)
// misc
#define CODE_ALIGNMENT 0x200
#define COREAPP_ALIGNMENT 0x200
#endif
#include "memory.h"

View File

@ -0,0 +1,99 @@
/*
* 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/>.
*/
#pragma once
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
// misc
#define FLASH_START 0x0C004000
// FLASH layout
#define SECRET_START 0x0C000000
#define SECRET_MAXSIZE (2 * 8 * 1024) // 8 kB
#define SECRET_SECTOR_START 0x0
#define SECRET_SECTOR_END 0x1
// overlaps with secret
#define BHK_START 0x0C002000
#define BHK_MAXSIZE (1 * 8 * 1024) // 8 kB
#define BHK_SECTOR_START 0x1
#define BHK_SECTOR_END 0x1
#define BOARDLOADER_START 0x0C004000
#define BOARDLOADER_MAXSIZE (6 * 8 * 1024) // 48 kB
#define BOARDLOADER_SECTOR_START 0x2
#define BOARDLOADER_SECTOR_END 0x7
#define BOARDCAPS_START 0x0C00FF00
#define BOARDCAPS_MAXSIZE 0x100
#define BOOTLOADER_START 0x0C010000
#define BOOTLOADER_MAXSIZE (16 * 8 * 1024) // 128 kB
#define BOOTLOADER_SECTOR_START 0x8
#define BOOTLOADER_SECTOR_END 0x17
#define STORAGE_1_START 0x0C030000
#define STORAGE_1_MAXSIZE (8 * 8 * 1024) // 64 kB
#define STORAGE_1_SECTOR_START 0x18
#define STORAGE_1_SECTOR_END 0x1F
#define STORAGE_2_START 0x0C040000
#define STORAGE_2_MAXSIZE (8 * 8 * 1024) // 64 kB
#define STORAGE_2_SECTOR_START 0x20
#define STORAGE_2_SECTOR_END 0x27
#define FIRMWARE_START 0x0C050000
#define FIRMWARE_MAXSIZE (208 * 8 * 1024) // 1664 kB
#define FIRMWARE_SECTOR_START 0x28
#define FIRMWARE_SECTOR_END 0xF7
#define KERNEL_START 0x0C050000
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
#define ASSETS_START 0x0C1F0000
#define ASSETS_MAXSIZE (8 * 8 * 1024) // 64 kB
#define ASSETS_SECTOR_START 0xF8
#define ASSETS_SECTOR_END 0xFF
// RAM layout
#define AUX1_RAM_START 0x30000000
#define AUX1_RAM_SIZE (192 * 1024 - 512)
// 256 bytes skipped - trustzone alignment vs fixed bootargs position
#define BOOTARGS_START 0x3002FF00
#define BOOTARGS_SIZE 0x100
#define MAIN_RAM_START 0x30030000
#define MAIN_RAM_SIZE (24 * 1024 - 512)
#define SAES_RAM_START 0x30035E00
#define SAES_RAM_SIZE 512
#define AUX2_RAM_START 0x30036000
#define AUX2_RAM_SIZE (544 * 1024)
#define FB1_RAM_START 0x300BE000
#define FB1_RAM_SIZE (0x2000)
#define FB2_RAM_START 0x300C0000
#define FB2_RAM_SIZE (0)
// misc
#define CODE_ALIGNMENT 0x200
#define COREAPP_ALIGNMENT 0x2000

View File

@ -1,8 +1,6 @@
/* Auto-generated file, do not edit.*/
FLASH_START = 0xc004000;
NORCOW_SECTOR_SIZE = 0x10000;
NORCOW_MIN_VERSION = 0x5;
SECRET_START = 0xc000000;
SECRET_MAXSIZE = 0x4000;
SECRET_SECTOR_START = 0x0;

View File

@ -1,5 +1,23 @@
#ifndef MODELS_MODEL_T3B1_H_
#define MODELS_MODEL_T3B1_H_
/*
* 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/>.
*/
#pragma once
#include "bootloaders/bootloader_hashes.h"
@ -30,85 +48,7 @@
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
#define RSOD_INFINITE_LOOP 1
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
// misc
#define FLASH_START 0x0C004000
#define NORCOW_SECTOR_SIZE (8 * 8 * 1024) // 64 kB
#define NORCOW_MIN_VERSION 0x00000005
// FLASH layout
#define SECRET_START 0x0C000000
#define SECRET_MAXSIZE (2 * 8 * 1024) // 8 kB
#define SECRET_SECTOR_START 0x0
#define SECRET_SECTOR_END 0x1
// overlaps with secret
#define BHK_START 0x0C002000
#define BHK_MAXSIZE (1 * 8 * 1024) // 8 kB
#define BHK_SECTOR_START 0x1
#define BHK_SECTOR_END 0x1
#define BOARDLOADER_START 0x0C004000
#define BOARDLOADER_MAXSIZE (6 * 8 * 1024) // 48 kB
#define BOARDLOADER_SECTOR_START 0x2
#define BOARDLOADER_SECTOR_END 0x7
#define BOARDCAPS_START 0x0C00FF00
#define BOARDCAPS_MAXSIZE 0x100
#define BOOTLOADER_START 0x0C010000
#define BOOTLOADER_MAXSIZE (16 * 8 * 1024) // 128 kB
#define BOOTLOADER_SECTOR_START 0x8
#define BOOTLOADER_SECTOR_END 0x17
#define STORAGE_1_START 0x0C030000
#define STORAGE_1_MAXSIZE (8 * 8 * 1024) // 64 kB
#define STORAGE_1_SECTOR_START 0x18
#define STORAGE_1_SECTOR_END 0x1F
#define STORAGE_2_START 0x0C040000
#define STORAGE_2_MAXSIZE (8 * 8 * 1024) // 64 kB
#define STORAGE_2_SECTOR_START 0x20
#define STORAGE_2_SECTOR_END 0x27
#define FIRMWARE_START 0x0C050000
#define FIRMWARE_MAXSIZE (208 * 8 * 1024) // 1664 kB
#define FIRMWARE_SECTOR_START 0x28
#define FIRMWARE_SECTOR_END 0xF7
#define KERNEL_START 0x0C050000
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
#define ASSETS_START 0x0C1F0000
#define ASSETS_MAXSIZE (8 * 8 * 1024) // 64 kB
#define ASSETS_SECTOR_START 0xF8
#define ASSETS_SECTOR_END 0xFF
// RAM layout
#define AUX1_RAM_START 0x30000000
#define AUX1_RAM_SIZE (192 * 1024 - 512)
// 256 bytes skipped - trustzone alignment vs fixed bootargs position
#define BOOTARGS_START 0x3002FF00
#define BOOTARGS_SIZE 0x100
#define MAIN_RAM_START 0x30030000
#define MAIN_RAM_SIZE (24 * 1024 - 512)
#define SAES_RAM_START 0x30035E00
#define SAES_RAM_SIZE 512
#define AUX2_RAM_START 0x30036000
#define AUX2_RAM_SIZE (544 * 1024)
#define FB1_RAM_START 0x300BE000
#define FB1_RAM_SIZE (0x2000)
#define FB2_RAM_START 0x300C0000
#define FB2_RAM_SIZE (0)
// misc
#define CODE_ALIGNMENT 0x200
#define COREAPP_ALIGNMENT 0x2000
#endif
#include "memory.h"

View File

@ -0,0 +1,99 @@
/*
* 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/>.
*/
#pragma once
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
// misc
#define FLASH_START 0x0C004000
// FLASH layout
#define SECRET_START 0x0C000000
#define SECRET_MAXSIZE (2 * 8 * 1024) // 8 kB
#define SECRET_SECTOR_START 0x0
#define SECRET_SECTOR_END 0x1
// overlaps with secret
#define BHK_START 0x0C002000
#define BHK_MAXSIZE (1 * 8 * 1024) // 8 kB
#define BHK_SECTOR_START 0x1
#define BHK_SECTOR_END 0x1
#define BOARDLOADER_START 0x0C004000
#define BOARDLOADER_MAXSIZE (6 * 8 * 1024) // 48 kB
#define BOARDLOADER_SECTOR_START 0x2
#define BOARDLOADER_SECTOR_END 0x7
#define BOARDCAPS_START 0x0C00FF00
#define BOARDCAPS_MAXSIZE 0x100
#define BOOTLOADER_START 0x0C010000
#define BOOTLOADER_MAXSIZE (16 * 8 * 1024) // 128 kB
#define BOOTLOADER_SECTOR_START 0x8
#define BOOTLOADER_SECTOR_END 0x17
#define STORAGE_1_START 0x0C030000
#define STORAGE_1_MAXSIZE (8 * 8 * 1024) // 64 kB
#define STORAGE_1_SECTOR_START 0x18
#define STORAGE_1_SECTOR_END 0x1F
#define STORAGE_2_START 0x0C040000
#define STORAGE_2_MAXSIZE (8 * 8 * 1024) // 64 kB
#define STORAGE_2_SECTOR_START 0x20
#define STORAGE_2_SECTOR_END 0x27
#define FIRMWARE_START 0x0C050000
#define FIRMWARE_MAXSIZE (208 * 8 * 1024) // 1664 kB
#define FIRMWARE_SECTOR_START 0x28
#define FIRMWARE_SECTOR_END 0xF7
#define KERNEL_START 0x0C050000
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
#define ASSETS_START 0x0C1F0000
#define ASSETS_MAXSIZE (8 * 8 * 1024) // 64 kB
#define ASSETS_SECTOR_START 0xF8
#define ASSETS_SECTOR_END 0xFF
// RAM layout
#define AUX1_RAM_START 0x30000000
#define AUX1_RAM_SIZE (192 * 1024 - 512)
// 256 bytes skipped - trustzone alignment vs fixed bootargs position
#define BOOTARGS_START 0x3002FF00
#define BOOTARGS_SIZE 0x100
#define MAIN_RAM_START 0x30030000
#define MAIN_RAM_SIZE (24 * 1024 - 512)
#define SAES_RAM_START 0x30035E00
#define SAES_RAM_SIZE 512
#define AUX2_RAM_START 0x30036000
#define AUX2_RAM_SIZE (327 * 1024)
#define FB1_RAM_START 0x30087C00
#define FB1_RAM_SIZE (115200)
#define FB2_RAM_START 0x300A3E00
#define FB2_RAM_SIZE (115200)
// misc
#define CODE_ALIGNMENT 0x200
#define COREAPP_ALIGNMENT 0x2000

View File

@ -1,8 +1,6 @@
/* Auto-generated file, do not edit.*/
FLASH_START = 0xc004000;
NORCOW_SECTOR_SIZE = 0x10000;
NORCOW_MIN_VERSION = 0x4;
SECRET_START = 0xc000000;
SECRET_MAXSIZE = 0x4000;
SECRET_SECTOR_START = 0x0;

View File

@ -1,5 +1,23 @@
#ifndef MODELS_MODEL_T3T1_H_
#define MODELS_MODEL_T3T1_H_
/*
* 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/>.
*/
#pragma once
#include "bootloaders/bootloader_hashes.h"
@ -30,85 +48,7 @@
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RETAIN_CONTENT
#define RSOD_INFINITE_LOOP 1
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
// misc
#define FLASH_START 0x0C004000
#define NORCOW_SECTOR_SIZE (8 * 8 * 1024) // 64 kB
#define NORCOW_MIN_VERSION 0x00000004
// FLASH layout
#define SECRET_START 0x0C000000
#define SECRET_MAXSIZE (2 * 8 * 1024) // 8 kB
#define SECRET_SECTOR_START 0x0
#define SECRET_SECTOR_END 0x1
// overlaps with secret
#define BHK_START 0x0C002000
#define BHK_MAXSIZE (1 * 8 * 1024) // 8 kB
#define BHK_SECTOR_START 0x1
#define BHK_SECTOR_END 0x1
#define BOARDLOADER_START 0x0C004000
#define BOARDLOADER_MAXSIZE (6 * 8 * 1024) // 48 kB
#define BOARDLOADER_SECTOR_START 0x2
#define BOARDLOADER_SECTOR_END 0x7
#define BOARDCAPS_START 0x0C00FF00
#define BOARDCAPS_MAXSIZE 0x100
#define BOOTLOADER_START 0x0C010000
#define BOOTLOADER_MAXSIZE (16 * 8 * 1024) // 128 kB
#define BOOTLOADER_SECTOR_START 0x8
#define BOOTLOADER_SECTOR_END 0x17
#define STORAGE_1_START 0x0C030000
#define STORAGE_1_MAXSIZE (8 * 8 * 1024) // 64 kB
#define STORAGE_1_SECTOR_START 0x18
#define STORAGE_1_SECTOR_END 0x1F
#define STORAGE_2_START 0x0C040000
#define STORAGE_2_MAXSIZE (8 * 8 * 1024) // 64 kB
#define STORAGE_2_SECTOR_START 0x20
#define STORAGE_2_SECTOR_END 0x27
#define FIRMWARE_START 0x0C050000
#define FIRMWARE_MAXSIZE (208 * 8 * 1024) // 1664 kB
#define FIRMWARE_SECTOR_START 0x28
#define FIRMWARE_SECTOR_END 0xF7
#define KERNEL_START 0x0C050000
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
#define ASSETS_START 0x0C1F0000
#define ASSETS_MAXSIZE (8 * 8 * 1024) // 64 kB
#define ASSETS_SECTOR_START 0xF8
#define ASSETS_SECTOR_END 0xFF
// RAM layout
#define AUX1_RAM_START 0x30000000
#define AUX1_RAM_SIZE (192 * 1024 - 512)
// 256 bytes skipped - trustzone alignment vs fixed bootargs position
#define BOOTARGS_START 0x3002FF00
#define BOOTARGS_SIZE 0x100
#define MAIN_RAM_START 0x30030000
#define MAIN_RAM_SIZE (24 * 1024 - 512)
#define SAES_RAM_START 0x30035E00
#define SAES_RAM_SIZE 512
#define AUX2_RAM_START 0x30036000
#define AUX2_RAM_SIZE (327 * 1024)
#define FB1_RAM_START 0x30087C00
#define FB1_RAM_SIZE (115200)
#define FB2_RAM_START 0x300A3E00
#define FB2_RAM_SIZE (115200)
// misc
#define CODE_ALIGNMENT 0x200
#define COREAPP_ALIGNMENT 0x2000
#endif
#include "memory.h"

View File

@ -0,0 +1,92 @@
/*
* 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/>.
*/
#pragma once
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
// misc
#define FLASH_START (0x0C004000)
// FLASH layout
#define SECRET_START (0x0C000000)
#define SECRET_MAXSIZE (2 * 8 * 1024) // 8 kB
#define SECRET_SECTOR_START 0x0
#define SECRET_SECTOR_END 0x1
// overlaps with secret
#define BHK_START (0x0C002000)
#define BHK_MAXSIZE (1 * 8 * 1024) // 8 kB
#define BHK_SECTOR_START 0x1
#define BHK_SECTOR_END 0x1
#define BOARDLOADER_START (0x0C004000)
#define BOARDLOADER_MAXSIZE (8 * 8 * 1024) // 64 kB
#define BOARDLOADER_SECTOR_START 0x2
#define BOARDLOADER_SECTOR_END 0x9
#define BOARDCAPS_START (0x0C013F00)
#define BOARDCAPS_MAXSIZE 0x100
#define BOOTLOADER_START (0x0C014000)
#define BOOTLOADER_MAXSIZE (24 * 8 * 1024) // 192 kB
#define BOOTLOADER_SECTOR_START 0x0A
#define BOOTLOADER_SECTOR_END 0x21
#define FIRMWARE_START (0x0C044000)
#define FIRMWARE_MAXSIZE (430 * 8 * 1024) // 3440 kB
#define FIRMWARE_SECTOR_START 0x22
#define FIRMWARE_SECTOR_END 0x1CF
#define KERNEL_START (0x0C044000)
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
#define STORAGE_1_START (0x0C3A0000)
#define STORAGE_1_MAXSIZE (16 * 8 * 1024) // 128 kB
#define STORAGE_1_SECTOR_START 0x1D0
#define STORAGE_1_SECTOR_END 0x1DF
#define STORAGE_2_START (0x0C3C0000)
#define STORAGE_2_MAXSIZE (16 * 8 * 1024) // 128 kB
#define STORAGE_2_SECTOR_START 0x1E0
#define STORAGE_2_SECTOR_END 0x1EF
#define ASSETS_START (0x0C3E0000)
#define ASSETS_MAXSIZE (16 * 8 * 1024) // 128 kB
#define ASSETS_SECTOR_START 0x1F0
#define ASSETS_SECTOR_END 0x1FF
// RAM layout
#define BOOTARGS_START (0x30000000)
#define BOOTARGS_SIZE 0x200
#define FB1_RAM_START (0x30000200)
#define FB1_RAM_SIZE (768 * 1024 - 512)
#define MAIN_RAM_START (0x300C0000)
#define MAIN_RAM_SIZE (64 * 1024)
#define FB2_RAM_START (0x300D0000)
#define FB2_RAM_SIZE (768 * 1024)
#define AUX1_RAM_START (0x30190000)
#define AUX1_RAM_SIZE (896 * 1024)
// misc
#define CODE_ALIGNMENT 0x400
#define COREAPP_ALIGNMENT 0x2000

View File

@ -1,8 +1,6 @@
/* Auto-generated file, do not edit.*/
FLASH_START = 0xc004000;
NORCOW_SECTOR_SIZE = 0x20000;
NORCOW_MIN_VERSION = 0x6;
SECRET_START = 0xc000000;
SECRET_MAXSIZE = 0x4000;
SECRET_SECTOR_START = 0x0;

View File

@ -1,7 +1,24 @@
#ifndef MODELS_MODEL_T3W1_H_
#define MODELS_MODEL_T3W1_H_
// #include "bootloaders/bootloader_hashes.h"
/*
* 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/>.
*/
#pragma once
#include <rtl/sizedefs.h>
@ -29,77 +46,7 @@
#define DISPLAY_JUMP_BEHAVIOR DISPLAY_RESET_CONTENT
// SHARED WITH MAKEFILE, LINKER SCRIPT etc.
// misc
#define FLASH_START 0x0C004000
#define NORCOW_SECTOR_SIZE (16 * 8 * 1024) // 128 kB
#define NORCOW_MIN_VERSION 0x00000006
// FLASH layout
#define SECRET_START 0x0C000000
#define SECRET_MAXSIZE (2 * 8 * 1024) // 8 kB
#define SECRET_SECTOR_START 0x0
#define SECRET_SECTOR_END 0x1
// overlaps with secret
#define BHK_START 0x0C002000
#define BHK_MAXSIZE (1 * 8 * 1024) // 8 kB
#define BHK_SECTOR_START 0x1
#define BHK_SECTOR_END 0x1
#define BOARDLOADER_START 0x0C004000
#define BOARDLOADER_MAXSIZE (8 * 8 * 1024) // 64 kB
#define BOARDLOADER_SECTOR_START 0x2
#define BOARDLOADER_SECTOR_END 0x9
#define BOARDCAPS_START 0x0C013F00
#define BOARDCAPS_MAXSIZE 0x100
#define BOOTLOADER_START 0x0C014000
#define BOOTLOADER_MAXSIZE (24 * 8 * 1024) // 192 kB
#define BOOTLOADER_SECTOR_START 0x0A
#define BOOTLOADER_SECTOR_END 0x21
#define FIRMWARE_START 0x0C044000
#define FIRMWARE_MAXSIZE (430 * 8 * 1024) // 3440 kB
#define FIRMWARE_SECTOR_START 0x22
#define FIRMWARE_SECTOR_END 0x1CF
#define KERNEL_START 0x0C044000
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
#define STORAGE_1_START 0x0C3A0000
#define STORAGE_1_MAXSIZE (16 * 8 * 1024) // 128 kB
#define STORAGE_1_SECTOR_START 0x1D0
#define STORAGE_1_SECTOR_END 0x1DF
#define STORAGE_2_START 0x0C3C0000
#define STORAGE_2_MAXSIZE (16 * 8 * 1024) // 128 kB
#define STORAGE_2_SECTOR_START 0x1E0
#define STORAGE_2_SECTOR_END 0x1EF
#define ASSETS_START 0x0C3E0000
#define ASSETS_MAXSIZE (16 * 8 * 1024) // 128 kB
#define ASSETS_SECTOR_START 0x1F0
#define ASSETS_SECTOR_END 0x1FF
// RAM layout
#define BOOTARGS_START 0x30000000
#define BOOTARGS_SIZE 0x200
#define FB1_RAM_START 0x30000200
#define FB1_RAM_SIZE (768 * 1024 - 512)
#define MAIN_RAM_START 0x300C0000
#define MAIN_RAM_SIZE (64 * 1024)
#define FB2_RAM_START 0x300D0000
#define FB2_RAM_SIZE (768 * 1024)
#define AUX1_RAM_START 0x30190000
#define AUX1_RAM_SIZE (896 * 1024)
// misc
#define CODE_ALIGNMENT 0x400
#define COREAPP_ALIGNMENT 0x2000
#endif
#include "memory.h"

View File

@ -18,6 +18,7 @@ def configure(
mcu = "STM32U5G9xx"
linker_script = """embed/sys/linker/stm32u5g/{target}.ld"""
memory_layout = "memory.ld"
stm32u5_common_files(env, features_wanted, defines, sources, paths)
@ -108,5 +109,6 @@ def configure(
]
env.get("ENV")["LINKER_SCRIPT"] = linker_script
env.get("ENV")["MEMORY_LAYOUT"] = memory_layout
return features_available

View File

@ -27,6 +27,7 @@ def configure(
mcu = "STM32U585xx"
linker_script = """embed/sys/linker/stm32u58/{target}.ld"""
memory_layout = "memory.ld"
stm32u5_common_files(env, features_wanted, defines, sources, paths)
@ -116,5 +117,6 @@ def configure(
env.get("ENV")["TREZOR_BOARD"] = board
env.get("ENV")["MCU_TYPE"] = mcu
env.get("ENV")["LINKER_SCRIPT"] = linker_script
env.get("ENV")["MEMORY_LAYOUT"] = memory_layout
return features_available

View File

@ -29,6 +29,7 @@ def configure(
mcu = "STM32U585xx"
linker_script = """embed/sys/linker/stm32u58/{target}.ld"""
memory_layout = "memory.ld"
stm32u5_common_files(env, features_wanted, defines, sources, paths)
@ -149,5 +150,6 @@ def configure(
env.get("ENV")["TREZOR_BOARD"] = board
env.get("ENV")["MCU_TYPE"] = mcu
env.get("ENV")["LINKER_SCRIPT"] = linker_script
env.get("ENV")["MEMORY_LAYOUT"] = memory_layout
return features_available

View File

@ -18,6 +18,7 @@ def configure(
mcu = "STM32U5G9xx"
linker_script = """embed/sys/linker/stm32u5g/{target}.ld"""
memory_layout = "memory.ld"
stm32u5_common_files(env, features_wanted, defines, sources, paths)
@ -259,5 +260,6 @@ def configure(
features_available.append("power_manager")
env.get("ENV")["LINKER_SCRIPT"] = linker_script
env.get("ENV")["MEMORY_LAYOUT"] = memory_layout
return features_available

View File

@ -18,6 +18,7 @@ def configure(
mcu = "STM32U5G9xx"
linker_script = """embed/sys/linker/stm32u5g/{target}.ld"""
memory_layout = "memory.ld"
stm32u5_common_files(env, features_wanted, defines, sources, paths)
@ -264,5 +265,6 @@ def configure(
features_available.append("power_manager")
env.get("ENV")["LINKER_SCRIPT"] = linker_script
env.get("ENV")["MEMORY_LAYOUT"] = memory_layout
return features_available

View File

@ -18,6 +18,7 @@ def configure(
mcu = "STM32U5G9xx"
linker_script = """embed/sys/linker/stm32u5g/{target}.ld"""
memory_layout = "memory.ld"
stm32u5_common_files(env, features_wanted, defines, sources, paths)
@ -264,5 +265,6 @@ def configure(
features_available.append("power_manager")
env.get("ENV")["LINKER_SCRIPT"] = linker_script
env.get("ENV")["MEMORY_LAYOUT"] = memory_layout
return features_available

View File

@ -104,3 +104,4 @@ def stm32f4_common_files(env, defines, sources, paths):
env.get("ENV")["SUFFIX"] = "stm32f4"
env.get("ENV")["LINKER_SCRIPT"] = """embed/sys/linker/stm32f4/{target}.ld"""
env.get("ENV")["MEMORY_LAYOUT"] = "memory.ld"

View File

@ -7,9 +7,15 @@ CORE = HERE.parent.parent
MODELS_DIR = CORE / "embed" / "models"
def get_layout_for_model(model: str, secmon: bool) -> Path:
if secmon:
return MODELS_DIR / model / f"memory_secmon.h"
else:
return MODELS_DIR / model / f"memory.h"
def get_layout_for_model(model: str) -> Path:
return MODELS_DIR / model / f"model_{model}.h"
def get_linkerscript_for_model(model: str) -> Path:
def get_linkerscript_for_model(model: str, secmon: bool) -> Path:
if secmon:
return MODELS_DIR / model / f"memory_secmon.ld"
else:
return MODELS_DIR / model / f"memory.ld"

View File

@ -16,8 +16,8 @@ from .common import get_layout_for_model
SEARCH_PATTERN = r"#define (\w+) (.+?)(?:\s*//.*)?$"
def find_all_values(model: str) -> dict[str, int]:
layout = get_layout_for_model(model)
def find_all_values(model: str, secmon: bool) -> dict[str, int]:
layout = get_layout_for_model(model, secmon)
values = {}
begin = False
for line in open(layout):
@ -37,8 +37,8 @@ def find_all_values(model: str) -> dict[str, int]:
return values
def find_value(model: str, name: str) -> int:
all_values = find_all_values(model)
def find_value(model: str, name: str, secmon: bool) -> int:
all_values = find_all_values(model, secmon)
if name not in all_values:
raise ValueError(f"Value {name} not found in layout for model {model}")
return all_values[name]
@ -47,9 +47,10 @@ def find_value(model: str, name: str) -> int:
@click.command()
@click.argument("model")
@click.argument("name")
def main(model: str, name: str) -> None:
@click.option("--secmon", is_flag=True)
def main(model: str, name: str, secmon:bool) -> None:
try:
print(find_value(model, name))
print(find_value(model, name, secmon))
except ValueError as e:
raise click.ClickException(str(e))

View File

@ -2,15 +2,24 @@
from __future__ import annotations
import click
import itertools
from .common import get_linkerscript_for_model, MODELS_DIR
from .common import get_linkerscript_for_model, get_layout_for_model, MODELS_DIR
from .layout_parser import find_all_values
warning = """/* Auto-generated file, do not edit.*/
FILE_HEADER = """/* Auto-generated file, do not edit.*/
"""
def create_linker_script(model: str, cmse: bool) -> str:
content = FILE_HEADER
defines = find_all_values(model, cmse)
for name, value in defines.items():
content += f"{name} = {hex(value)};\n"
return content
@click.command()
@click.option("--check", is_flag=True)
def main(check: bool) -> None:
@ -18,20 +27,23 @@ def main(check: bool) -> None:
models = list(MODELS_DIR.iterdir())
models = [model for model in models if model.is_dir()]
for model in models:
values = find_all_values(model.name)
content = warning
input = get_linkerscript_for_model(model.name)
print(f"Processing {input}")
for name, value in values.items():
content += f"{name} = {hex(value)};\n"
if not check:
input.write_text(content)
else:
actual = input.read_text()
if content != actual:
raise click.ClickException(f"{input} differs from expected")
for model, split in itertools.product(models, [False, True]):
path = get_layout_for_model(model.name, split)
if not path.exists():
continue
path = get_linkerscript_for_model(model.name, split)
print(f"Processing {path}")
new_content = create_linker_script(model.name, split)
if check:
current_content = path.read_text()
if new_content != current_content:
raise click.ClickException(f"{path} differs from expected")
else:
path.write_text(new_content)
if __name__ == "__main__":
main()