Skip to content

Commit

Permalink
Multiple lowlevel optimizes, check commits for detail (#173)
Browse files Browse the repository at this point in the history
* nrf device key verify no longer blocking update mode (leftover due to "main" rebase)

* boardloader update modes enter method change (leftover due to "main" rebase)

* debugger script and makefile cleanup

* usb descriptor update

* adc and hardware version detect support

* mpu disallow exec in spi flash range

* minor fix and code format

* minor hal changes

* public keys move to dedicate file

* support board without qspi flash

* firmware switch to emmc_fs api

* legacy user data storage api removal

* boardloader mpu config move to dedicate location

* emmc provide deinit methods

* boardloader flash ecc recovery bug fix

* ci build add non-prod boardloader reflash

---------

Signed-off-by: Adam BZH <[email protected]>
  • Loading branch information
424778940z authored Aug 29, 2024
1 parent 6deb9fb commit 70ef643
Show file tree
Hide file tree
Showing 51 changed files with 1,238 additions and 1,193 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-pro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ jobs:
git submodule update --init --recursive
nix-shell --run "poetry run make -C core clean"
nix-shell --run "poetry run make -C core build_boardloader"
nix-shell --run "poetry run make -C core build_boardloader_reflash_dev"
nix-shell --run "poetry run make -C core build_bootloader"
nix-shell --run "poetry run make -C core build_firmware"
nix-shell --run "poetry run core/tools/headertool.py -h core/build/boardloader_reflash_dev/pro.boardloader_reflash_dev*Stable*.bin -S 1:${{ secrets.SECRET_QA_KEY_1 }} -S 2:${{ secrets.SECRET_QA_KEY_2 }}"
nix-shell --run "poetry run core/tools/headertool.py -h core/build/bootloader/pro.bootloader*Stable*.bin -S 1:${{ secrets.SECRET_QA_KEY_1 }} -S 2:${{ secrets.SECRET_QA_KEY_2 }}"
nix-shell --run "poetry run core/tools/headertool.py -h core/build/firmware/pro*Stable*.bin -S 1:${{ secrets.SECRET_QA_KEY_1 }} -S 2:${{ secrets.SECRET_QA_KEY_2 }}"
mkdir -p core/build/output/qa
cp ./core/build/boardloader/boardloader.bin core/build/output/qa
cp ./core/build/boardloader_reflash_dev/pro.boardloader_reflash_dev*Stable*.bin core/build/output/qa
cp ./core/build/bootloader/pro.bootloader*Stable*.bin core/build/output/qa
cp ./core/build/firmware/pro*Stable*.bin core/build/output/qa
tools/hash.py -t bootloader -f core/build/bootloader/bootloader.bin > core/build/output/qa/bootloader_sha256.txt
Expand Down
86 changes: 22 additions & 64 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ OPENOCD_T1 = openocd -f interface/$(OPENOCD_INTERFACE).cfg -c "transport select
BOARDLOADER_START = 0x08000000
BOOTLOADER_START = 0x08020000
FIRMWARE_P1_START = 0x08060000
FIRMWARE_P2_START = 0x08120000
PRODTEST_START = 0x08040000
FIRMWARE_T1_START = 0x08010000
FIRMWARE_P2_START = 0x90000000

BOARDLOADER_MAXSIZE = 49152
BOOTLOADER_MAXSIZE = 131072
Expand Down Expand Up @@ -244,71 +242,37 @@ clean_cross: ## clean mpy-cross build

## flash commands:

flash: flash_boardloader flash_bootloader flash_firmware ## flash everything using OpenOCD

flash_boardloader: $(BOARDLOADER_BUILD_DIR)/boardloader.bin ## flash boardloader using OpenOCD
$(OPENOCD) -c "init; reset halt; flash write_image erase $< $(BOARDLOADER_START); exit"

flash_bootloader: $(BOOTLOADER_BUILD_DIR)/bootloader.bin ## flash bootloader using OpenOCD
$(OPENOCD) -c "init; reset halt; flash write_image erase $< $(BOOTLOADER_START); exit"

flash_bootloader_ci: $(BOOTLOADER_CI_BUILD_DIR)/bootloader.bin ## flash CI bootloader using OpenOCD
$(OPENOCD) -c "init; reset halt; flash write_image erase $< $(BOOTLOADER_START); exit"

flash_prodtest: $(PRODTEST_BUILD_DIR)/prodtest.bin ## flash prodtest using OpenOCD
$(OPENOCD) -c "init; reset halt; flash write_image erase $< $(PRODTEST_START); exit"

flash_firmware: $(FIRMWARE_BUILD_DIR)/firmware.bin ## flash firmware using OpenOCD
$(OPENOCD) -c "init; reset halt; flash write_image erase $<.p1 $(FIRMWARE_P1_START); flash write_image erase $<.p2 $(FIRMWARE_P2_START); exit"

flash_firmware_t1: $(FIRMWARE_BUILD_DIR)/firmware.bin ## flash T1 core port on T1 using OpenOCD
$(OPENOCD_T1) -c "init; reset halt; flash write_image erase $< $(FIRMWARE_T1_START); exit"

flash_combine: $(PRODTEST_BUILD_DIR)/combined.bin ## flash combined using OpenOCD
$(OPENOCD) -c "init; reset halt; flash write_image erase $< $(BOARDLOADER_START); exit"

flash_erase: ## erase all sectors in flash bank 0
$(OPENOCD) -c "init; reset halt; flash info 0; flash erase_sector 0 0 last; flash erase_check 0; exit"

flash_read_storage: ## read storage sectors from flash
$(OPENOCD) -c "init; flash read_bank 0 storage1.data 0x10000 65536; flash read_bank 0 storage2.data 0x110000 65536; exit"

flash_erase_storage: ## erase storage sectors from flash
$(OPENOCD) -c "init; flash erase_sector 0 4 4; flash erase_sector 0 16 16; exit"

flash_boardloader_jlink: $(BOARDLOADER_BUILD_DIR)/boardloader.bin ## flash bootloader using JLink
JLinkExe -nogui 1 -commanderscript embed/debugger_scripts/jlink/write_boardloader.jlink
embed/debugger_scripts/jlink/jlink_write.sh $(BOARDLOADER_BUILD_DIR)/boardloader.bin $(BOARDLOADER_START)

flash_boardloader_reflash_dev_jlink: $(BOAR_DEV_REFLASH_BUILD_DIR)/boardloader_reflash_dev.bin ## flash boardloader_reflash_dev using JLink
JLinkExe -nogui 1 -commanderscript embed/debugger_scripts/jlink/write_boardloader_reflash_dev.jlink
embed/debugger_scripts/jlink/jlink_write.sh $(BOAR_DEV_REFLASH_BUILD_DIR)/boardloader_reflash_dev.bin $(BOOTLOADER_START)

flash_bootloader_jlink: $(BOOTLOADER_BUILD_DIR)/bootloader.bin ## flash bootloader using JLink
JLinkExe -nogui 1 -commanderscript embed/debugger_scripts/jlink/write_bootloader.jlink

# flash_bootloader_ci_jlink: $(BOOTLOADER_CI_BUILD_DIR)/bootloader.bin ## flash CI bootloader using JLink
# JLinkExe -nogui 1 -commanderscript embed/bootloader_ci/bootloader_flash.jlink
embed/debugger_scripts/jlink/jlink_write.sh $(BOOTLOADER_BUILD_DIR)/bootloader.bin $(BOOTLOADER_START)

erase_firmware_jlink: $(FIRMWARE_BUILD_DIR)/firmware.bin
JLinkExe -nogui 1 -commanderscript embed/debugger_scripts/jlink/wipe_firmware_header.jlink
erase_firmware_jlink:
embed/debugger_scripts/jlink/jlink_erase.sh $(FIRMWARE_P1_START) 0x180000
embed/debugger_scripts/jlink/jlink_erase.sh $(FIRMWARE_P2_START) 0x200000

flash_firmware_jlink: $(FIRMWARE_BUILD_DIR)/firmware.bin ## flash firmware using JLink. file names must end in .bin for JLink
cp -f $<.p1 $<.p1.bin
cp -f $<.p2 $<.p2.bin
JLinkExe -nogui 1 -commanderscript embed/firmware/firmware_flash.jlink

# flash_firmware_t1_jlink: $(FIRMWARE_BUILD_DIR)/firmware.bin ## flash T1 core port via JLink
# JLinkExe -nogui 1 -commanderscript embed/firmware/firmware_flash_t1.jlink

reboot_device_jlink: ## cause a system reset using JLink
JLinkExe -nogui 1 -commanderscript embed/debugger_scripts/jlink/reboot_device.jlink

## openocd debug commands:

openocd: ## start openocd which connects to the device
$(OPENOCD)

openocd_reset: ## cause a system reset using OpenOCD
$(OPENOCD) -c "init; reset; exit"
embed/debugger_scripts/jlink/jlink_write.sh $<.p1.bin $(FIRMWARE_P1_START)
embed/debugger_scripts/jlink/jlink_write.sh $<.p2.bin $(FIRMWARE_P2_START)
rm $<.p1.bin
rm $<.p2.bin

dump_firmware_jlink:
embed/debugger_scripts/jlink/jlink_read.sh $(FIRMWARE_BUILD_DIR)/firmware.readback.p1.bin $(FIRMWARE_P1_START) 0x180000
embed/debugger_scripts/jlink/jlink_read.sh $(FIRMWARE_BUILD_DIR)/firmware.readback.p2.bin $(FIRMWARE_P2_START) 0x200000

jlink_device_reboot: ## cause a system reset using JLink
embed/debugger_scripts/jlink/jlink_rebootDevice.sh 0
jlink_device_enter_board:
embed/debugger_scripts/jlink/jlink_rebootDevice.sh 1
jlink_device_enter_boot:
embed/debugger_scripts/jlink/jlink_rebootDevice.sh 2

GDB = arm-none-eabi-gdb --nx -ex 'set remotetimeout unlimited' -ex 'set confirm off' -ex 'target remote 127.0.0.1:3333' -ex 'monitor reset halt'

Expand Down Expand Up @@ -348,11 +312,5 @@ combine: ## combine boardloader + bootloader + prodtest into one combined image
$(PRODTEST_START) $(PRODTEST_BUILD_DIR)/prodtest.bin \
> $(PRODTEST_BUILD_DIR)/combined.bin

upload: ## upload firmware using trezorctl
trezorctl firmware_update -f $(FIRMWARE_BUILD_DIR)/firmware.bin

upload_prodtest: ## upload prodtest using trezorctl
trezorctl firmware_update -f $(PRODTEST_BUILD_DIR)/prodtest.bin

coverage: # generate coverage report
./tools/coverage-report
89 changes: 7 additions & 82 deletions core/SConscript.boardloader
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ if PRODUCTION_MODEL == 'H':
SOURCE_TREZORHAL = [
'embed/trezorhal/system_stm32h7xx.c',
'embed/trezorhal/common.c',
'embed/trezorhal/mpu.c',
'embed/trezorhal/emmc.c',
'embed/trezorhal/sdram.c',
'embed/trezorhal/qspi_flash.c',
Expand Down Expand Up @@ -127,55 +128,13 @@ if PRODUCTION_MODEL == 'H':
'embed/trezorhal/fatfs/ffunicode.c',
'embed/trezorhal/fatfs/diskio.c',
]
else:
SOURCE_MOD += [
'embed/extmod/modtrezorui/display.c',
'embed/extmod/modtrezorui/fonts/font_bitmap.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_BOARDLOADER = [
'embed/boardloader/startup.s',
'embed/boardloader/main.c',
]

SOURCE_TREZORHAL = [
'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/sdcard.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')))

