2017-08-01 16:50:28 +00:00
|
|
|
# pylint: disable=E0602
|
|
|
|
|
2017-08-07 10:04:23 +00:00
|
|
|
import os
|
|
|
|
|
2019-08-22 18:15:16 +00:00
|
|
|
BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0')
|
|
|
|
EVERYTHING = BITCOIN_ONLY != '1'
|
2019-08-21 16:53:08 +00:00
|
|
|
|
2017-08-01 16:50:28 +00:00
|
|
|
CCFLAGS_MOD = ''
|
|
|
|
CPPPATH_MOD = []
|
|
|
|
CPPDEFINES_MOD = []
|
|
|
|
SOURCE_MOD = []
|
2019-08-21 16:53:08 +00:00
|
|
|
if EVERYTHING:
|
|
|
|
SOURCE_MOD_SECP256K1_ZKP = []
|
2017-08-01 16:50:28 +00:00
|
|
|
|
2019-08-21 16:04:15 +00:00
|
|
|
PYOPT = ARGUMENTS.get('PYOPT', '1')
|
|
|
|
FROZEN = True
|
2018-02-08 17:04:10 +00:00
|
|
|
|
2017-08-01 16:50:28 +00:00
|
|
|
# modtrezorconfig
|
2019-01-24 15:17:37 +00:00
|
|
|
CPPPATH_MOD += [
|
|
|
|
'embed/extmod/modtrezorconfig',
|
|
|
|
'vendor/trezor-storage',
|
|
|
|
]
|
2017-08-01 16:50:28 +00:00
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorconfig/modtrezorconfig.c',
|
2019-01-24 15:17:37 +00:00
|
|
|
'vendor/trezor-storage/norcow.c',
|
|
|
|
'vendor/trezor-storage/storage.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# modtrezorcrypto
|
|
|
|
CCFLAGS_MOD += '-Wno-sequence-point '
|
|
|
|
CPPPATH_MOD += [
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto',
|
2017-08-01 16:50:28 +00:00
|
|
|
]
|
|
|
|
CPPDEFINES_MOD += [
|
|
|
|
'AES_128',
|
|
|
|
'AES_192',
|
2018-01-13 14:28:35 +00:00
|
|
|
'RAND_PLATFORM_INDEPENDENT',
|
2017-12-23 14:12:31 +00:00
|
|
|
('USE_KECCAK', '1'),
|
2019-08-21 16:53:08 +00:00
|
|
|
('USE_ETHEREUM', '1' if EVERYTHING else '0'),
|
|
|
|
('USE_MONERO', '1' if EVERYTHING else '0'),
|
|
|
|
('USE_CARDANO', '1' if EVERYTHING else '0'),
|
|
|
|
('USE_NEM', '1' if EVERYTHING else '0'),
|
|
|
|
('USE_EOS', '1' if EVERYTHING else '0'),
|
2017-08-01 16:50:28 +00:00
|
|
|
]
|
|
|
|
SOURCE_MOD += [
|
2017-12-19 20:54:22 +00:00
|
|
|
'embed/extmod/modtrezorcrypto/crc.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'embed/extmod/modtrezorcrypto/modtrezorcrypto.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
'embed/extmod/modtrezorcrypto/rand.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/address.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'vendor/trezor-crypto/aes/aes_modes.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/aes/aescrypt.c',
|
|
|
|
'vendor/trezor-crypto/aes/aeskey.c',
|
|
|
|
'vendor/trezor-crypto/aes/aestab.c',
|
2018-03-09 10:37:06 +00:00
|
|
|
'vendor/trezor-crypto/base32.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'vendor/trezor-crypto/base58.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/bignum.c',
|
|
|
|
'vendor/trezor-crypto/bip32.c',
|
|
|
|
'vendor/trezor-crypto/bip39.c',
|
2017-12-12 21:00:15 +00:00
|
|
|
'vendor/trezor-crypto/blake256.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/blake2b.c',
|
|
|
|
'vendor/trezor-crypto/blake2s.c',
|
2018-01-02 17:57:23 +00:00
|
|
|
'vendor/trezor-crypto/chacha20poly1305/chacha20poly1305.c',
|
|
|
|
'vendor/trezor-crypto/chacha20poly1305/chacha_merged.c',
|
|
|
|
'vendor/trezor-crypto/chacha20poly1305/poly1305-donna.c',
|
|
|
|
'vendor/trezor-crypto/chacha20poly1305/rfc7539.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'vendor/trezor-crypto/curves.c',
|
|
|
|
'vendor/trezor-crypto/ecdsa.c',
|
2017-12-12 21:00:15 +00:00
|
|
|
'vendor/trezor-crypto/ed25519-donna/curve25519-donna-32bit.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/curve25519-donna-helpers.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/curve25519-donna-scalarmult-base.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519-donna-32bit-tables.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519-donna-basepoint-table.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519-donna-impl-base.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519-keccak.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519-sha3.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519.c',
|
2017-12-12 21:00:15 +00:00
|
|
|
'vendor/trezor-crypto/ed25519-donna/modm-donna-32bit.c',
|
2018-06-15 08:31:21 +00:00
|
|
|
'vendor/trezor-crypto/groestl.c',
|
2017-12-12 21:00:15 +00:00
|
|
|
'vendor/trezor-crypto/hasher.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/hmac.c',
|
2019-06-07 10:16:24 +00:00
|
|
|
'vendor/trezor-crypto/hmac_drbg.c',
|
2018-01-18 14:26:22 +00:00
|
|
|
'vendor/trezor-crypto/memzero.c',
|
2018-03-09 10:37:06 +00:00
|
|
|
'vendor/trezor-crypto/nem.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/nist256p1.c',
|
|
|
|
'vendor/trezor-crypto/pbkdf2.c',
|
2018-01-13 14:28:35 +00:00
|
|
|
'vendor/trezor-crypto/rand.c',
|
2019-06-07 10:16:24 +00:00
|
|
|
'vendor/trezor-crypto/rfc6979.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'vendor/trezor-crypto/ripemd160.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/secp256k1.c',
|
|
|
|
'vendor/trezor-crypto/sha2.c',
|
|
|
|
'vendor/trezor-crypto/sha3.c',
|
2019-04-17 09:26:16 +00:00
|
|
|
'vendor/trezor-crypto/shamir.c',
|
2019-06-23 10:18:24 +00:00
|
|
|
'vendor/trezor-crypto/slip39.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
]
|
2019-08-21 16:53:08 +00:00
|
|
|
if EVERYTHING:
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'vendor/trezor-crypto/monero/base58.c',
|
|
|
|
'vendor/trezor-crypto/monero/serialize.c',
|
|
|
|
'vendor/trezor-crypto/monero/xmr.c',
|
|
|
|
]
|
2017-08-01 16:50:28 +00:00
|
|
|
|
2019-04-02 15:13:03 +00:00
|
|
|
# libsecp256k1-zkp
|
2019-08-21 16:53:08 +00:00
|
|
|
if EVERYTHING:
|
|
|
|
CPPPATH_MOD += [
|
|
|
|
'vendor/secp256k1-zkp',
|
|
|
|
'vendor/secp256k1-zkp/src',
|
|
|
|
'vendor/secp256k1-zkp/include',
|
|
|
|
]
|
|
|
|
CPPDEFINES_MOD += [
|
|
|
|
'SECP256K1_BUILD',
|
|
|
|
'USE_ASM_ARM',
|
|
|
|
'USE_NUM_NONE',
|
|
|
|
'USE_FIELD_INV_BUILTIN',
|
|
|
|
'USE_SCALAR_INV_BUILTIN',
|
|
|
|
'USE_EXTERNAL_ASM',
|
|
|
|
'USE_FIELD_10X26',
|
|
|
|
'USE_SCALAR_8X32',
|
|
|
|
'USE_ECMULT_STATIC_PRECOMPUTATION',
|
|
|
|
'USE_EXTERNAL_DEFAULT_CALLBACKS',
|
|
|
|
('ECMULT_WINDOW_SIZE', '8'),
|
|
|
|
'ENABLE_MODULE_GENERATOR',
|
|
|
|
'ENABLE_MODULE_RANGEPROOF',
|
|
|
|
'ENABLE_MODULE_RECOVERY',
|
|
|
|
'ENABLE_MODULE_ECDH',
|
|
|
|
]
|
|
|
|
SOURCE_MOD_SECP256K1_ZKP += [
|
|
|
|
'vendor/secp256k1-zkp/src/secp256k1.c',
|
|
|
|
'vendor/secp256k1-zkp/src/asm/field_10x26_arm.s'
|
|
|
|
]
|
2019-04-02 15:13:03 +00:00
|
|
|
|
2017-08-01 16:50:28 +00:00
|
|
|
# modtrezorio
|
|
|
|
SOURCE_MOD += [
|
2019-06-17 18:09:58 +00:00
|
|
|
'embed/extmod/modtrezorio/ff.c',
|
2019-06-23 13:58:33 +00:00
|
|
|
'embed/extmod/modtrezorio/ffunicode.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
'embed/extmod/modtrezorio/modtrezorio.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
# modtrezorui
|
2017-12-15 22:13:25 +00:00
|
|
|
CPPDEFINES_MOD += [
|
|
|
|
'TREZOR_FONT_BOLD_ENABLE',
|
|
|
|
'TREZOR_FONT_NORMAL_ENABLE',
|
2018-08-16 18:59:24 +00:00
|
|
|
'TREZOR_FONT_MONO_ENABLE',
|
|
|
|
'TREZOR_FONT_MONO_BOLD_ENABLE',
|
2017-12-15 22:13:25 +00:00
|
|
|
]
|
2017-08-01 16:50:28 +00:00
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorui/display.c',
|
|
|
|
'embed/extmod/modtrezorui/font_bitmap.c',
|
|
|
|
'embed/extmod/modtrezorui/font_roboto_bold_20.c',
|
|
|
|
'embed/extmod/modtrezorui/font_roboto_regular_20.c',
|
2018-08-16 18:59:24 +00:00
|
|
|
'embed/extmod/modtrezorui/font_robotomono_bold_20.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
'embed/extmod/modtrezorui/font_robotomono_regular_20.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'embed/extmod/modtrezorui/inflate.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
'embed/extmod/modtrezorui/modtrezorui.c',
|
2019-02-16 16:36:08 +00:00
|
|
|
'embed/extmod/modtrezorui/qr-code-generator/qrcodegen.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# modtrezorutils
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorutils/modtrezorutils.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
# modutime
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/firmware/modutime.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
SOURCE_MICROPYTHON = [
|
|
|
|
'vendor/micropython/extmod/modubinascii.c',
|
|
|
|
'vendor/micropython/extmod/moductypes.c',
|
|
|
|
'vendor/micropython/extmod/moduheapq.c',
|
|
|
|
'vendor/micropython/extmod/modutimeq.c',
|
|
|
|
'vendor/micropython/extmod/utime_mphal.c',
|
|
|
|
'vendor/micropython/lib/embed/abort_.c',
|
|
|
|
'vendor/micropython/lib/mp-readline/readline.c',
|
|
|
|
'vendor/micropython/lib/utils/interrupt_char.c',
|
|
|
|
'vendor/micropython/lib/utils/printf.c',
|
|
|
|
'vendor/micropython/lib/utils/pyexec.c',
|
|
|
|
'vendor/micropython/lib/utils/stdout_helpers.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'vendor/micropython/ports/stm32/gccollect.c',
|
|
|
|
'vendor/micropython/ports/stm32/gchelper.s',
|
|
|
|
'vendor/micropython/ports/stm32/pendsv.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
'vendor/micropython/py/argcheck.c',
|
|
|
|
'vendor/micropython/py/asmarm.c',
|
|
|
|
'vendor/micropython/py/asmbase.c',
|
|
|
|
'vendor/micropython/py/asmthumb.c',
|
|
|
|
'vendor/micropython/py/asmx64.c',
|
|
|
|
'vendor/micropython/py/asmx86.c',
|
|
|
|
'vendor/micropython/py/asmxtensa.c',
|
|
|
|
'vendor/micropython/py/bc.c',
|
|
|
|
'vendor/micropython/py/binary.c',
|
|
|
|
'vendor/micropython/py/builtinevex.c',
|
|
|
|
'vendor/micropython/py/builtinhelp.c',
|
|
|
|
'vendor/micropython/py/builtinimport.c',
|
|
|
|
'vendor/micropython/py/compile.c',
|
|
|
|
'vendor/micropython/py/emitbc.c',
|
|
|
|
'vendor/micropython/py/emitcommon.c',
|
|
|
|
'vendor/micropython/py/emitglue.c',
|
|
|
|
'vendor/micropython/py/emitinlinethumb.c',
|
|
|
|
'vendor/micropython/py/emitinlinextensa.c',
|
|
|
|
'vendor/micropython/py/formatfloat.c',
|
|
|
|
'vendor/micropython/py/frozenmod.c',
|
|
|
|
'vendor/micropython/py/lexer.c',
|
|
|
|
'vendor/micropython/py/malloc.c',
|
|
|
|
'vendor/micropython/py/map.c',
|
|
|
|
'vendor/micropython/py/modarray.c',
|
|
|
|
'vendor/micropython/py/modbuiltins.c',
|
|
|
|
'vendor/micropython/py/modgc.c',
|
|
|
|
'vendor/micropython/py/modmath.c',
|
|
|
|
'vendor/micropython/py/modmicropython.c',
|
|
|
|
'vendor/micropython/py/modstruct.c',
|
|
|
|
'vendor/micropython/py/modsys.c',
|
|
|
|
'vendor/micropython/py/mpprint.c',
|
|
|
|
'vendor/micropython/py/mpstate.c',
|
|
|
|
'vendor/micropython/py/mpz.c',
|
|
|
|
'vendor/micropython/py/nativeglue.c',
|
|
|
|
'vendor/micropython/py/obj.c',
|
|
|
|
'vendor/micropython/py/objarray.c',
|
|
|
|
'vendor/micropython/py/objattrtuple.c',
|
|
|
|
'vendor/micropython/py/objbool.c',
|
|
|
|
'vendor/micropython/py/objboundmeth.c',
|
|
|
|
'vendor/micropython/py/objcell.c',
|
|
|
|
'vendor/micropython/py/objclosure.c',
|
|
|
|
'vendor/micropython/py/objcomplex.c',
|
|
|
|
'vendor/micropython/py/objdict.c',
|
|
|
|
'vendor/micropython/py/objenumerate.c',
|
|
|
|
'vendor/micropython/py/objexcept.c',
|
|
|
|
'vendor/micropython/py/objfilter.c',
|
|
|
|
'vendor/micropython/py/objfloat.c',
|
|
|
|
'vendor/micropython/py/objfun.c',
|
|
|
|
'vendor/micropython/py/objgenerator.c',
|
|
|
|
'vendor/micropython/py/objgetitemiter.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/objint.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
'vendor/micropython/py/objint_longlong.c',
|
|
|
|
'vendor/micropython/py/objint_mpz.c',
|
|
|
|
'vendor/micropython/py/objlist.c',
|
|
|
|
'vendor/micropython/py/objmap.c',
|
|
|
|
'vendor/micropython/py/objmodule.c',
|
|
|
|
'vendor/micropython/py/objnamedtuple.c',
|
|
|
|
'vendor/micropython/py/objnone.c',
|
|
|
|
'vendor/micropython/py/objobject.c',
|
|
|
|
'vendor/micropython/py/objpolyiter.c',
|
|
|
|
'vendor/micropython/py/objproperty.c',
|
|
|
|
'vendor/micropython/py/objrange.c',
|
|
|
|
'vendor/micropython/py/objreversed.c',
|
|
|
|
'vendor/micropython/py/objset.c',
|
|
|
|
'vendor/micropython/py/objsingleton.c',
|
|
|
|
'vendor/micropython/py/objslice.c',
|
|
|
|
'vendor/micropython/py/objstr.c',
|
|
|
|
'vendor/micropython/py/objstringio.c',
|
|
|
|
'vendor/micropython/py/objstrunicode.c',
|
|
|
|
'vendor/micropython/py/objtuple.c',
|
|
|
|
'vendor/micropython/py/objtype.c',
|
|
|
|
'vendor/micropython/py/objzip.c',
|
|
|
|
'vendor/micropython/py/opmethods.c',
|
|
|
|
'vendor/micropython/py/parse.c',
|
|
|
|
'vendor/micropython/py/parsenum.c',
|
|
|
|
'vendor/micropython/py/parsenumbase.c',
|
|
|
|
'vendor/micropython/py/persistentcode.c',
|
|
|
|
'vendor/micropython/py/qstr.c',
|
|
|
|
'vendor/micropython/py/reader.c',
|
|
|
|
'vendor/micropython/py/repl.c',
|
|
|
|
'vendor/micropython/py/runtime.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/runtime_utils.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
'vendor/micropython/py/scope.c',
|
|
|
|
'vendor/micropython/py/sequence.c',
|
|
|
|
'vendor/micropython/py/showbc.c',
|
|
|
|
'vendor/micropython/py/smallint.c',
|
|
|
|
'vendor/micropython/py/stackctrl.c',
|
|
|
|
'vendor/micropython/py/stream.c',
|
|
|
|
'vendor/micropython/py/unicode.c',
|
|
|
|
'vendor/micropython/py/vstr.c',
|
|
|
|
'vendor/micropython/py/warning.c',
|
|
|
|
]
|
|
|
|
|
2017-08-15 19:04:12 +00:00
|
|
|
SOURCE_MICROPYTHON_SPEED = [
|
|
|
|
'vendor/micropython/py/gc.c',
|
|
|
|
'vendor/micropython/py/vm.c',
|
|
|
|
]
|
|
|
|
|
2017-08-01 16:50:28 +00:00
|
|
|
SOURCE_STMHAL = [
|
2019-09-03 16:15:47 +00:00
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c',
|
2017-09-06 17:15:59 +00:00
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c',
|
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c',
|
2017-09-06 17:15:59 +00:00
|
|
|
'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',
|
2019-09-03 16:15:47 +00:00
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c',
|
2017-09-06 17:15:59 +00:00
|
|
|
'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',
|
2018-09-26 17:34:05 +00:00
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c',
|
2017-09-06 17:15:59 +00:00
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c',
|
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c',
|
2017-10-11 17:18:56 +00:00
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c',
|
2017-09-06 17:15:59 +00:00
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c',
|
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
SOURCE_FIRMWARE = [
|
2019-02-18 15:59:06 +00:00
|
|
|
'embed/firmware/bl_check.c',
|
2017-08-03 22:45:32 +00:00
|
|
|
'embed/firmware/header.S',
|
2017-08-01 16:50:28 +00:00
|
|
|
'embed/firmware/main.c',
|
|
|
|
'embed/firmware/mphalport.c',
|
2017-12-13 01:04:48 +00:00
|
|
|
'embed/firmware/nlrthumb.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'embed/firmware/startup.s',
|
2017-08-01 16:50:28 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
SOURCE_TREZORHAL = [
|
|
|
|
'embed/trezorhal/common.c',
|
|
|
|
'embed/trezorhal/flash.c',
|
|
|
|
'embed/trezorhal/mini_printf.c',
|
2018-02-23 18:08:34 +00:00
|
|
|
'embed/trezorhal/mpu.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
'embed/trezorhal/rng.c',
|
2017-09-07 21:50:57 +00:00
|
|
|
'embed/trezorhal/sbu.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
'embed/trezorhal/sdcard.c',
|
2017-10-11 16:43:39 +00:00
|
|
|
'embed/trezorhal/stm32.c',
|
2018-02-23 18:35:40 +00:00
|
|
|
'embed/trezorhal/systick.c',
|
2017-08-01 16:50:28 +00:00
|
|
|
'embed/trezorhal/touch.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',
|
2017-10-09 15:45:45 +00:00
|
|
|
'embed/trezorhal/util.s',
|
|
|
|
'embed/trezorhal/vectortable.s',
|
2017-08-01 16:50:28 +00:00
|
|
|
]
|
|
|
|
|
2017-08-15 19:04:12 +00:00
|
|
|
SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED
|
2017-08-01 16:50:28 +00:00
|
|
|
|
2019-08-22 18:15:16 +00:00
|
|
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s -DPYOPT=%s -DBITCOIN_ONLY=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'), PYOPT, BITCOIN_ONLY))
|
2017-08-03 18:46:40 +00:00
|
|
|
|
|
|
|
env.Tool('micropython')
|
|
|
|
|
|
|
|
env.Replace(
|
2018-06-20 12:55:30 +00:00
|
|
|
CAT='cat',
|
2018-07-05 20:42:46 +00:00
|
|
|
DD='dd',
|
2017-08-01 16:50:28 +00:00
|
|
|
SED='sed',
|
|
|
|
AS='arm-none-eabi-as',
|
|
|
|
AR='arm-none-eabi-ar',
|
|
|
|
CC='arm-none-eabi-gcc',
|
2018-02-17 15:19:16 +00:00
|
|
|
LINK='arm-none-eabi-gcc',
|
2017-08-01 16:50:28 +00:00
|
|
|
SIZE='arm-none-eabi-size',
|
|
|
|
STRIP='arm-none-eabi-strip',
|
2017-08-03 18:46:40 +00:00
|
|
|
OBJCOPY='arm-none-eabi-objcopy', )
|
|
|
|
|
|
|
|
env.Replace(
|
2018-09-30 14:39:40 +00:00
|
|
|
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
|
|
|
|
|
|
|
|
if env.get('TREZOR_MODEL') == 'T':
|
|
|
|
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
|
|
|
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
|
|
|
CPU_MODEL = 'STM32F427xx'
|
|
|
|
else:
|
|
|
|
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
|
|
|
|
CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
|
|
|
|
CPU_MODEL = 'STM32F405xx'
|
|
|
|
|
|
|
|
env.Replace(
|
2018-07-09 18:59:35 +00:00
|
|
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
2017-08-15 19:04:12 +00:00
|
|
|
CCFLAGS='$COPT '
|
2017-08-01 16:50:28 +00:00
|
|
|
'-g3 '
|
|
|
|
'-nostdlib '
|
2019-10-11 07:59:32 +00:00
|
|
|
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -Wno-missing-braces -fno-common '
|
2017-10-13 21:21:09 +00:00
|
|
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
2018-01-17 14:24:06 +00:00
|
|
|
'-ffreestanding '
|
2017-12-13 01:04:48 +00:00
|
|
|
'-fstack-protector-all '
|
2018-09-30 14:39:40 +00:00
|
|
|
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
2017-08-03 19:22:02 +00:00
|
|
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
2019-08-22 18:15:16 +00:00
|
|
|
LINKFLAGS='-T embed/firmware/memory_${TREZOR_MODEL}%s.ld -Wl,--gc-sections -Wl,-Map=build/firmware/firmware.map -Wl,--warn-common' % ('' if EVERYTHING else '_min'),
|
2017-08-01 16:50:28 +00:00
|
|
|
CPPPATH=[
|
2017-08-03 22:45:32 +00:00
|
|
|
'.',
|
2017-08-01 16:50:28 +00:00
|
|
|
'embed/firmware',
|
|
|
|
'embed/trezorhal',
|
|
|
|
'embed/extmod/modtrezorui',
|
|
|
|
'vendor/micropython',
|
2017-09-06 17:15:59 +00:00
|
|
|
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc',
|
|
|
|
'vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include',
|
2017-08-01 16:50:28 +00:00
|
|
|
'vendor/micropython/lib/cmsis/inc',
|
|
|
|
] + CPPPATH_MOD,
|
|
|
|
CPPDEFINES=[
|
2018-09-20 11:43:44 +00:00
|
|
|
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
2018-09-30 14:39:40 +00:00
|
|
|
CPU_MODEL,
|
2017-11-05 15:57:31 +00:00
|
|
|
'USE_HAL_DRIVER',
|
|
|
|
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
2017-08-03 22:45:32 +00:00
|
|
|
] + CPPDEFINES_MOD,
|
2018-09-30 14:39:40 +00:00
|
|
|
ASFLAGS=CPU_ASFLAGS,
|
2017-08-03 22:45:32 +00:00
|
|
|
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
2017-08-03 18:46:40 +00:00
|
|
|
|
|
|
|
env.Replace(
|
2017-10-26 22:41:22 +00:00
|
|
|
BINCTL='tools/binctl',
|
2018-01-29 14:02:32 +00:00
|
|
|
KEYCTL='tools/keyctl',
|
2017-08-01 16:50:28 +00:00
|
|
|
PYTHON='python',
|
|
|
|
MAKEQSTRDATA='$PYTHON vendor/micropython/py/makeqstrdata.py',
|
|
|
|
MAKEVERSIONHDR='$PYTHON vendor/micropython/py/makeversionhdr.py',
|
|
|
|
MPY_TOOL='$PYTHON vendor/micropython/tools/mpy-tool.py',
|
2018-02-08 17:04:10 +00:00
|
|
|
MPY_CROSS='vendor/micropython/mpy-cross/mpy-cross -O' + PYOPT
|
2017-10-25 20:51:38 +00:00
|
|
|
)
|
2017-08-01 16:50:28 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Micropython version
|
|
|
|
#
|
|
|
|
|
|
|
|
hdr_version = env.Command(
|
|
|
|
target='genhdr/mpversion.h',
|
|
|
|
source='',
|
|
|
|
action='$MAKEVERSIONHDR $TARGET', )
|
|
|
|
|
|
|
|
#
|
|
|
|
# Qstrings
|
|
|
|
#
|
|
|
|
|
2017-08-02 21:42:04 +00:00
|
|
|
qstr_micropython = 'vendor/micropython/py/qstrdefs.h'
|
|
|
|
|
2017-08-01 16:50:28 +00:00
|
|
|
qstr_collected = env.CollectQstr(
|
2017-08-03 18:46:40 +00:00
|
|
|
target='genhdr/qstrdefs.collected.h', source=SOURCE_QSTR)
|
2017-08-01 16:50:28 +00:00
|
|
|
|
|
|
|
qstr_preprocessed = env.PreprocessQstr(
|
|
|
|
target='genhdr/qstrdefs.preprocessed.h',
|
2017-08-02 21:42:04 +00:00
|
|
|
source=[qstr_micropython, qstr_collected])
|
2017-08-01 16:50:28 +00:00
|
|
|
|
|
|
|
qstr_generated = env.GenerateQstrDefs(
|
2017-08-03 18:46:40 +00:00
|
|
|
target='genhdr/qstrdefs.generated.h', source=qstr_preprocessed)
|
2017-08-01 16:50:28 +00:00
|
|
|
|
|
|
|
env.Ignore(qstr_collected, qstr_generated)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Frozen modules
|
|
|
|
#
|
|
|
|
|
2019-08-21 16:04:15 +00:00
|
|
|
if FROZEN:
|
2019-05-01 11:39:44 +00:00
|
|
|
if env.get('TREZOR_MODEL') == '1':
|
|
|
|
SOURCE_PY_DIR = 'src1/'
|
|
|
|
else:
|
|
|
|
SOURCE_PY_DIR = 'src/'
|
2018-10-02 15:32:38 +00:00
|
|
|
|
2019-05-01 11:39:44 +00:00
|
|
|
SOURCE_PY = Glob(SOURCE_PY_DIR + '*.py')
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/crypto/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/res/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/wire/*.py'))
|
|
|
|
|
2019-11-11 14:52:46 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'storage/*.py'))
|
|
|
|
|
2019-08-21 16:45:07 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/*.py',
|
|
|
|
exclude=[
|
|
|
|
SOURCE_PY_DIR + 'trezor/messages/Binance*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/messages/Cardano*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/messages/DebugMonero*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/messages/Eos*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/messages/Ethereum*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/messages/Lisk*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/messages/Monero*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/messages/NEM*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/messages/Ripple*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/messages/Stellar*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/messages/Tezos*.py',
|
|
|
|
])
|
|
|
|
)
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/common/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/common/*/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/debug/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/homescreen/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/wallet/*.py'))
|
2019-08-26 11:48:41 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/wallet/*/*.py',
|
|
|
|
exclude=[
|
|
|
|
SOURCE_PY_DIR + 'apps/wallet/sign_tx/decred.py',
|
|
|
|
SOURCE_PY_DIR + 'apps/wallet/sign_tx/zcash.py',
|
|
|
|
])
|
|
|
|
)
|
2019-08-21 09:15:33 +00:00
|
|
|
|
2019-08-21 16:53:08 +00:00
|
|
|
if EVERYTHING:
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/binance/*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Binance*.py'))
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/cardano/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/cardano/*/*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Cardano*.py'))
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/eos/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/eos/*/*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Eos*.py'))
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/ethereum/*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Ethereum*.py'))
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/lisk/*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Lisk*.py'))
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/monero/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/monero/*/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/monero/*/*/*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/DebugMonero*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Monero*.py'))
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/nem/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/nem/*/*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/NEM*.py'))
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/ripple/*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Ripple*.py'))
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/stellar/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/stellar/*/*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Stellar*.py'))
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/tezos/*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Tezos*.py'))
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/webauthn/*.py'))
|
2018-10-02 15:32:38 +00:00
|
|
|
|
2019-08-26 11:48:41 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/wallet/sign_tx/decred.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/wallet/sign_tx/zcash.py'))
|
|
|
|
|
2019-08-22 18:15:16 +00:00
|
|
|
source_mpy = env.FrozenModule(source=SOURCE_PY, source_dir=SOURCE_PY_DIR, bitcoin_only=BITCOIN_ONLY)
|
2017-08-01 16:50:28 +00:00
|
|
|
|
2019-05-01 11:39:44 +00:00
|
|
|
source_mpyc = env.FrozenCFile(
|
|
|
|
target='frozen_mpy.c', source=source_mpy, qstr_header=qstr_preprocessed)
|
2017-08-01 16:50:28 +00:00
|
|
|
|
2019-05-01 11:39:44 +00:00
|
|
|
env.Depends(source_mpyc, qstr_generated)
|
2017-08-01 16:50:28 +00:00
|
|
|
|
2019-04-02 15:13:03 +00:00
|
|
|
#
|
|
|
|
# static secp256-zkp ecmult context
|
|
|
|
#
|
|
|
|
|
2019-08-21 16:53:08 +00:00
|
|
|
if EVERYTHING:
|
|
|
|
host_env = Environment(ENV=os.environ)
|
|
|
|
host_env.Replace(
|
|
|
|
CC=os.getenv('CC_FOR_BUILD') or 'gcc',
|
|
|
|
COPT='-O2',
|
|
|
|
CPPPATH='vendor/secp256k1-zkp',
|
|
|
|
)
|
|
|
|
gen_context = host_env.Program(
|
|
|
|
target='vendor/secp256k1-zkp/gen_context',
|
|
|
|
source='vendor/secp256k1-zkp/src/gen_context.c',
|
|
|
|
)
|
|
|
|
secp256k1_zkp_ecmult_static_context = host_env.Command(
|
|
|
|
target='vendor/secp256k1-zkp/src/ecmult_static_context.h',
|
|
|
|
source='vendor/secp256k1-zkp/gen_context',
|
|
|
|
action='cd ${SOURCE.dir}; ./gen_context',
|
|
|
|
)
|
2019-04-02 15:13:03 +00:00
|
|
|
|
2017-08-01 16:50:28 +00:00
|
|
|
#
|
|
|
|
# Program objects
|
|
|
|
#
|
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
obj_program = []
|
2017-08-05 08:17:16 +00:00
|
|
|
obj_program.extend(env.Object(source=SOURCE_MOD))
|
2019-08-21 16:53:08 +00:00
|
|
|
if EVERYTHING:
|
|
|
|
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
|
2017-08-05 08:17:16 +00:00
|
|
|
obj_program.extend(env.Object(source=SOURCE_FIRMWARE))
|
|
|
|
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON))
|
2017-08-15 19:04:12 +00:00
|
|
|
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON_SPEED, COPT='-O3'))
|
2017-08-05 08:17:16 +00:00
|
|
|
obj_program.extend(env.Object(source=SOURCE_STMHAL))
|
|
|
|
obj_program.extend(env.Object(source=SOURCE_TREZORHAL))
|
2019-08-21 16:04:15 +00:00
|
|
|
if FROZEN:
|
2019-05-01 11:39:44 +00:00
|
|
|
obj_program.extend(env.Object(source=source_mpyc))
|
2017-08-05 08:17:16 +00:00
|
|
|
|
2018-02-08 15:45:23 +00:00
|
|
|
VENDORHEADER = 'embed/vendorheader/vendorheader_' + ('unsafe_signed_prod.bin' if ARGUMENTS.get('PRODUCTION', '0') == '0' else 'satoshilabs_signed_prod.bin')
|
2018-01-31 13:45:02 +00:00
|
|
|
|
2017-08-05 08:17:16 +00:00
|
|
|
obj_program.extend(
|
|
|
|
env.Command(
|
|
|
|
target='embed/firmware/vendorheader.o',
|
2018-01-31 13:45:02 +00:00
|
|
|
source=VENDORHEADER,
|
2017-08-05 08:17:16 +00:00
|
|
|
action='$OBJCOPY -I binary -O elf32-littlearm -B arm'
|
|
|
|
' --rename-section .data=.vendorheader,alloc,load,readonly,contents'
|
|
|
|
' $SOURCE $TARGET', ))
|
2017-08-03 22:45:32 +00:00
|
|
|
|
2019-02-18 15:59:06 +00:00
|
|
|
obj_program.extend(
|
|
|
|
env.Command(
|
|
|
|
target='embed/firmware/bootloader.o',
|
|
|
|
source='embed/firmware/bootloader.bin',
|
|
|
|
action='$OBJCOPY -I binary -O elf32-littlearm -B arm'
|
|
|
|
' --rename-section .data=.bootloader'
|
|
|
|
' $SOURCE $TARGET', ))
|
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
env.Depends(obj_program, qstr_generated)
|
2019-08-21 16:53:08 +00:00
|
|
|
if EVERYTHING:
|
|
|
|
env.Depends(obj_program, secp256k1_zkp_ecmult_static_context)
|
2017-08-01 16:50:28 +00:00
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
program_elf = env.Command(
|
2017-08-01 16:50:28 +00:00
|
|
|
target='firmware.elf',
|
2017-08-03 18:46:40 +00:00
|
|
|
source=obj_program,
|
2017-08-01 16:50:28 +00:00
|
|
|
action=
|
2018-02-17 15:19:16 +00:00
|
|
|
'$LINK -o $TARGET $CCFLAGS $CFLAGS $LINKFLAGS $SOURCES -lc_nano -lm -lgcc',
|
2017-08-01 16:50:28 +00:00
|
|
|
)
|
|
|
|
|
2018-09-20 14:37:36 +00:00
|
|
|
if env.get('TREZOR_MODEL') == 'T':
|
|
|
|
action_bin=[
|
2018-06-20 12:55:30 +00:00
|
|
|
'$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',
|
|
|
|
'$CAT ${TARGET}.p1 ${TARGET}.p2 > $TARGET',
|
2017-10-26 01:08:18 +00:00
|
|
|
'$BINCTL $TARGET -h',
|
2018-01-30 14:32:53 +00:00
|
|
|
'$BINCTL $TARGET -s 1:2 `$KEYCTL sign firmware $TARGET 4747474747474747474747474747474747474747474747474747474747474747 4848484848484848484848484848484848484848484848484848484848484848`' if ARGUMENTS.get('PRODUCTION', '0') == '0' else '',
|
2018-07-11 13:15:07 +00:00
|
|
|
'$DD if=$TARGET of=${TARGET}.p1 skip=0 bs=128k count=6',
|
2018-09-20 14:37:36 +00:00
|
|
|
]
|
|
|
|
else:
|
|
|
|
action_bin=[
|
|
|
|
'$OBJCOPY -O binary -j .flash -j .data $SOURCE $TARGET',
|
|
|
|
]
|
|
|
|
|
|
|
|
program_bin = env.Command(
|
|
|
|
target='firmware.bin',
|
|
|
|
source=program_elf,
|
|
|
|
action=action_bin,
|
|
|
|
)
|