mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 00:28:10 +00:00
refactor(core): restructure trezorhal, prepare to support more platforms
[no changelog]
This commit is contained in:
parent
34a563018d
commit
ebbd7f9d35
@ -24,6 +24,9 @@ CCFLAGS_MOD = ''
|
|||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
SOURCE_MOD = []
|
SOURCE_MOD = []
|
||||||
|
CPPDEFINES_HAL = []
|
||||||
|
SOURCE_HAL = []
|
||||||
|
PATH_HAL = []
|
||||||
|
|
||||||
# modtrezorcrypto
|
# modtrezorcrypto
|
||||||
CCFLAGS_MOD += '-Wno-sequence-point '
|
CCFLAGS_MOD += '-Wno-sequence-point '
|
||||||
@ -57,31 +60,7 @@ SOURCE_MOD += [
|
|||||||
'embed/lib/colors.c',
|
'embed/lib/colors.c',
|
||||||
'embed/lib/fonts/fonts.c',
|
'embed/lib/fonts/fonts.c',
|
||||||
'embed/lib/fonts/font_bitmap.c',
|
'embed/lib/fonts/font_bitmap.c',
|
||||||
]
|
'embed/lib/mini_printf.c',
|
||||||
|
|
||||||
SOURCE_STMHAL = [
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_ltdc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sdram.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_BOARDLOADER = [
|
SOURCE_BOARDLOADER = [
|
||||||
@ -89,24 +68,9 @@ SOURCE_BOARDLOADER = [
|
|||||||
'embed/boardloader/main.c',
|
'embed/boardloader/main.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_TREZORHAL = [
|
|
||||||
'embed/trezorhal/board_capabilities.c',
|
|
||||||
'embed/trezorhal/common.c',
|
|
||||||
'embed/trezorhal/dma.c',
|
|
||||||
'embed/trezorhal/image.c',
|
|
||||||
'embed/trezorhal/flash.c',
|
|
||||||
'embed/trezorhal/lowlevel.c',
|
|
||||||
'embed/trezorhal/mini_printf.c',
|
|
||||||
'embed/trezorhal/stm32.c',
|
|
||||||
'embed/trezorhal/systick.c',
|
|
||||||
'embed/trezorhal/rng.c',
|
|
||||||
'embed/trezorhal/util.s',
|
|
||||||
'embed/trezorhal/vectortable.s',
|
|
||||||
]
|
|
||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||||
|
|
||||||
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
CP='cp',
|
CP='cp',
|
||||||
@ -123,17 +87,6 @@ env.Replace(
|
|||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=TREZOR_MODEL, )
|
TREZOR_MODEL=TREZOR_MODEL, )
|
||||||
|
|
||||||
if TREZOR_MODEL in ('T', 'R'):
|
|
||||||
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 TREZOR_MODEL in ('DISC1',):
|
|
||||||
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 = 'STM32F429xx'
|
|
||||||
else:
|
|
||||||
raise ValueError('Unknown Trezor model')
|
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
@ -143,7 +96,7 @@ env.Replace(
|
|||||||
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
||||||
'-ffreestanding '
|
'-ffreestanding '
|
||||||
'-fstack-protector-all '
|
'-fstack-protector-all '
|
||||||
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
+ env.get('ENV')["CPU_CCFLAGS"] + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LINKFLAGS='-T embed/boardloader/memory.ld -Wl,--gc-sections -Wl,-Map=build/boardloader/boardloader.map -Wl,--warn-common -Wl,--print-memory-usage',
|
LINKFLAGS='-T embed/boardloader/memory.ld -Wl,--gc-sections -Wl,-Map=build/boardloader/boardloader.map -Wl,--warn-common -Wl,--print-memory-usage',
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
@ -152,23 +105,19 @@ env.Replace(
|
|||||||
'embed/models',
|
'embed/models',
|
||||||
'embed/trezorhal',
|
'embed/trezorhal',
|
||||||
'embed/extmod/modtrezorui',
|
'embed/extmod/modtrezorui',
|
||||||
'vendor/micropython/stmhal',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc',
|
|
||||||
'vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include',
|
|
||||||
'vendor/micropython/lib/cmsis/inc',
|
'vendor/micropython/lib/cmsis/inc',
|
||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD + PATH_HAL,
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
'BOARDLOADER',
|
'BOARDLOADER',
|
||||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||||
CPU_MODEL,
|
|
||||||
'USE_HAL_DRIVER',
|
'USE_HAL_DRIVER',
|
||||||
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
] + CPPDEFINES_MOD + CPPDEFINES_HAL,
|
||||||
] + CPPDEFINES_MOD,
|
ASFLAGS=env.get('ENV')['CPU_ASFLAGS'],
|
||||||
ASFLAGS=CPU_ASFLAGS,
|
ASPPFLAGS='$CFLAGS $CCFLAGS',
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
ALLSOURCES=SOURCE_MOD + SOURCE_BOARDLOADER + SOURCE_STMHAL + SOURCE_TREZORHAL,
|
ALLSOURCES=SOURCE_MOD + SOURCE_BOARDLOADER + SOURCE_HAL,
|
||||||
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES']))
|
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES']))
|
||||||
|
|
||||||
cmake_gen = env.Command(
|
cmake_gen = env.Command(
|
||||||
@ -184,8 +133,7 @@ cmake_gen = env.Command(
|
|||||||
obj_program = []
|
obj_program = []
|
||||||
obj_program += env.Object(source=SOURCE_MOD)
|
obj_program += env.Object(source=SOURCE_MOD)
|
||||||
obj_program += env.Object(source=SOURCE_BOARDLOADER)
|
obj_program += env.Object(source=SOURCE_BOARDLOADER)
|
||||||
obj_program += env.Object(source=SOURCE_STMHAL)
|
obj_program += env.Object(source=SOURCE_HAL)
|
||||||
obj_program += env.Object(source=SOURCE_TREZORHAL)
|
|
||||||
|
|
||||||
program_elf = env.Command(
|
program_elf = env.Command(
|
||||||
target='boardloader.elf',
|
target='boardloader.elf',
|
||||||
|
@ -20,12 +20,15 @@ if TREZOR_MODEL in ('1', ):
|
|||||||
)
|
)
|
||||||
Return()
|
Return()
|
||||||
|
|
||||||
FEATURES_WANTED = ["input", "rgb_led", "consumption_mask"]
|
FEATURES_WANTED = ["input", "rgb_led", "consumption_mask", "usb"]
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
SOURCE_MOD = []
|
SOURCE_MOD = []
|
||||||
|
CPPDEFINES_HAL = []
|
||||||
|
SOURCE_HAL = []
|
||||||
|
PATH_HAL = []
|
||||||
|
|
||||||
if TREZOR_MODEL in ('R', ):
|
if TREZOR_MODEL in ('R', ):
|
||||||
FONT_NORMAL='Font_PixelOperator_Regular_8'
|
FONT_NORMAL='Font_PixelOperator_Regular_8'
|
||||||
@ -75,6 +78,7 @@ CPPPATH_MOD += [
|
|||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_MOD += [
|
SOURCE_MOD += [
|
||||||
|
'embed/lib/mini_printf.c',
|
||||||
'embed/lib/unit_variant.c',
|
'embed/lib/unit_variant.c',
|
||||||
'embed/lib/buffers.c',
|
'embed/lib/buffers.c',
|
||||||
'embed/lib/colors.c',
|
'embed/lib/colors.c',
|
||||||
@ -87,31 +91,6 @@ SOURCE_MOD += [
|
|||||||
'vendor/micropython/lib/uzlib/tinflate.c',
|
'vendor/micropython/lib/uzlib/tinflate.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_STMHAL = [
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_ltdc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sdram.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c',
|
|
||||||
]
|
|
||||||
|
|
||||||
SOURCE_NANOPB = [
|
SOURCE_NANOPB = [
|
||||||
'vendor/nanopb/pb_common.c',
|
'vendor/nanopb/pb_common.c',
|
||||||
'vendor/nanopb/pb_decode.c',
|
'vendor/nanopb/pb_decode.c',
|
||||||
@ -127,25 +106,6 @@ SOURCE_BOOTLOADER = [
|
|||||||
'embed/bootloader/protob/messages.pb.c',
|
'embed/bootloader/protob/messages.pb.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_TREZORHAL = [
|
|
||||||
'embed/trezorhal/common.c',
|
|
||||||
'embed/trezorhal/image.c',
|
|
||||||
'embed/trezorhal/flash.c',
|
|
||||||
'embed/trezorhal/mini_printf.c',
|
|
||||||
'embed/trezorhal/mpu.c',
|
|
||||||
'embed/trezorhal/random_delays.c',
|
|
||||||
'embed/trezorhal/rng.c',
|
|
||||||
'embed/trezorhal/stm32.c',
|
|
||||||
'embed/trezorhal/systick.c',
|
|
||||||
'embed/trezorhal/usb.c',
|
|
||||||
'embed/trezorhal/usbd_conf.c',
|
|
||||||
'embed/trezorhal/usbd_core.c',
|
|
||||||
'embed/trezorhal/usbd_ctlreq.c',
|
|
||||||
'embed/trezorhal/usbd_ioreq.c',
|
|
||||||
'embed/trezorhal/util.s',
|
|
||||||
'embed/trezorhal/vectortable.s',
|
|
||||||
]
|
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD)
|
tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD)
|
||||||
tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD)
|
tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD)
|
||||||
@ -155,7 +115,7 @@ tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD)
|
|||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS=f"{ARGUMENTS.get('CFLAGS', '')} -DPRODUCTION={int(PRODUCTION)} -DBOOTLOADER_QA={int(BOOTLOADER_QA)}")
|
env = Environment(ENV=os.environ, CFLAGS=f"{ARGUMENTS.get('CFLAGS', '')} -DPRODUCTION={int(PRODUCTION)} -DBOOTLOADER_QA={int(BOOTLOADER_QA)}")
|
||||||
|
|
||||||
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
CP='cp',
|
CP='cp',
|
||||||
@ -172,19 +132,6 @@ env.Replace(
|
|||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=TREZOR_MODEL, )
|
TREZOR_MODEL=TREZOR_MODEL, )
|
||||||
|
|
||||||
if TREZOR_MODEL in ('T', 'R'):
|
|
||||||
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'
|
|
||||||
RUST_TARGET = 'thumbv7em-none-eabihf'
|
|
||||||
elif TREZOR_MODEL in ('DISC1', ):
|
|
||||||
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 = 'STM32F429xx'
|
|
||||||
RUST_TARGET = 'thumbv7em-none-eabihf'
|
|
||||||
else:
|
|
||||||
raise ValueError('Unknown Trezor model')
|
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
@ -194,7 +141,7 @@ env.Replace(
|
|||||||
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
||||||
'-ffreestanding '
|
'-ffreestanding '
|
||||||
'-fstack-protector-all '
|
'-fstack-protector-all '
|
||||||
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
+ env.get('ENV')["CPU_CCFLAGS"] + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LINKFLAGS='-T embed/bootloader/memory.ld -Wl,--gc-sections -Wl,-Map=build/bootloader/bootloader.map -Wl,--warn-common -Wl,--print-memory-usage',
|
LINKFLAGS='-T embed/bootloader/memory.ld -Wl,--gc-sections -Wl,-Map=build/bootloader/bootloader.map -Wl,--warn-common -Wl,--print-memory-usage',
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
@ -206,30 +153,27 @@ env.Replace(
|
|||||||
'embed/models',
|
'embed/models',
|
||||||
'embed/trezorhal',
|
'embed/trezorhal',
|
||||||
'embed/extmod/modtrezorui',
|
'embed/extmod/modtrezorui',
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc',
|
|
||||||
'vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include',
|
|
||||||
'vendor/micropython/lib/cmsis/inc',
|
'vendor/micropython/lib/cmsis/inc',
|
||||||
'vendor/nanopb',
|
'vendor/nanopb',
|
||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD + PATH_HAL,
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
'BOOTLOADER',
|
'BOOTLOADER',
|
||||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||||
CPU_MODEL,
|
|
||||||
'USE_HAL_DRIVER',
|
'USE_HAL_DRIVER',
|
||||||
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
|
||||||
'PB_FIELD_16BIT',
|
'PB_FIELD_16BIT',
|
||||||
'PB_ENCODE_ARRAYS_UNPACKED',
|
'PB_ENCODE_ARRAYS_UNPACKED',
|
||||||
'PB_VALIDATE_UTF8',
|
'PB_VALIDATE_UTF8',
|
||||||
] + CPPDEFINES_MOD,
|
] + CPPDEFINES_MOD + CPPDEFINES_HAL,
|
||||||
ASFLAGS=CPU_ASFLAGS,
|
ASFLAGS=env.get('ENV')['CPU_ASFLAGS'],
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
ASPPFLAGS='$CFLAGS $CCFLAGS',
|
||||||
|
)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
HEADERTOOL='tools/headertool.py',
|
HEADERTOOL='tools/headertool.py',
|
||||||
)
|
)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
ALLSOURCES=SOURCE_MOD + SOURCE_BOOTLOADER + SOURCE_NANOPB + SOURCE_STMHAL + SOURCE_TREZORHAL,
|
ALLSOURCES=SOURCE_MOD + SOURCE_BOOTLOADER + SOURCE_NANOPB + SOURCE_HAL,
|
||||||
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES'] + [f"PRODUCTION={int(PRODUCTION)}", f"BOOTLOADER_QA={int(BOOTLOADER_QA)}"]))
|
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES'] + [f"PRODUCTION={int(PRODUCTION)}", f"BOOTLOADER_QA={int(BOOTLOADER_QA)}"]))
|
||||||
|
|
||||||
cmake_gen = env.Command(
|
cmake_gen = env.Command(
|
||||||
@ -245,7 +189,7 @@ cmake_gen = env.Command(
|
|||||||
|
|
||||||
RUST_PROFILE = 'release'
|
RUST_PROFILE = 'release'
|
||||||
RUST_LIB = 'trezor_lib'
|
RUST_LIB = 'trezor_lib'
|
||||||
RUST_LIBDIR = f'build/bootloader/rust/{RUST_TARGET}/{RUST_PROFILE}'
|
RUST_LIBDIR = f'build/bootloader/rust/{env.get("ENV")["RUST_TARGET"]}/{RUST_PROFILE}'
|
||||||
RUST_LIBPATH = f'{RUST_LIBDIR}/lib{RUST_LIB}.a'
|
RUST_LIBPATH = f'{RUST_LIBDIR}/lib{RUST_LIB}.a'
|
||||||
|
|
||||||
def cargo_build():
|
def cargo_build():
|
||||||
@ -266,7 +210,7 @@ def cargo_build():
|
|||||||
features.extend(FEATURES_AVAILABLE)
|
features.extend(FEATURES_AVAILABLE)
|
||||||
|
|
||||||
cargo_opts = [
|
cargo_opts = [
|
||||||
f'--target={RUST_TARGET}',
|
f'--target={env.get("ENV")["RUST_TARGET"]}',
|
||||||
f'--target-dir=../../build/bootloader/rust',
|
f'--target-dir=../../build/bootloader/rust',
|
||||||
'--no-default-features',
|
'--no-default-features',
|
||||||
'--features ' + ','.join(features),
|
'--features ' + ','.join(features),
|
||||||
@ -292,8 +236,7 @@ obj_program = []
|
|||||||
obj_program += env.Object(source=SOURCE_MOD)
|
obj_program += env.Object(source=SOURCE_MOD)
|
||||||
obj_program += env.Object(source=SOURCE_BOOTLOADER)
|
obj_program += env.Object(source=SOURCE_BOOTLOADER)
|
||||||
obj_program += env.Object(source=SOURCE_NANOPB)
|
obj_program += env.Object(source=SOURCE_NANOPB)
|
||||||
obj_program += env.Object(source=SOURCE_STMHAL)
|
obj_program += env.Object(source=SOURCE_HAL)
|
||||||
obj_program += env.Object(source=SOURCE_TREZORHAL)
|
|
||||||
|
|
||||||
|
|
||||||
program_elf = env.Command(
|
program_elf = env.Command(
|
||||||
|
@ -18,12 +18,15 @@ if TREZOR_MODEL in ('1', 'DISC1'):
|
|||||||
)
|
)
|
||||||
Return()
|
Return()
|
||||||
|
|
||||||
FEATURES_WANTED = ["input"]
|
FEATURES_WANTED = ["input", "usb"]
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
SOURCE_MOD = []
|
SOURCE_MOD = []
|
||||||
|
CPPDEFINES_HAL = []
|
||||||
|
SOURCE_HAL = []
|
||||||
|
PATH_HAL = []
|
||||||
|
|
||||||
if TREZOR_MODEL in ('1', 'R'):
|
if TREZOR_MODEL in ('1', 'R'):
|
||||||
FONT_NORMAL='Font_PixelOperator_Regular_8'
|
FONT_NORMAL='Font_PixelOperator_Regular_8'
|
||||||
@ -73,34 +76,13 @@ SOURCE_MOD += [
|
|||||||
'embed/lib/colors.c',
|
'embed/lib/colors.c',
|
||||||
'embed/lib/fonts/fonts.c',
|
'embed/lib/fonts/fonts.c',
|
||||||
'embed/lib/fonts/font_bitmap.c',
|
'embed/lib/fonts/font_bitmap.c',
|
||||||
|
'embed/lib/mini_printf.c',
|
||||||
'embed/extmod/modtrezorcrypto/rand.c',
|
'embed/extmod/modtrezorcrypto/rand.c',
|
||||||
'vendor/micropython/lib/uzlib/adler32.c',
|
'vendor/micropython/lib/uzlib/adler32.c',
|
||||||
'vendor/micropython/lib/uzlib/crc32.c',
|
'vendor/micropython/lib/uzlib/crc32.c',
|
||||||
'vendor/micropython/lib/uzlib/tinflate.c',
|
'vendor/micropython/lib/uzlib/tinflate.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_STMHAL = [
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c',
|
|
||||||
]
|
|
||||||
|
|
||||||
SOURCE_NANOPB = [
|
SOURCE_NANOPB = [
|
||||||
'vendor/nanopb/pb_common.c',
|
'vendor/nanopb/pb_common.c',
|
||||||
'vendor/nanopb/pb_decode.c',
|
'vendor/nanopb/pb_decode.c',
|
||||||
@ -116,24 +98,6 @@ SOURCE_BOOTLOADER = [
|
|||||||
'embed/bootloader_ci/protob/messages.pb.c',
|
'embed/bootloader_ci/protob/messages.pb.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_TREZORHAL = [
|
|
||||||
'embed/trezorhal/common.c',
|
|
||||||
'embed/trezorhal/image.c',
|
|
||||||
'embed/trezorhal/flash.c',
|
|
||||||
'embed/trezorhal/mini_printf.c',
|
|
||||||
'embed/trezorhal/mpu.c',
|
|
||||||
'embed/trezorhal/random_delays.c',
|
|
||||||
'embed/trezorhal/rng.c',
|
|
||||||
'embed/trezorhal/stm32.c',
|
|
||||||
'embed/trezorhal/systick.c',
|
|
||||||
'embed/trezorhal/usb.c',
|
|
||||||
'embed/trezorhal/usbd_conf.c',
|
|
||||||
'embed/trezorhal/usbd_core.c',
|
|
||||||
'embed/trezorhal/usbd_ctlreq.c',
|
|
||||||
'embed/trezorhal/usbd_ioreq.c',
|
|
||||||
'embed/trezorhal/util.s',
|
|
||||||
'embed/trezorhal/vectortable.s',
|
|
||||||
]
|
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD)
|
tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD)
|
||||||
@ -144,7 +108,7 @@ tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD)
|
|||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||||
|
|
||||||
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
CP='cp',
|
CP='cp',
|
||||||
@ -161,13 +125,6 @@ env.Replace(
|
|||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=TREZOR_MODEL, )
|
TREZOR_MODEL=TREZOR_MODEL, )
|
||||||
|
|
||||||
if TREZOR_MODEL in ('T', 'R'):
|
|
||||||
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:
|
|
||||||
raise ValueError('Unknown Trezor model')
|
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
@ -177,7 +134,7 @@ env.Replace(
|
|||||||
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
||||||
'-ffreestanding '
|
'-ffreestanding '
|
||||||
'-fstack-protector-all '
|
'-fstack-protector-all '
|
||||||
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
+ env.get('ENV')["CPU_CCFLAGS"] + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LINKFLAGS='-T embed/bootloader_ci/memory.ld -Wl,--gc-sections -Wl,-Map=build/bootloader_ci/bootloader.map -Wl,--warn-common',
|
LINKFLAGS='-T embed/bootloader_ci/memory.ld -Wl,--gc-sections -Wl,-Map=build/bootloader_ci/bootloader.map -Wl,--warn-common',
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
@ -188,30 +145,26 @@ env.Replace(
|
|||||||
'embed/models',
|
'embed/models',
|
||||||
'embed/trezorhal',
|
'embed/trezorhal',
|
||||||
'embed/extmod/modtrezorui',
|
'embed/extmod/modtrezorui',
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc',
|
|
||||||
'vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include',
|
|
||||||
'vendor/micropython/lib/cmsis/inc',
|
'vendor/micropython/lib/cmsis/inc',
|
||||||
'vendor/nanopb',
|
'vendor/nanopb',
|
||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD + PATH_HAL,
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||||
CPU_MODEL,
|
|
||||||
'USE_HAL_DRIVER',
|
'USE_HAL_DRIVER',
|
||||||
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
|
||||||
'PB_FIELD_16BIT',
|
'PB_FIELD_16BIT',
|
||||||
'PB_ENCODE_ARRAYS_UNPACKED',
|
'PB_ENCODE_ARRAYS_UNPACKED',
|
||||||
'PB_VALIDATE_UTF8',
|
'PB_VALIDATE_UTF8',
|
||||||
] + CPPDEFINES_MOD,
|
] + CPPDEFINES_MOD + CPPDEFINES_HAL,
|
||||||
ASFLAGS=CPU_ASFLAGS,
|
ASFLAGS=env.get('ENV')['CPU_ASFLAGS'],
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS',
|
ASPPFLAGS='$CFLAGS $CCFLAGS',
|
||||||
ALLSOURCES=SOURCE_MOD + SOURCE_BOOTLOADER + SOURCE_STMHAL + SOURCE_TREZORHAL+ SOURCE_NANOPB, )
|
ALLSOURCES=SOURCE_MOD + SOURCE_BOOTLOADER + SOURCE_HAL+ SOURCE_NANOPB, )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
HEADERTOOL='tools/headertool.py',
|
HEADERTOOL='tools/headertool.py',
|
||||||
)
|
)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
ALLSOURCES=SOURCE_MOD + SOURCE_BOOTLOADER + SOURCE_NANOPB + SOURCE_STMHAL + SOURCE_TREZORHAL,
|
ALLSOURCES=SOURCE_MOD + SOURCE_BOOTLOADER + SOURCE_NANOPB + SOURCE_HAL,
|
||||||
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES']))
|
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES']))
|
||||||
|
|
||||||
cmake_gen = env.Command(
|
cmake_gen = env.Command(
|
||||||
@ -229,8 +182,7 @@ obj_program = []
|
|||||||
obj_program += env.Object(source=SOURCE_MOD)
|
obj_program += env.Object(source=SOURCE_MOD)
|
||||||
obj_program += env.Object(source=SOURCE_BOOTLOADER)
|
obj_program += env.Object(source=SOURCE_BOOTLOADER)
|
||||||
obj_program += env.Object(source=SOURCE_NANOPB)
|
obj_program += env.Object(source=SOURCE_NANOPB)
|
||||||
obj_program += env.Object(source=SOURCE_STMHAL)
|
obj_program += env.Object(source=SOURCE_HAL)
|
||||||
obj_program += env.Object(source=SOURCE_TREZORHAL)
|
|
||||||
|
|
||||||
program_elf = env.Command(
|
program_elf = env.Command(
|
||||||
target='bootloader.elf',
|
target='bootloader.elf',
|
||||||
|
@ -82,6 +82,7 @@ SOURCE_MOD += [
|
|||||||
'embed/lib/display.c',
|
'embed/lib/display.c',
|
||||||
'embed/lib/fonts/fonts.c',
|
'embed/lib/fonts/fonts.c',
|
||||||
'embed/lib/fonts/font_bitmap.c',
|
'embed/lib/fonts/font_bitmap.c',
|
||||||
|
'embed/lib/touch.c',
|
||||||
'embed/extmod/modtrezorcrypto/rand.c',
|
'embed/extmod/modtrezorcrypto/rand.c',
|
||||||
'vendor/micropython/lib/uzlib/adler32.c',
|
'vendor/micropython/lib/uzlib/adler32.c',
|
||||||
'vendor/micropython/lib/uzlib/crc32.c',
|
'vendor/micropython/lib/uzlib/crc32.c',
|
||||||
@ -103,18 +104,18 @@ SOURCE_BOOTLOADER = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_TREZORHAL = [
|
SOURCE_TREZORHAL = [
|
||||||
'embed/trezorhal/image.c',
|
'embed/trezorhal/unix/image.c',
|
||||||
|
'embed/trezorhal/unix/display-unix.c',
|
||||||
|
'embed/trezorhal/unix/flash.c',
|
||||||
|
'embed/trezorhal/unix/common.c',
|
||||||
|
'embed/trezorhal/unix/touch/touch.c',
|
||||||
|
'embed/trezorhal/unix/rng.c',
|
||||||
|
'embed/trezorhal/unix/usb.c',
|
||||||
|
'embed/trezorhal/unix/random_delays.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_UNIX = [
|
SOURCE_UNIX = [
|
||||||
'embed/unix/common.c',
|
|
||||||
'embed/unix/display-unix.c',
|
|
||||||
'embed/unix/flash.c',
|
|
||||||
'embed/unix/profile.c',
|
'embed/unix/profile.c',
|
||||||
'embed/unix/random_delays.c',
|
|
||||||
'embed/unix/rng.c',
|
|
||||||
'embed/unix/touch/touch.c',
|
|
||||||
'embed/unix/usb.c',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
@ -170,6 +171,8 @@ env.Replace(
|
|||||||
'embed/bootloader/protob',
|
'embed/bootloader/protob',
|
||||||
'embed/lib',
|
'embed/lib',
|
||||||
'embed/models',
|
'embed/models',
|
||||||
|
'embed/trezorhal',
|
||||||
|
'embed/trezorhal/unix',
|
||||||
'embed/unix',
|
'embed/unix',
|
||||||
'embed/extmod/modtrezorui',
|
'embed/extmod/modtrezorui',
|
||||||
'vendor/nanopb',
|
'vendor/nanopb',
|
||||||
@ -181,7 +184,7 @@ env.Replace(
|
|||||||
'HW_MODEL=' + MODEL_AS_NUMBER,
|
'HW_MODEL=' + MODEL_AS_NUMBER,
|
||||||
'HW_REVISION=' + ('6' if TREZOR_MODEL in ('R',) else '0'),
|
'HW_REVISION=' + ('6' if TREZOR_MODEL in ('R',) else '0'),
|
||||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||||
'TREZOR_BOARD=\\"board-unix.h\\"',
|
'TREZOR_BOARD=\\"boards/board-unix.h\\"',
|
||||||
'PB_FIELD_16BIT',
|
'PB_FIELD_16BIT',
|
||||||
'PB_ENCODE_ARRAYS_UNPACKED',
|
'PB_ENCODE_ARRAYS_UNPACKED',
|
||||||
'PB_VALIDATE_UTF8',
|
'PB_VALIDATE_UTF8',
|
||||||
|
@ -18,12 +18,15 @@ FEATURE_FLAGS = {
|
|||||||
"SYSTEM_VIEW": False,
|
"SYSTEM_VIEW": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
FEATURES_WANTED = ["input", "sbu", "sd_card", "rgb_led", "dma2d", "consumption_mask"]
|
FEATURES_WANTED = ["input", "sbu", "sd_card", "rgb_led", "dma2d", "consumption_mask", "usb"]
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
SOURCE_MOD = []
|
SOURCE_MOD = []
|
||||||
|
CPPDEFINES_HAL = []
|
||||||
|
SOURCE_HAL = []
|
||||||
|
PATH_HAL = []
|
||||||
|
|
||||||
PYOPT = ARGUMENTS.get('PYOPT', '1')
|
PYOPT = ARGUMENTS.get('PYOPT', '1')
|
||||||
FROZEN = True
|
FROZEN = True
|
||||||
@ -174,6 +177,7 @@ CPPPATH_MOD += [
|
|||||||
'vendor/micropython/lib/uzlib',
|
'vendor/micropython/lib/uzlib',
|
||||||
]
|
]
|
||||||
SOURCE_MOD += [
|
SOURCE_MOD += [
|
||||||
|
'embed/lib/mini_printf.c',
|
||||||
'embed/lib/unit_variant.c',
|
'embed/lib/unit_variant.c',
|
||||||
'embed/lib/buffers.c',
|
'embed/lib/buffers.c',
|
||||||
'embed/lib/colors.c',
|
'embed/lib/colors.c',
|
||||||
@ -328,31 +332,6 @@ SOURCE_MICROPYTHON_SPEED = [
|
|||||||
'vendor/micropython/py/vm.c',
|
'vendor/micropython/py/vm.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_STMHAL = [
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_ltdc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sdram.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c',
|
|
||||||
]
|
|
||||||
|
|
||||||
SOURCE_FIRMWARE = [
|
SOURCE_FIRMWARE = [
|
||||||
'embed/firmware/bl_check.c',
|
'embed/firmware/bl_check.c',
|
||||||
'embed/firmware/delay.c',
|
'embed/firmware/delay.c',
|
||||||
@ -363,28 +342,6 @@ SOURCE_FIRMWARE = [
|
|||||||
'embed/firmware/startup.S',
|
'embed/firmware/startup.S',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_TREZORHAL = [
|
|
||||||
'embed/trezorhal/board_capabilities.c',
|
|
||||||
'embed/trezorhal/common.c',
|
|
||||||
'embed/trezorhal/dma.c',
|
|
||||||
'embed/trezorhal/image.c',
|
|
||||||
'embed/trezorhal/flash.c',
|
|
||||||
'embed/trezorhal/mini_printf.c',
|
|
||||||
'embed/trezorhal/mpu.c',
|
|
||||||
'embed/trezorhal/random_delays.c',
|
|
||||||
'embed/trezorhal/rng.c',
|
|
||||||
'embed/trezorhal/stm32.c',
|
|
||||||
'embed/trezorhal/systick.c',
|
|
||||||
'embed/trezorhal/usb.c',
|
|
||||||
'embed/trezorhal/usbd_conf.c',
|
|
||||||
'embed/trezorhal/usbd_core.c',
|
|
||||||
'embed/trezorhal/usbd_ctlreq.c',
|
|
||||||
'embed/trezorhal/usbd_ioreq.c',
|
|
||||||
'embed/trezorhal/util.s',
|
|
||||||
'embed/trezorhal/vectortable.s',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
CPPDEFINES_MOD += ['USE_SVC_SHUTDOWN']
|
CPPDEFINES_MOD += ['USE_SVC_SHUTDOWN']
|
||||||
|
|
||||||
if FEATURE_FLAGS["RDI"]:
|
if FEATURE_FLAGS["RDI"]:
|
||||||
@ -417,7 +374,7 @@ SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED
|
|||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS=f"{ARGUMENTS.get('CFLAGS', '')} -DPRODUCTION={int(PRODUCTION)} -DPYOPT={PYOPT} -DBOOTLOADER_QA={int(BOOTLOADER_QA)} -DBITCOIN_ONLY={BITCOIN_ONLY}")
|
env = Environment(ENV=os.environ, CFLAGS=f"{ARGUMENTS.get('CFLAGS', '')} -DPRODUCTION={int(PRODUCTION)} -DPYOPT={PYOPT} -DBOOTLOADER_QA={int(BOOTLOADER_QA)} -DBITCOIN_ONLY={BITCOIN_ONLY}")
|
||||||
|
|
||||||
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL)
|
||||||
|
|
||||||
env.Tool('micropython')
|
env.Tool('micropython')
|
||||||
|
|
||||||
@ -437,26 +394,10 @@ env.Replace(
|
|||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=TREZOR_MODEL,)
|
TREZOR_MODEL=TREZOR_MODEL,)
|
||||||
|
|
||||||
if TREZOR_MODEL in ('T', 'R'):
|
if TREZOR_MODEL in ('1',):
|
||||||
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'
|
|
||||||
LD_VARIANT = ''
|
|
||||||
RUST_TARGET = 'thumbv7em-none-eabihf'
|
|
||||||
elif TREZOR_MODEL in ('DISC1', ):
|
|
||||||
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 = 'STM32F429xx'
|
|
||||||
LD_VARIANT = ''
|
|
||||||
RUST_TARGET = 'thumbv7em-none-eabihf'
|
|
||||||
elif TREZOR_MODEL in ('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'
|
|
||||||
LD_VARIANT = '' if EVERYTHING else '_min'
|
LD_VARIANT = '' if EVERYTHING else '_min'
|
||||||
RUST_TARGET = 'thumbv7m-none-eabi'
|
|
||||||
else:
|
else:
|
||||||
raise ValueError('Unknown Trezor model')
|
LD_VARIANT = ''
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
@ -467,7 +408,7 @@ env.Replace(
|
|||||||
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
||||||
'-ffreestanding '
|
'-ffreestanding '
|
||||||
'-fstack-protector-all '
|
'-fstack-protector-all '
|
||||||
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
+ env.get('ENV')["CPU_CCFLAGS"] + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LINKFLAGS='-T embed/firmware/memory_${TREZOR_MODEL}%s.ld -Wl,--gc-sections -Wl,--print-memory-usage -Wl,-Map=build/firmware/firmware.map -Wl,--warn-common' % LD_VARIANT,
|
LINKFLAGS='-T embed/firmware/memory_${TREZOR_MODEL}%s.ld -Wl,--gc-sections -Wl,--print-memory-usage -Wl,-Map=build/firmware/firmware.map -Wl,--warn-common' % LD_VARIANT,
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
@ -479,19 +420,16 @@ env.Replace(
|
|||||||
'embed/trezorhal',
|
'embed/trezorhal',
|
||||||
'embed/extmod/modtrezorui',
|
'embed/extmod/modtrezorui',
|
||||||
'vendor/micropython',
|
'vendor/micropython',
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc',
|
|
||||||
'vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include',
|
|
||||||
'vendor/micropython/lib/cmsis/inc',
|
'vendor/micropython/lib/cmsis/inc',
|
||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD + PATH_HAL,
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
'FIRMWARE',
|
'FIRMWARE',
|
||||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||||
CPU_MODEL,
|
|
||||||
'USE_HAL_DRIVER',
|
'USE_HAL_DRIVER',
|
||||||
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
] + CPPDEFINES_MOD + CPPDEFINES_HAL,
|
||||||
] + CPPDEFINES_MOD,
|
ASFLAGS=env.get('ENV')['CPU_ASFLAGS'],
|
||||||
ASFLAGS=CPU_ASFLAGS,
|
ASPPFLAGS='$CFLAGS $CCFLAGS',
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
HEADERTOOL='tools/headertool.py',
|
HEADERTOOL='tools/headertool.py',
|
||||||
@ -725,7 +663,7 @@ env.Depends(protobuf_blobs, qstr_generated)
|
|||||||
|
|
||||||
RUST_PROFILE = 'release'
|
RUST_PROFILE = 'release'
|
||||||
RUST_LIB = 'trezor_lib'
|
RUST_LIB = 'trezor_lib'
|
||||||
RUST_LIBDIR = f'build/firmware/rust/{RUST_TARGET}/{RUST_PROFILE}'
|
RUST_LIBDIR = f'build/firmware/rust/{env.get("ENV")["RUST_TARGET"]}/{RUST_PROFILE}'
|
||||||
RUST_LIBPATH = f'{RUST_LIBDIR}/lib{RUST_LIB}.a'
|
RUST_LIBPATH = f'{RUST_LIBDIR}/lib{RUST_LIB}.a'
|
||||||
|
|
||||||
def cargo_build():
|
def cargo_build():
|
||||||
@ -751,7 +689,7 @@ def cargo_build():
|
|||||||
features.extend(FEATURES_AVAILABLE)
|
features.extend(FEATURES_AVAILABLE)
|
||||||
|
|
||||||
cargo_opts = [
|
cargo_opts = [
|
||||||
f'--target={RUST_TARGET}',
|
f'--target={env.get("ENV")["RUST_TARGET"]}',
|
||||||
f'--target-dir=../../build/firmware/rust',
|
f'--target-dir=../../build/firmware/rust',
|
||||||
'--no-default-features',
|
'--no-default-features',
|
||||||
'--features ' + ','.join(features),
|
'--features ' + ','.join(features),
|
||||||
@ -776,7 +714,7 @@ env.Append(LINKFLAGS=f' -l{RUST_LIB}')
|
|||||||
# Program objects
|
# Program objects
|
||||||
#
|
#
|
||||||
|
|
||||||
source_files = SOURCE_MOD + SOURCE_FIRMWARE + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED + SOURCE_STMHAL + SOURCE_TREZORHAL
|
source_files = SOURCE_MOD + SOURCE_FIRMWARE + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED + SOURCE_HAL
|
||||||
obj_program = []
|
obj_program = []
|
||||||
obj_program.extend(env.Object(source=SOURCE_MOD))
|
obj_program.extend(env.Object(source=SOURCE_MOD))
|
||||||
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||||
@ -785,8 +723,7 @@ if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
|||||||
obj_program.extend(env.Object(source=SOURCE_FIRMWARE))
|
obj_program.extend(env.Object(source=SOURCE_FIRMWARE))
|
||||||
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON))
|
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON))
|
||||||
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON_SPEED, COPT='-O3'))
|
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON_SPEED, COPT='-O3'))
|
||||||
obj_program.extend(env.Object(source=SOURCE_STMHAL))
|
obj_program.extend(env.Object(source=SOURCE_HAL))
|
||||||
obj_program.extend(env.Object(source=SOURCE_TREZORHAL))
|
|
||||||
if FROZEN:
|
if FROZEN:
|
||||||
obj_program.extend(env.Object(source=source_mpyc))
|
obj_program.extend(env.Object(source=source_mpyc))
|
||||||
|
|
||||||
@ -812,13 +749,15 @@ elif PRODUCTION:
|
|||||||
else:
|
else:
|
||||||
VENDORHEADER = f'embed/vendorheader/{MODEL_IDENTIFIER}/vendorheader_unsafe_signed_prod.bin'
|
VENDORHEADER = f'embed/vendorheader/{MODEL_IDENTIFIER}/vendorheader_unsafe_signed_prod.bin'
|
||||||
|
|
||||||
obj_program.extend(
|
|
||||||
env.Command(
|
if TREZOR_MODEL not in ('1',):
|
||||||
target='embed/firmware/vendorheader.o',
|
obj_program.extend(
|
||||||
source=VENDORHEADER,
|
env.Command(
|
||||||
action='$OBJCOPY -I binary -O elf32-littlearm -B arm'
|
target='embed/firmware/vendorheader.o',
|
||||||
' --rename-section .data=.vendorheader,alloc,load,readonly,contents'
|
source=VENDORHEADER,
|
||||||
' $SOURCE $TARGET', ))
|
action='$OBJCOPY -I binary -O elf32-littlearm -B arm'
|
||||||
|
' --rename-section .data=.vendorheader,alloc,load,readonly,contents'
|
||||||
|
' $SOURCE $TARGET', ))
|
||||||
|
|
||||||
if TREZOR_MODEL not in ('DISC1', ):
|
if TREZOR_MODEL not in ('DISC1', ):
|
||||||
obj_program.extend(
|
obj_program.extend(
|
||||||
|
@ -17,7 +17,7 @@ if TREZOR_MODEL in ('DISC1', ):
|
|||||||
action=build_prodtest)
|
action=build_prodtest)
|
||||||
Return()
|
Return()
|
||||||
|
|
||||||
FEATURES_WANTED = ["input", "sbu", "sd_card", "rdb_led"]
|
FEATURES_WANTED = ["input", "sbu", "sd_card", "rdb_led", "usb"]
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
@ -25,6 +25,9 @@ CPPDEFINES_MOD = [
|
|||||||
'USE_INSECURE_PRNG',
|
'USE_INSECURE_PRNG',
|
||||||
]
|
]
|
||||||
SOURCE_MOD = []
|
SOURCE_MOD = []
|
||||||
|
CPPDEFINES_HAL = []
|
||||||
|
SOURCE_HAL = []
|
||||||
|
PATH_HAL = []
|
||||||
|
|
||||||
if TREZOR_MODEL in ('1', 'R'):
|
if TREZOR_MODEL in ('1', 'R'):
|
||||||
FONT_NORMAL=None
|
FONT_NORMAL=None
|
||||||
@ -61,58 +64,19 @@ SOURCE_MOD += [
|
|||||||
'embed/lib/colors.c',
|
'embed/lib/colors.c',
|
||||||
'embed/lib/fonts/fonts.c',
|
'embed/lib/fonts/fonts.c',
|
||||||
'embed/lib/fonts/font_bitmap.c',
|
'embed/lib/fonts/font_bitmap.c',
|
||||||
|
'embed/lib/mini_printf.c',
|
||||||
'embed/lib/qr-code-generator/qrcodegen.c',
|
'embed/lib/qr-code-generator/qrcodegen.c',
|
||||||
'vendor/micropython/lib/uzlib/adler32.c',
|
'vendor/micropython/lib/uzlib/adler32.c',
|
||||||
'vendor/micropython/lib/uzlib/crc32.c',
|
'vendor/micropython/lib/uzlib/crc32.c',
|
||||||
'vendor/micropython/lib/uzlib/tinflate.c',
|
'vendor/micropython/lib/uzlib/tinflate.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_STMHAL = [
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c',
|
|
||||||
]
|
|
||||||
|
|
||||||
SOURCE_PRODTEST = [
|
SOURCE_PRODTEST = [
|
||||||
'embed/prodtest/startup.s',
|
'embed/prodtest/startup.s',
|
||||||
'embed/prodtest/header.S',
|
'embed/prodtest/header.S',
|
||||||
'embed/prodtest/main.c',
|
'embed/prodtest/main.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_TREZORHAL = [
|
|
||||||
'embed/trezorhal/common.c',
|
|
||||||
'embed/trezorhal/dma.c',
|
|
||||||
'embed/trezorhal/flash.c',
|
|
||||||
'embed/trezorhal/mini_printf.c',
|
|
||||||
'embed/trezorhal/random_delays.c',
|
|
||||||
'embed/trezorhal/rng.c',
|
|
||||||
'embed/trezorhal/stm32.c',
|
|
||||||
'embed/trezorhal/systick.c',
|
|
||||||
'embed/trezorhal/usb.c',
|
|
||||||
'embed/trezorhal/usbd_conf.c',
|
|
||||||
'embed/trezorhal/usbd_core.c',
|
|
||||||
'embed/trezorhal/usbd_ctlreq.c',
|
|
||||||
'embed/trezorhal/usbd_ioreq.c',
|
|
||||||
'embed/trezorhal/util.s',
|
|
||||||
'embed/trezorhal/vectortable.s',
|
|
||||||
]
|
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD)
|
tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD)
|
||||||
tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD)
|
tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD)
|
||||||
@ -122,7 +86,7 @@ tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD)
|
|||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||||
|
|
||||||
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
CP='cp',
|
CP='cp',
|
||||||
@ -139,17 +103,6 @@ env.Replace(
|
|||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=TREZOR_MODEL, )
|
TREZOR_MODEL=TREZOR_MODEL, )
|
||||||
|
|
||||||
if TREZOR_MODEL in ('T', 'R'):
|
|
||||||
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 TREZOR_MODEL in ('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(
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
@ -159,7 +112,7 @@ env.Replace(
|
|||||||
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
||||||
'-ffreestanding '
|
'-ffreestanding '
|
||||||
'-fstack-protector-all '
|
'-fstack-protector-all '
|
||||||
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
+ env.get('ENV')["CPU_CCFLAGS"] + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LINKFLAGS='-T embed/prodtest/memory.ld -Wl,--gc-sections -Wl,-Map=build/prodtest/prodtest.map -Wl,--warn-common',
|
LINKFLAGS='-T embed/prodtest/memory.ld -Wl,--gc-sections -Wl,-Map=build/prodtest/prodtest.map -Wl,--warn-common',
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
@ -168,19 +121,16 @@ env.Replace(
|
|||||||
'embed/models',
|
'embed/models',
|
||||||
'embed/trezorhal',
|
'embed/trezorhal',
|
||||||
'embed/extmod/modtrezorui',
|
'embed/extmod/modtrezorui',
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc',
|
|
||||||
'vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include',
|
|
||||||
'vendor/micropython/lib/cmsis/inc',
|
'vendor/micropython/lib/cmsis/inc',
|
||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD + PATH_HAL,
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
'TREZOR_PRODTEST',
|
'TREZOR_PRODTEST',
|
||||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||||
CPU_MODEL,
|
|
||||||
'USE_HAL_DRIVER',
|
'USE_HAL_DRIVER',
|
||||||
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
] + CPPDEFINES_MOD + CPPDEFINES_HAL,
|
||||||
] + CPPDEFINES_MOD,
|
ASFLAGS=env.get('ENV')['CPU_ASFLAGS'],
|
||||||
ASFLAGS=CPU_ASFLAGS,
|
ASPPFLAGS='$CFLAGS $CCFLAGS',
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
HEADERTOOL='tools/headertool.py',
|
HEADERTOOL='tools/headertool.py',
|
||||||
@ -188,7 +138,7 @@ env.Replace(
|
|||||||
|
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
ALLSOURCES=SOURCE_MOD + SOURCE_PRODTEST + SOURCE_STMHAL + SOURCE_TREZORHAL,
|
ALLSOURCES=SOURCE_MOD + SOURCE_PRODTEST + SOURCE_HAL,
|
||||||
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES']))
|
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES']))
|
||||||
|
|
||||||
cmake_gen = env.Command(
|
cmake_gen = env.Command(
|
||||||
@ -205,8 +155,7 @@ cmake_gen = env.Command(
|
|||||||
obj_program = []
|
obj_program = []
|
||||||
obj_program.extend(env.Object(source=SOURCE_MOD))
|
obj_program.extend(env.Object(source=SOURCE_MOD))
|
||||||
obj_program.extend(env.Object(source=SOURCE_PRODTEST))
|
obj_program.extend(env.Object(source=SOURCE_PRODTEST))
|
||||||
obj_program.extend(env.Object(source=SOURCE_STMHAL))
|
obj_program.extend(env.Object(source=SOURCE_HAL))
|
||||||
obj_program.extend(env.Object(source=SOURCE_TREZORHAL))
|
|
||||||
|
|
||||||
MODEL_IDENTIFIER = tools.get_model_identifier(TREZOR_MODEL)
|
MODEL_IDENTIFIER = tools.get_model_identifier(TREZOR_MODEL)
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@ CCFLAGS_MOD = ''
|
|||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
SOURCE_MOD = []
|
SOURCE_MOD = []
|
||||||
|
CPPDEFINES_HAL = []
|
||||||
|
SOURCE_HAL = []
|
||||||
|
PATH_HAL = []
|
||||||
|
|
||||||
if TREZOR_MODEL in ('1', 'R'):
|
if TREZOR_MODEL in ('1', 'R'):
|
||||||
FONT_NORMAL=None
|
FONT_NORMAL=None
|
||||||
@ -54,56 +57,18 @@ SOURCE_MOD += [
|
|||||||
'embed/lib/colors.c',
|
'embed/lib/colors.c',
|
||||||
'embed/lib/fonts/fonts.c',
|
'embed/lib/fonts/fonts.c',
|
||||||
'embed/lib/fonts/font_bitmap.c',
|
'embed/lib/fonts/font_bitmap.c',
|
||||||
|
'embed/lib/mini_printf.c',
|
||||||
'vendor/micropython/lib/uzlib/adler32.c',
|
'vendor/micropython/lib/uzlib/adler32.c',
|
||||||
'vendor/micropython/lib/uzlib/crc32.c',
|
'vendor/micropython/lib/uzlib/crc32.c',
|
||||||
'vendor/micropython/lib/uzlib/tinflate.c',
|
'vendor/micropython/lib/uzlib/tinflate.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_STMHAL = [
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c',
|
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c',
|
|
||||||
]
|
|
||||||
|
|
||||||
SOURCE_REFLASH = [
|
SOURCE_REFLASH = [
|
||||||
'embed/reflash/startup.s',
|
'embed/reflash/startup.s',
|
||||||
'embed/reflash/header.S',
|
'embed/reflash/header.S',
|
||||||
'embed/reflash/main.c',
|
'embed/reflash/main.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_TREZORHAL = [
|
|
||||||
'embed/trezorhal/common.c',
|
|
||||||
'embed/trezorhal/dma.c',
|
|
||||||
'embed/trezorhal/flash.c',
|
|
||||||
'embed/trezorhal/mini_printf.c',
|
|
||||||
'embed/trezorhal/rng.c',
|
|
||||||
'embed/trezorhal/systick.c',
|
|
||||||
'embed/trezorhal/stm32.c',
|
|
||||||
'embed/trezorhal/usb.c',
|
|
||||||
'embed/trezorhal/usbd_conf.c',
|
|
||||||
'embed/trezorhal/usbd_core.c',
|
|
||||||
'embed/trezorhal/usbd_ctlreq.c',
|
|
||||||
'embed/trezorhal/usbd_ioreq.c',
|
|
||||||
'embed/trezorhal/util.s',
|
|
||||||
'embed/trezorhal/vectortable.s',
|
|
||||||
]
|
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD)
|
tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD)
|
||||||
tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD)
|
tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD)
|
||||||
@ -113,7 +78,7 @@ tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD)
|
|||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||||
|
|
||||||
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
CP='cp',
|
CP='cp',
|
||||||
@ -130,17 +95,6 @@ env.Replace(
|
|||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=TREZOR_MODEL, )
|
TREZOR_MODEL=TREZOR_MODEL, )
|
||||||
|
|
||||||
if TREZOR_MODEL in ('T', 'R'):
|
|
||||||
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 TREZOR_MODEL in ('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(
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
@ -150,7 +104,7 @@ env.Replace(
|
|||||||
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
||||||
'-ffreestanding '
|
'-ffreestanding '
|
||||||
'-fstack-protector-all '
|
'-fstack-protector-all '
|
||||||
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
+ env.get('ENV')["CPU_CCFLAGS"] + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LINKFLAGS='-T embed/reflash/memory.ld -Wl,--gc-sections -Wl,-Map=build/reflash/reflash.map -Wl,--warn-common',
|
LINKFLAGS='-T embed/reflash/memory.ld -Wl,--gc-sections -Wl,-Map=build/reflash/reflash.map -Wl,--warn-common',
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
@ -159,25 +113,22 @@ env.Replace(
|
|||||||
'embed/models',
|
'embed/models',
|
||||||
'embed/trezorhal',
|
'embed/trezorhal',
|
||||||
'embed/extmod/modtrezorui',
|
'embed/extmod/modtrezorui',
|
||||||
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc',
|
|
||||||
'vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include',
|
|
||||||
'vendor/micropython/lib/cmsis/inc',
|
'vendor/micropython/lib/cmsis/inc',
|
||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD + PATH_HAL,
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||||
CPU_MODEL,
|
|
||||||
'USE_HAL_DRIVER',
|
'USE_HAL_DRIVER',
|
||||||
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
] + CPPDEFINES_MOD + CPPDEFINES_HAL,
|
||||||
] + CPPDEFINES_MOD,
|
ASFLAGS=env.get('ENV')['CPU_ASFLAGS'],
|
||||||
ASFLAGS=CPU_ASFLAGS,
|
ASPPFLAGS='$CFLAGS $CCFLAGS',
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
HEADERTOOL='tools/headertool.py',
|
HEADERTOOL='tools/headertool.py',
|
||||||
)
|
)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
ALLSOURCES=SOURCE_MOD + SOURCE_REFLASH + SOURCE_STMHAL + SOURCE_TREZORHAL,
|
ALLSOURCES=SOURCE_MOD + SOURCE_REFLASH + SOURCE_HAL,
|
||||||
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES']))
|
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES']))
|
||||||
|
|
||||||
cmake_gen = env.Command(
|
cmake_gen = env.Command(
|
||||||
@ -193,8 +144,7 @@ cmake_gen = env.Command(
|
|||||||
obj_program = []
|
obj_program = []
|
||||||
obj_program += env.Object(source=SOURCE_MOD)
|
obj_program += env.Object(source=SOURCE_MOD)
|
||||||
obj_program += env.Object(source=SOURCE_REFLASH)
|
obj_program += env.Object(source=SOURCE_REFLASH)
|
||||||
obj_program += env.Object(source=SOURCE_STMHAL)
|
obj_program += env.Object(source=SOURCE_HAL)
|
||||||
obj_program += env.Object(source=SOURCE_TREZORHAL)
|
|
||||||
|
|
||||||
MODEL_IDENTIFIER = tools.get_model_identifier(TREZOR_MODEL)
|
MODEL_IDENTIFIER = tools.get_model_identifier(TREZOR_MODEL)
|
||||||
|
|
||||||
|
@ -351,16 +351,16 @@ SOURCE_MICROPYTHON = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
SOURCE_UNIX = [
|
SOURCE_UNIX = [
|
||||||
'embed/unix/common.c',
|
'embed/trezorhal/unix/common.c',
|
||||||
'embed/unix/display-unix.c',
|
'embed/trezorhal/unix/display-unix.c',
|
||||||
'embed/unix/flash.c',
|
'embed/trezorhal/unix/flash.c',
|
||||||
|
'embed/trezorhal/unix/random_delays.c',
|
||||||
|
'embed/trezorhal/unix/rng.c',
|
||||||
|
'embed/trezorhal/unix/usb.c',
|
||||||
|
'embed/trezorhal/unix/touch/touch.c',
|
||||||
'embed/unix/main.c',
|
'embed/unix/main.c',
|
||||||
'embed/unix/main_main.c',
|
'embed/unix/main_main.c',
|
||||||
'embed/unix/profile.c',
|
'embed/unix/profile.c',
|
||||||
'embed/unix/random_delays.c',
|
|
||||||
'embed/unix/rng.c',
|
|
||||||
'embed/unix/touch/touch.c',
|
|
||||||
'embed/unix/usb.c',
|
|
||||||
'vendor/micropython/shared/runtime/gchelper_generic.c',
|
'vendor/micropython/shared/runtime/gchelper_generic.c',
|
||||||
'vendor/micropython/ports/unix/alloc.c',
|
'vendor/micropython/ports/unix/alloc.c',
|
||||||
'vendor/micropython/ports/unix/gccollect.c',
|
'vendor/micropython/ports/unix/gccollect.c',
|
||||||
@ -369,8 +369,8 @@ SOURCE_UNIX = [
|
|||||||
]
|
]
|
||||||
if TREZOR_MODEL in ('T', 'R'):
|
if TREZOR_MODEL in ('T', 'R'):
|
||||||
SOURCE_UNIX += [
|
SOURCE_UNIX += [
|
||||||
'embed/unix/sbu.c',
|
'embed/trezorhal/unix/sbu.c',
|
||||||
'embed/unix/sdcard.c',
|
'embed/trezorhal/unix/sdcard.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
if DMA2D:
|
if DMA2D:
|
||||||
@ -469,6 +469,8 @@ env.Replace(
|
|||||||
'embed/lib',
|
'embed/lib',
|
||||||
'embed/models',
|
'embed/models',
|
||||||
'embed/unix',
|
'embed/unix',
|
||||||
|
'embed/trezorhal',
|
||||||
|
'embed/trezorhal/unix',
|
||||||
'embed/extmod/modtrezorui',
|
'embed/extmod/modtrezorui',
|
||||||
'vendor/micropython',
|
'vendor/micropython',
|
||||||
'vendor/micropython/ports/unix',
|
'vendor/micropython/ports/unix',
|
||||||
@ -478,7 +480,7 @@ env.Replace(
|
|||||||
CPU_MODEL,
|
CPU_MODEL,
|
||||||
'TREZOR_EMULATOR',
|
'TREZOR_EMULATOR',
|
||||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||||
'TREZOR_BOARD=\\"board-unix.h\\"',
|
'TREZOR_BOARD=\\"boards/board-unix.h\\"',
|
||||||
('MP_CONFIGFILE', '\\"embed/unix/mpconfigport.h\\"'),
|
('MP_CONFIGFILE', '\\"embed/unix/mpconfigport.h\\"'),
|
||||||
] + CPPDEFINES_MOD,
|
] + CPPDEFINES_MOD,
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
||||||
|
@ -110,7 +110,7 @@ void ui_screen_boot_wait(int wait_seconds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined USE_TOUCH
|
#if defined USE_TOUCH
|
||||||
#include "touch/touch.h"
|
#include "touch.h"
|
||||||
|
|
||||||
void ui_click(void) {
|
void ui_click(void) {
|
||||||
// flush touch events if any
|
// flush touch events if any
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "compiler_traits.h"
|
#include "compiler_traits.h"
|
||||||
#include "mini_printf.h"
|
#include "mini_printf.h"
|
||||||
#include "mpu.h"
|
#include "mpu.h"
|
||||||
#include "stm32.h"
|
#include "platform.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_DMA2D
|
#ifdef USE_DMA2D
|
||||||
#include "dma2d.h"
|
#include "dma2d.h"
|
||||||
@ -41,7 +41,7 @@
|
|||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_TOUCH
|
#ifdef USE_TOUCH
|
||||||
#include "touch/touch.h"
|
#include "touch.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_BUTTON
|
#ifdef USE_BUTTON
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
#ifdef USE_TOUCH
|
#ifdef USE_TOUCH
|
||||||
#include "touch/touch.h"
|
#include "touch.h"
|
||||||
#endif
|
#endif
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include TREZOR_BOARD
|
#include TREZOR_BOARD
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "touch/touch.h"
|
#include "touch.h"
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
// Whether USB data pins were connected on last check (USB configured)
|
// Whether USB data pins were connected on last check (USB configured)
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_TOUCH
|
#ifdef USE_TOUCH
|
||||||
#include "touch/touch.h"
|
#include "touch.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SD_CARD
|
#ifdef USE_SD_CARD
|
||||||
#include "sdcard.h"
|
#include "sdcard.h"
|
||||||
@ -71,8 +71,8 @@
|
|||||||
#ifdef SYSTEM_VIEW
|
#ifdef SYSTEM_VIEW
|
||||||
#include "systemview.h"
|
#include "systemview.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "platform.h"
|
||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
#include "stm32.h"
|
|
||||||
#include "supervise.h"
|
#include "supervise.h"
|
||||||
#ifdef USE_SECP256K1_ZKP
|
#ifdef USE_SECP256K1_ZKP
|
||||||
#include "zkp_context.h"
|
#include "zkp_context.h"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
#ifdef USE_TOUCH
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
|
|
||||||
uint32_t touch_click(void) {
|
uint32_t touch_click(void) {
|
||||||
@ -18,3 +19,4 @@ uint32_t touch_click(void) {
|
|||||||
// return last touch coordinate
|
// return last touch coordinate
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
#endif
|
@ -34,7 +34,7 @@
|
|||||||
#include "sbu.h"
|
#include "sbu.h"
|
||||||
#include "sdcard.h"
|
#include "sdcard.h"
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
#include "touch/touch.h"
|
#include "touch.h"
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
#include "memzero.h"
|
#include "memzero.h"
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "sbu.h"
|
#include "sbu.h"
|
||||||
#include "sdcard.h"
|
#include "sdcard.h"
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
#include "touch/touch.h"
|
#include "touch.h"
|
||||||
|
|
||||||
static void progress_callback(int pos, int len) { display_printf("."); }
|
static void progress_callback(int pos, int len) { display_printf("."); }
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ sbu = []
|
|||||||
sd_card = []
|
sd_card = []
|
||||||
rgb_led = []
|
rgb_led = []
|
||||||
backlight = []
|
backlight = []
|
||||||
|
usb = []
|
||||||
test = [
|
test = [
|
||||||
"button",
|
"button",
|
||||||
"cc",
|
"cc",
|
||||||
|
@ -21,7 +21,7 @@ fn model() -> String {
|
|||||||
|
|
||||||
fn board() -> String {
|
fn board() -> String {
|
||||||
if !is_firmware() {
|
if !is_firmware() {
|
||||||
return String::from("board-unix.h");
|
return String::from("boards/board-unix.h");
|
||||||
}
|
}
|
||||||
|
|
||||||
match env::var("TREZOR_BOARD") {
|
match env::var("TREZOR_BOARD") {
|
||||||
@ -76,6 +76,7 @@ fn prepare_bindings() -> bindgen::Builder {
|
|||||||
"-I../../vendor/micropython",
|
"-I../../vendor/micropython",
|
||||||
"-I../../vendor/micropython/lib/uzlib",
|
"-I../../vendor/micropython/lib/uzlib",
|
||||||
"-I../lib",
|
"-I../lib",
|
||||||
|
"-I../trezorhal",
|
||||||
"-DSTM32F427xx",
|
"-DSTM32F427xx",
|
||||||
format!("-DTREZOR_MODEL_{}", model()).as_str(),
|
format!("-DTREZOR_MODEL_{}", model()).as_str(),
|
||||||
format!("-DTREZOR_BOARD=\"{}\"", board()).as_str(),
|
format!("-DTREZOR_BOARD=\"{}\"", board()).as_str(),
|
||||||
@ -86,7 +87,7 @@ fn prepare_bindings() -> bindgen::Builder {
|
|||||||
bindings = bindings.clang_args(&[
|
bindings = bindings.clang_args(&[
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-I../firmware",
|
"-I../firmware",
|
||||||
"-I../trezorhal",
|
"-I../trezorhal/stm32f4",
|
||||||
"-I../../build/firmware",
|
"-I../../build/firmware",
|
||||||
"-I../../vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc",
|
"-I../../vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc",
|
||||||
"-I../../vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include",
|
"-I../../vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include",
|
||||||
@ -117,6 +118,7 @@ fn prepare_bindings() -> bindgen::Builder {
|
|||||||
} else {
|
} else {
|
||||||
bindings = bindings.clang_args(&[
|
bindings = bindings.clang_args(&[
|
||||||
"-I../unix",
|
"-I../unix",
|
||||||
|
"-I../trezorhal/unix",
|
||||||
"-I../../build/unix",
|
"-I../../build/unix",
|
||||||
"-I../../vendor/micropython/ports/unix",
|
"-I../../vendor/micropython/ports/unix",
|
||||||
"-DTREZOR_EMULATOR",
|
"-DTREZOR_EMULATOR",
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "rgb_led.h"
|
#include "rgb_led.h"
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
#include "touch/touch.h"
|
#include "touch.h"
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
#include "bip39.h"
|
#include "bip39.h"
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
#ifndef MIN_8bits
|
#ifndef MIN_8bits
|
||||||
#define MIN_8bits(a, b) \
|
#define MIN_8bits(a, b) \
|
||||||
({ \
|
({ \
|
||||||
@ -70,20 +72,8 @@ void show_pin_too_many_screen(void);
|
|||||||
void hal_delay(uint32_t ms);
|
void hal_delay(uint32_t ms);
|
||||||
uint32_t hal_ticks_ms();
|
uint32_t hal_ticks_ms();
|
||||||
|
|
||||||
void clear_otg_hs_memory(void);
|
|
||||||
|
|
||||||
extern uint32_t __stack_chk_guard;
|
|
||||||
|
|
||||||
void collect_hw_entropy(void);
|
void collect_hw_entropy(void);
|
||||||
#define HW_ENTROPY_LEN (12 + 32)
|
#define HW_ENTROPY_LEN (12 + 32)
|
||||||
extern uint8_t HW_ENTROPY_DATA[HW_ENTROPY_LEN];
|
extern uint8_t HW_ENTROPY_DATA[HW_ENTROPY_LEN];
|
||||||
|
|
||||||
// the following functions are defined in util.s
|
|
||||||
|
|
||||||
void memset_reg(volatile void *start, volatile void *stop, uint32_t val);
|
|
||||||
void jump_to(uint32_t address);
|
|
||||||
void jump_to_unprivileged(uint32_t address);
|
|
||||||
void jump_to_with_flag(uint32_t address, uint32_t register_flag);
|
|
||||||
void ensure_compatible_settings(void);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -92,6 +92,8 @@ extern const uint8_t FIRMWARE_SECTORS[FIRMWARE_SECTORS_COUNT];
|
|||||||
|
|
||||||
void flash_init(void);
|
void flash_init(void);
|
||||||
|
|
||||||
|
uint32_t flash_wait_and_clear_status_flags(void);
|
||||||
|
|
||||||
secbool __wur flash_unlock_write(void);
|
secbool __wur flash_unlock_write(void);
|
||||||
secbool __wur flash_lock_write(void);
|
secbool __wur flash_lock_write(void);
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
|
|
||||||
uint32_t flash_wait_and_clear_status_flags(void);
|
|
||||||
secbool flash_check_option_bytes(void);
|
secbool flash_check_option_bytes(void);
|
||||||
void flash_lock_option_bytes(void);
|
void flash_lock_option_bytes(void);
|
||||||
void flash_unlock_option_bytes(void);
|
void flash_unlock_option_bytes(void);
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
#include "rust_ui.h"
|
#include "rust_ui.h"
|
||||||
#endif
|
#endif
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
#include "platform.h"
|
||||||
#include "rand.h"
|
#include "rand.h"
|
||||||
#include "stm32.h"
|
|
||||||
#include "supervise.h"
|
#include "supervise.h"
|
||||||
|
|
||||||
#include "mini_printf.h"
|
#include "mini_printf.h"
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include STM32_HAL_H
|
#include STM32_HAL_H
|
||||||
|
|
||||||
#include "stm32.h"
|
#include "platform.h"
|
||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
|
|
||||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0,
|
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0,
|
@ -21,6 +21,7 @@
|
|||||||
#define TREZORHAL_STM32_H
|
#define TREZORHAL_STM32_H
|
||||||
|
|
||||||
#include STM32_HAL_H
|
#include STM32_HAL_H
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CLOCK_180_MHZ = 0,
|
CLOCK_180_MHZ = 0,
|
||||||
@ -29,5 +30,15 @@ typedef enum {
|
|||||||
} clock_settings_t;
|
} clock_settings_t;
|
||||||
|
|
||||||
void set_core_clock(clock_settings_t settings);
|
void set_core_clock(clock_settings_t settings);
|
||||||
|
// the following functions are defined in util.s
|
||||||
|
|
||||||
|
void memset_reg(volatile void *start, volatile void *stop, uint32_t val);
|
||||||
|
void jump_to(uint32_t address);
|
||||||
|
void jump_to_unprivileged(uint32_t address);
|
||||||
|
void jump_to_with_flag(uint32_t address, uint32_t register_flag);
|
||||||
|
void ensure_compatible_settings(void);
|
||||||
|
void clear_otg_hs_memory(void);
|
||||||
|
|
||||||
|
extern uint32_t __stack_chk_guard;
|
||||||
|
|
||||||
#endif // TREZORHAL_STM32_H
|
#endif // TREZORHAL_STM32_H
|
1
core/embed/trezorhal/stm32f4/systemview.h
Symbolic link
1
core/embed/trezorhal/stm32f4/systemview.h
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../firmware/systemview.h
|
@ -1 +0,0 @@
|
|||||||
../firmware/systemview.h
|
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user