# fw keys
SOURCE_FW_KEYS = []
SOURCE_FW_KEYS.extend(Glob('embed/fw_keys/fw_keys.c'))

# debug utils
SOURCE_DEBUG_UTILS = []
SOURCE_DEBUG_UTILS.extend(Glob('embed/debug_utils/*.c'))
Expand Down Expand Up @@ -203,10 +162,6 @@ if PRODUCTION_MODEL == 'H':
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -mtune=cortex-m7 --specs=nano.specs '
CPU_MODEL = 'STM32H747xx'
CORE_MODEL = 'CORE_CM7'
elif 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')

Expand Down Expand Up @@ -234,6 +189,7 @@ if PRODUCTION_MODEL == 'H':
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Inc',
'vendor/micropython/lib/stm32lib/CMSIS/STM32H7xx/Include',
'vendor/micropython/lib/cmsis/inc',
'embed/fw_keys',
'embed/debug_utils',
'embed/emmc_wrapper',
] + CPPPATH_MOD,
Expand All @@ -249,38 +205,6 @@ if PRODUCTION_MODEL == 'H':
ASFLAGS=CPU_ASFLAGS,
ASPPFLAGS='$CFLAGS $CCFLAGS', )

else:
LD_FILE = '-T embed/boardloader/memory.ld '
env.Replace(
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
CCFLAGS='$COPT '
'-g3 '
'-nostdlib '
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -Wno-missing-braces -fno-common '
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
'-ffreestanding '
'-fstack-protector-all '
+ CPU_CCFLAGS + CCFLAGS_MOD,
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',
CPPPATH=[
'embed/boardloader',
'embed/trezorhal',
'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',
] + CPPPATH_MOD,
CPPDEFINES=[
'TREZOR_MODEL_'+TREZOR_MODEL,
CPU_MODEL,
'USE_HAL_DRIVER',
('STM32_HAL_H', '"<stm32f4xx.h>"'),
] + CPPDEFINES_MOD,
ASFLAGS=CPU_ASFLAGS,
ASPPFLAGS='$CFLAGS $CCFLAGS', )

