1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

core: unify usage of TREZOR_MODEL

This commit is contained in:
Pavol Rusnak 2020-06-06 19:26:47 +02:00
parent c877dc8dd6
commit 179645e3ad
18 changed files with 50 additions and 26 deletions

View File

@ -99,10 +99,12 @@ if env.get('TREZOR_MODEL') == 'T':
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
CPU_MODEL = 'STM32F427xx'
else:
elif env.get('TREZOR_MODEL') == '1':
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
CPU_MODEL = 'STM32F405xx'
else:
raise ValueError('Unknown Trezor model')
env.Replace(
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),

View File

@ -125,10 +125,12 @@ if env.get('TREZOR_MODEL') == 'T':
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
CPU_MODEL = 'STM32F427xx'
else:
elif env.get('TREZOR_MODEL') == '1':
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
CPU_MODEL = 'STM32F405xx'
else:
raise ValueError('Unknown Trezor model')
env.Replace(
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),

View File

@ -369,10 +369,12 @@ if env.get('TREZOR_MODEL') == 'T':
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
CPU_MODEL = 'STM32F427xx'
else:
elif env.get('TREZOR_MODEL') == '1':
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
CPU_MODEL = 'STM32F405xx'
else:
raise ValueError('Unknown Trezor model')
env.Replace(
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
@ -457,10 +459,12 @@ env.Ignore(hdr_moduledefs, qstr_generated)
#
if FROZEN:
if env.get('TREZOR_MODEL') == '1':
if env.get('TREZOR_MODEL') == 'T':
SOURCE_PY_DIR = 'src/'
elif env.get('TREZOR_MODEL') == '1':
SOURCE_PY_DIR = 'src1/'
else:
SOURCE_PY_DIR = 'src/'
raise ValueError('Unknown Trezor model')
SOURCE_PY = Glob(SOURCE_PY_DIR + '*.py')
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/*.py'))
@ -629,11 +633,13 @@ if env.get('TREZOR_MODEL') == 'T':
'$HEADERTOOL $TARGET ' + ('-D' if ARGUMENTS.get('PRODUCTION', '0') == '0' else ''),
'$DD if=$TARGET of=${TARGET}.p1 skip=0 bs=128k count=6',
]
else:
elif env.get('TREZOR_MODEL') == '1':
action_bin=[
'$OBJCOPY -O binary -j .header -j .flash -j .data $SOURCE $TARGET',
'../legacy/bootloader/firmware_sign.py -f $TARGET',
]
else:
raise ValueError('Unknown Trezor model')
program_bin = env.Command(
target='firmware.bin',

View File

@ -101,10 +101,12 @@ if env.get('TREZOR_MODEL') == 'T':
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
CPU_MODEL = 'STM32F427xx'
else:
elif env.get('TREZOR_MODEL') == '1':
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
CPU_MODEL = 'STM32F405xx'
else:
raise ValueError('Unknown Trezor model')
env.Replace(
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),

View File

@ -95,10 +95,12 @@ if env.get('TREZOR_MODEL') == 'T':
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
CPU_MODEL = 'STM32F427xx'
else:
elif env.get('TREZOR_MODEL') == '1':
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
CPU_MODEL = 'STM32F405xx'
else:
raise ValueError('Unknown Trezor model')
env.Replace(
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),

View File

@ -425,10 +425,12 @@ env.Ignore(hdr_moduledefs, qstr_generated)
#
if FROZEN:
if env.get('TREZOR_MODEL') == '1':
if env.get('TREZOR_MODEL') == 'T':
SOURCE_PY_DIR = 'src/'
elif env.get('TREZOR_MODEL') == '1':
SOURCE_PY_DIR = 'src1/'
else:
SOURCE_PY_DIR = 'src/'
raise ValueError('Unknown Trezor model')
SOURCE_PY = Glob(SOURCE_PY_DIR + '*.py')
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/*.py'))

View File

@ -26,17 +26,11 @@
#define NORCOW_SECTOR_COUNT 2
#if TREZOR_MODEL == T
#define NORCOW_SECTOR_SIZE (64 * 1024)
#elif TREZOR_MODEL == 1
#define NORCOW_SECTOR_SIZE (16 * 1024)
#else
#error Unknown Trezor Model
#error Unknown Trezor model
#endif
#define NORCOW_SECTORS \

View File

@ -47,7 +47,7 @@
#define TOUCH_OFFSET_Y 92
#else
#error Unknown Trezor Model
#error Unknown Trezor model
#endif
static SDL_Renderer *RENDERER;

View File

@ -54,9 +54,11 @@ static struct { int x, y; } DISPLAY_OFFSET;
#include "display-unix.h"
#else
#if TREZOR_MODEL == T
#include "display-stm32_t.h"
#include "display-stm32_T.h"
#elif TREZOR_MODEL == 1
#include "display-stm32_1.h"
#else
#error Unknown Trezor model
#endif
#endif

View File

@ -39,7 +39,7 @@
#define DISPLAY_RESY 64
#else
#error Unknown Trezor Model
#error Unknown Trezor model
#endif
#define FONT_BPP 4

View File

@ -26,12 +26,12 @@ g_header:
. = . + 8 // reserved
. = . + 512 // hash1 ... hash16
#if TREZOR_MODEL != 1
#if TREZOR_MODEL == T
// model T header specifics
. = . + 415 // reserved
.byte 0 // sigmask
. = . + 64 // sig
#else
#elif TREZOR_MODEL == 1
// model 1 header specifics
. = . + 64 // sig1
. = . + 64 // sig2
@ -41,6 +41,8 @@ g_header:
.byte 0 // sigindex3
. = . + 220 // reserved
. = . + 65 // reserved
#else
#error Unknown Trezor model
#endif
g_header_end:

View File

@ -55,6 +55,8 @@ static const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
[24] = 0x08200000, // last element - not a valid sector
#elif TREZOR_MODEL == 1
[12] = 0x08100000, // last element - not a valid sector
#else
#error Unknown Trezor model
#endif
};

View File

@ -30,6 +30,8 @@
#define FLASH_SECTOR_COUNT 24
#elif TREZOR_MODEL == 1
#define FLASH_SECTOR_COUNT 12
#else
#error Unknown Trezor model
#endif
#define FLASH_SECTOR_BOARDLOADER_START 0
@ -44,6 +46,8 @@
#elif TREZOR_MODEL == 1
#define FLASH_SECTOR_STORAGE_1 2
#define FLASH_SECTOR_STORAGE_2 3
#else
#error Unknown Trezor model
#endif
#define FLASH_SECTOR_BOOTLOADER 5

View File

@ -21,11 +21,11 @@
#include "touch.h"
#if TREZOR_MODEL == T
#include "touch_t.h"
#include "touch_T.h"
#elif TREZOR_MODEL == 1
#include "touch_1.h"
#else
#error Unknown Trezor Model
#error Unknown Trezor model
#endif
uint32_t touch_click(void) {

View File

@ -63,6 +63,8 @@ static const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
[24] = 0x08200000, // last element - not a valid sector
#elif TREZOR_MODEL == 1
[12] = 0x08100000, // last element - not a valid sector
#else
#error Unknown Trezor model
#endif
};

View File

@ -31,10 +31,12 @@
* The length of the sector header in bytes. The header is preserved between
* sector erasures.
*/
#if TREZOR_MODEL == 1
#if TREZOR_MODEL == T
#define NORCOW_HEADER_LEN 0
#elif TREZOR_MODEL == 1
#define NORCOW_HEADER_LEN (0x100)
#else
#define NORCOW_HEADER_LEN 0
#error Unknown Trezor model
#endif
/*