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

core: introduce TREZOR_MODEL flag (#1233)

This commit is contained in:
Martin Milata 2020-08-28 14:50:38 +02:00 committed by GitHub
parent c7b6d98cfc
commit c7934116ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 43 additions and 30 deletions

View File

@ -21,6 +21,7 @@ PRODUCTION ?= 0
PYOPT ?= 1
BITCOIN_ONLY ?= 0
RDI ?= 1
TREZOR_MODEL ?= T
STLINK_VER ?= v2
OPENOCD = openocd -f interface/stlink-$(STLINK_VER).cfg -c "transport select hla_swd" -f target/stm32f4x.cfg
@ -123,33 +124,33 @@ build: build_boardloader build_bootloader build_firmware build_prodtest build_un
build_embed: build_boardloader build_bootloader build_firmware # build boardloader, bootloader, firmware
build_boardloader: ## build boardloader
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" $(BOARDLOADER_BUILD_DIR)/boardloader.bin
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" TREZOR_MODEL="$(TREZOR_MODEL)" $(BOARDLOADER_BUILD_DIR)/boardloader.bin
build_bootloader: ## build bootloader
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" $(BOOTLOADER_BUILD_DIR)/bootloader.bin
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" TREZOR_MODEL="$(TREZOR_MODEL)" $(BOOTLOADER_BUILD_DIR)/bootloader.bin
build_bootloader_ci: ## build CI device testing bootloader
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" $(BOOTLOADER_CI_BUILD_DIR)/bootloader.bin
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" TREZOR_MODEL="$(TREZOR_MODEL)" $(BOOTLOADER_CI_BUILD_DIR)/bootloader.bin
build_prodtest: ## build production test firmware
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" $(PRODTEST_BUILD_DIR)/prodtest.bin
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" TREZOR_MODEL="$(TREZOR_MODEL)" $(PRODTEST_BUILD_DIR)/prodtest.bin
build_reflash: ## build reflash firmware + reflash image
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" $(REFLASH_BUILD_DIR)/reflash.bin
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" TREZOR_MODEL="$(TREZOR_MODEL)" $(REFLASH_BUILD_DIR)/reflash.bin
dd if=build/boardloader/boardloader.bin of=$(REFLASH_BUILD_DIR)/sdimage.bin bs=1 seek=0
dd if=build/bootloader/bootloader.bin of=$(REFLASH_BUILD_DIR)/sdimage.bin bs=1 seek=49152
build_firmware: res build_cross ## build firmware with frozen modules
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" PYOPT="$(PYOPT)" BITCOIN_ONLY="$(BITCOIN_ONLY)" RDI="$(RDI)" $(FIRMWARE_BUILD_DIR)/firmware.bin
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" TREZOR_MODEL="$(TREZOR_MODEL)" PYOPT="$(PYOPT)" BITCOIN_ONLY="$(BITCOIN_ONLY)" RDI="$(RDI)" $(FIRMWARE_BUILD_DIR)/firmware.bin
build_unix: res ## build unix port
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/trezor-emu-core $(UNIX_PORT_OPTS) BITCOIN_ONLY="$(BITCOIN_ONLY)"
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/trezor-emu-core $(UNIX_PORT_OPTS) TREZOR_MODEL="$(TREZOR_MODEL)" BITCOIN_ONLY="$(BITCOIN_ONLY)"
build_unix_frozen: res build_cross ## build unix port with frozen modules
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/trezor-emu-core $(UNIX_PORT_OPTS) PYOPT="$(PYOPT)" BITCOIN_ONLY="$(BITCOIN_ONLY)" TREZOR_EMULATOR_FROZEN=1
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/trezor-emu-core $(UNIX_PORT_OPTS) TREZOR_MODEL="$(TREZOR_MODEL)" PYOPT="$(PYOPT)" BITCOIN_ONLY="$(BITCOIN_ONLY)" TREZOR_EMULATOR_FROZEN=1
build_unix_debug: res ## build unix port
$(SCONS) --max-drift=1 CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/trezor-emu-core $(UNIX_PORT_OPTS) TREZOR_EMULATOR_ASAN=1 TREZOR_EMULATOR_DEBUGGABLE=1
$(SCONS) --max-drift=1 CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/trezor-emu-core $(UNIX_PORT_OPTS) TREZOR_MODEL="$(TREZOR_MODEL)" TREZOR_EMULATOR_ASAN=1 TREZOR_EMULATOR_DEBUGGABLE=1
build_cross: ## build mpy-cross port
$(MAKE) -C vendor/micropython/mpy-cross $(CROSS_PORT_OPTS)

View File

@ -2,6 +2,8 @@
import os
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
@ -93,13 +95,13 @@ env.Replace(
OBJCOPY='arm-none-eabi-objcopy', )
env.Replace(
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
TREZOR_MODEL=TREZOR_MODEL, )
if env.get('TREZOR_MODEL') == 'T':
if 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'
elif env.get('TREZOR_MODEL') == '1':
elif 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'

View File

@ -2,6 +2,8 @@
import os
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
@ -118,13 +120,13 @@ env.Replace(
OBJCOPY='arm-none-eabi-objcopy', )
env.Replace(
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
TREZOR_MODEL=TREZOR_MODEL, )
if env.get('TREZOR_MODEL') == 'T':
if 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'
elif env.get('TREZOR_MODEL') == '1':
elif 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'

View File

@ -2,6 +2,8 @@
import os
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
@ -118,13 +120,13 @@ env.Replace(
OBJCOPY='arm-none-eabi-objcopy', )
env.Replace(
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
TREZOR_MODEL=TREZOR_MODEL, )
if env.get('TREZOR_MODEL') == 'T':
if 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'
elif env.get('TREZOR_MODEL') == '1':
elif 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'

View File

@ -5,6 +5,7 @@ import os
BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0')
RDI = ARGUMENTS.get('RDI', '1') == '1'
EVERYTHING = BITCOIN_ONLY != '1'
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
CCFLAGS_MOD = ''
CPPPATH_MOD = []
@ -365,13 +366,13 @@ env.Replace(
OBJCOPY='arm-none-eabi-objcopy', )
env.Replace(
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
TREZOR_MODEL=TREZOR_MODEL, )
if env.get('TREZOR_MODEL') == 'T':
if 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'
elif env.get('TREZOR_MODEL') == '1':
elif 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'
@ -622,7 +623,7 @@ program_elf = env.Command(
'$LINK -o $TARGET $CCFLAGS $CFLAGS $LINKFLAGS $SOURCES -lc_nano -lm -lgcc',
)
if env.get('TREZOR_MODEL') == 'T':
if TREZOR_MODEL == 'T':
action_bin=[
'$OBJCOPY -O binary -j .vendorheader -j .header -j .flash -j .data --pad-to 0x08100000 $SOURCE ${TARGET}.p1',
'$OBJCOPY -O binary -j .flash2 $SOURCE ${TARGET}.p2',
@ -630,7 +631,7 @@ 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',
]
elif env.get('TREZOR_MODEL') == '1':
elif TREZOR_MODEL == '1':
action_bin=[
'$OBJCOPY -O binary -j .header -j .flash -j .data $SOURCE $TARGET',
'../legacy/bootloader/firmware_sign.py -f $TARGET',

View File

@ -2,6 +2,8 @@
import os
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
@ -95,13 +97,13 @@ env.Replace(
OBJCOPY='arm-none-eabi-objcopy', )
env.Replace(
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
TREZOR_MODEL=TREZOR_MODEL, )
if env.get('TREZOR_MODEL') == 'T':
if 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'
elif env.get('TREZOR_MODEL') == '1':
elif 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'

View File

@ -2,6 +2,8 @@
import os
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
@ -89,13 +91,13 @@ env.Replace(
OBJCOPY='arm-none-eabi-objcopy', )
env.Replace(
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
TREZOR_MODEL=TREZOR_MODEL, )
if env.get('TREZOR_MODEL') == 'T':
if 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'
elif env.get('TREZOR_MODEL') == '1':
elif 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'

View File

@ -4,6 +4,7 @@ import os
BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0')
EVERYTHING = BITCOIN_ONLY != '1'
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
CCFLAGS_MOD = ''
CPPPATH_MOD = []
@ -346,7 +347,7 @@ if ARGUMENTS.get('TREZOR_EMULATOR_DEBUGGABLE', 0):
STRIP='true', )
env.Replace(
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
TREZOR_MODEL=TREZOR_MODEL, )
env.Replace(
CCFLAGS='$COPT '