#
# Program objects
#
Expand All @@ -290,6 +214,7 @@ obj_program += env.Object(source=SOURCE_MOD)
obj_program += env.Object(source=SOURCE_BOARDLOADER)
obj_program += env.Object(source=SOURCE_STMHAL)
obj_program += env.Object(source=SOURCE_TREZORHAL)
obj_program += env.Object(source=SOURCE_FW_KEYS)
obj_program += env.Object(source=SOURCE_DEBUG_UTILS)
obj_program += env.Object(source=SOURCE_EMMC_WRAPPER)

Expand Down
68 changes: 16 additions & 52 deletions core/SConscript.bootloader
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ if PRODUCTION_MODEL == 'H':
SOURCE_STMHAL = [
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc_ex.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dcmi.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma_ex.c',
Expand Down Expand Up @@ -175,6 +177,8 @@ SOURCE_NANOPB = [

SOURCE_TREZORHAL = [
'embed/trezorhal/system_stm32h7xx.c',
'embed/trezorhal/adc.c',
'embed/trezorhal/hardware_version.c',
'embed/trezorhal/common.c',
'embed/trezorhal/image.c',
'embed/trezorhal/flash.c',
Expand Down Expand Up @@ -228,6 +232,10 @@ if TREZOR_MODEL in ('R'):
if TREZOR_MODEL in ('T',):
SOURCE_TREZORHAL.append('embed/trezorhal/touch.c')

# fw keys
SOURCE_FW_KEYS = []
SOURCE_FW_KEYS.extend(Glob('embed/fw_keys/fw_keys.c'))

# debug utils
SOURCE_DEBUG_UTILS = []
SOURCE_DEBUG_UTILS.extend(Glob('embed/debug_utils/*.c'))
Expand All @@ -251,6 +259,10 @@ env.Replace(
STRIP='arm-none-eabi-strip',
OBJCOPY='arm-none-eabi-objcopy', )

env.Replace(
HEADERTOOL='tools/headertool.py',
)

env.Replace(
TREZOR_MODEL=TREZOR_MODEL,
PRODUCTION_MODEL=ord(PRODUCTION_MODEL), )
Expand All @@ -260,20 +272,6 @@ if PRODUCTION_MODEL == 'H':
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -mtune=cortex-m7 --specs=nano.specs '
CPU_MODEL = 'STM32H747xx'
CORE_MODEL = 'CORE_CM7'
elif 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 ('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'
RUST_TARGET = 'thumbv7m-none-eabi'
else:
raise ValueError('Unknown Trezor model')

if PRODUCTION_MODEL == 'H':
env.Replace(
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
CCFLAGS='$COPT '
Expand All @@ -297,6 +295,7 @@ if PRODUCTION_MODEL == 'H':
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Inc',
'vendor/micropython/lib/stm32lib/CMSIS/STM32H7xx/Include',
'vendor/micropython/lib/cmsis/inc',
'embed/fw_keys',
'embed/debug_utils',
'embed/emmc_wrapper',
'embed/pn532',
Expand All @@ -321,45 +320,9 @@ if PRODUCTION_MODEL == 'H':
] + CPPDEFINES_MOD,
ASFLAGS=CPU_ASFLAGS,
ASPPFLAGS='$CFLAGS $CCFLAGS', )
else:
env.Replace(
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
CCFLAGS='$COPT '
'-g3 '
'-nostdlib '
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -Wno-missing-braces -fno-common '
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
'-ffreestanding '
'-fstack-protector-all '
+ CPU_CCFLAGS + CCFLAGS_MOD,
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',
CPPPATH=[
'embed/bootloader',
'embed/bootloader/nanopb',
'embed/bootloader/protob',
'embed/trezorhal',
'embed/extmod/modtrezorui',
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc',
'vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include',
'vendor/micropython/lib/cmsis/inc',
'vendor/nanopb',
] + CPPPATH_MOD,
CPPDEFINES=[
'TREZOR_MODEL_'+TREZOR_MODEL,
CPU_MODEL,
'USE_HAL_DRIVER',
('STM32_HAL_H', '"<stm32f4xx.h>"'),
'PB_FIELD_16BIT',
'PB_ENCODE_ARRAYS_UNPACKED',
'PB_VALIDATE_UTF8',
] + CPPDEFINES_MOD,
ASFLAGS=CPU_ASFLAGS,
ASPPFLAGS='$CFLAGS $CCFLAGS', )

env.Replace(
HEADERTOOL='tools/headertool.py',
)
else:
raise ValueError('Unknown Trezor model')

#
# Program objects
Expand All @@ -371,6 +334,7 @@ obj_program += env.Object(source=SOURCE_BOOTLOADER)
obj_program += env.Object(source=SOURCE_NANOPB)
obj_program += env.Object(source=SOURCE_STMHAL)
obj_program += env.Object(source=SOURCE_TREZORHAL)
obj_program += env.Object(source=SOURCE_FW_KEYS)
obj_program += env.Object(source=SOURCE_DEBUG_UTILS)
obj_program += env.Object(source=SOURCE_EMMC_WRAPPER)
obj_program += env.Object(source=SOURCE_PN532_WRAPPER)
Expand Down
Loading

0 comments on commit 70ef643

Please sign in to comment.