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

core: preparations for bitcoin-only firmware

This commit is contained in:
Pavol Rusnak 2019-08-21 18:53:08 +02:00
parent 76719bab65
commit 132c841752
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 123 additions and 105 deletions

View File

@ -2,11 +2,14 @@
import os
EVERYTHING = True
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
SOURCE_MOD = []
SOURCE_MOD_SECP256K1_ZKP = []
if EVERYTHING:
SOURCE_MOD_SECP256K1_ZKP = []
PYOPT = ARGUMENTS.get('PYOPT', '1')
FROZEN = True
@ -32,11 +35,11 @@ CPPDEFINES_MOD += [
'AES_192',
'RAND_PLATFORM_INDEPENDENT',
('USE_KECCAK', '1'),
('USE_ETHEREUM', '1'),
('USE_MONERO', '1'),
('USE_CARDANO', '1'),
('USE_NEM', '1'),
('USE_EOS', '1'),
('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'),
]
SOURCE_MOD += [
'embed/extmod/modtrezorcrypto/modtrezorcrypto.c',
@ -71,9 +74,6 @@ SOURCE_MOD += [
'vendor/trezor-crypto/ed25519-donna/ed25519-keccak.c',
'vendor/trezor-crypto/ed25519-donna/ed25519-sha3.c',
'vendor/trezor-crypto/ed25519-donna/modm-donna-32bit.c',
'vendor/trezor-crypto/monero/base58.c',
'vendor/trezor-crypto/monero/serialize.c',
'vendor/trezor-crypto/monero/xmr.c',
'vendor/trezor-crypto/groestl.c',
'vendor/trezor-crypto/hasher.c',
'vendor/trezor-crypto/hmac.c',
@ -91,14 +91,21 @@ SOURCE_MOD += [
'vendor/trezor-crypto/shamir.c',
'vendor/trezor-crypto/slip39.c',
]
if EVERYTHING:
SOURCE_MOD += [
'vendor/trezor-crypto/monero/base58.c',
'vendor/trezor-crypto/monero/serialize.c',
'vendor/trezor-crypto/monero/xmr.c',
]
# libsecp256k1-zkp
CPPPATH_MOD += [
if EVERYTHING:
CPPPATH_MOD += [
'vendor/secp256k1-zkp',
'vendor/secp256k1-zkp/src',
'vendor/secp256k1-zkp/include',
]
CPPDEFINES_MOD += [
]
CPPDEFINES_MOD += [
'SECP256K1_BUILD',
'USE_ASM_ARM',
'USE_NUM_NONE',
@ -114,11 +121,11 @@ CPPDEFINES_MOD += [
'ENABLE_MODULE_RANGEPROOF',
'ENABLE_MODULE_RECOVERY',
'ENABLE_MODULE_ECDH',
]
SOURCE_MOD_SECP256K1_ZKP += [
]
SOURCE_MOD_SECP256K1_ZKP += [
'vendor/secp256k1-zkp/src/secp256k1.c',
'vendor/secp256k1-zkp/src/asm/field_10x26_arm.s'
]
]
# modtrezorio
SOURCE_MOD += [
@ -457,7 +464,7 @@ if FROZEN:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/wallet/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/wallet/*/*.py'))
if True:
if EVERYTHING:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/binance/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Binance*.py'))
@ -508,22 +515,22 @@ if FROZEN:
# static secp256-zkp ecmult context
#
host_env = Environment(ENV=os.environ)
host_env.Replace(
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(
)
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(
)
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',
)
)
#
# Program objects
@ -531,7 +538,8 @@ secp256k1_zkp_ecmult_static_context = host_env.Command(
obj_program = []
obj_program.extend(env.Object(source=SOURCE_MOD))
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
if EVERYTHING:
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
obj_program.extend(env.Object(source=SOURCE_FIRMWARE))
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON))
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON_SPEED, COPT='-O3'))
@ -559,7 +567,8 @@ obj_program.extend(
' $SOURCE $TARGET', ))
env.Depends(obj_program, qstr_generated)
env.Depends(obj_program, secp256k1_zkp_ecmult_static_context)
if EVERYTHING:
env.Depends(obj_program, secp256k1_zkp_ecmult_static_context)
program_elf = env.Command(
target='firmware.elf',

View File

@ -2,11 +2,14 @@
import os
EVERYTHING = True
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
SOURCE_MOD = []
SOURCE_MOD_SECP256K1_ZKP = []
if EVERYTHING:
SOURCE_MOD_SECP256K1_ZKP = []
PYOPT = ARGUMENTS.get('PYOPT', '1')
FROZEN = ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0)
@ -31,11 +34,11 @@ CPPDEFINES_MOD += [
'AES_128',
'AES_192',
('USE_KECCAK', '1'),
('USE_ETHEREUM', '1'),
('USE_MONERO', '1'),
('USE_CARDANO', '1'),
('USE_NEM', '1'),
('USE_EOS', '1'),
('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'),
]
SOURCE_MOD += [
'embed/extmod/modtrezorcrypto/modtrezorcrypto.c',
@ -69,9 +72,6 @@ SOURCE_MOD += [
'vendor/trezor-crypto/ed25519-donna/ed25519-keccak.c',
'vendor/trezor-crypto/ed25519-donna/ed25519-sha3.c',
'vendor/trezor-crypto/ed25519-donna/modm-donna-32bit.c',
'vendor/trezor-crypto/monero/base58.c',
'vendor/trezor-crypto/monero/serialize.c',
'vendor/trezor-crypto/monero/xmr.c',
'vendor/trezor-crypto/groestl.c',
'vendor/trezor-crypto/hasher.c',
'vendor/trezor-crypto/hmac.c',
@ -89,14 +89,21 @@ SOURCE_MOD += [
'vendor/trezor-crypto/shamir.c',
'vendor/trezor-crypto/slip39.c',
]
if EVERYTHING:
SOURCE_MOD += [
'vendor/trezor-crypto/monero/base58.c',
'vendor/trezor-crypto/monero/serialize.c',
'vendor/trezor-crypto/monero/xmr.c',
]
# libsecp256k1-zkp
CPPPATH_MOD += [
if EVERYTHING:
CPPPATH_MOD += [
'vendor/secp256k1-zkp',
'vendor/secp256k1-zkp/src',
'vendor/secp256k1-zkp/include',
]
CPPDEFINES_MOD += [
]
CPPDEFINES_MOD += [
'SECP256K1_BUILD',
'USE_NUM_NONE',
'USE_FIELD_INV_BUILTIN',
@ -110,10 +117,10 @@ CPPDEFINES_MOD += [
'ENABLE_MODULE_RANGEPROOF',
'ENABLE_MODULE_RECOVERY',
'ENABLE_MODULE_ECDH',
]
SOURCE_MOD_SECP256K1_ZKP += [
]
SOURCE_MOD_SECP256K1_ZKP += [
'vendor/secp256k1-zkp/src/secp256k1.c',
]
]
# modtrezorio
SOURCE_MOD += [
@ -420,7 +427,7 @@ if FROZEN:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/wallet/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/wallet/*/*.py'))
if True:
if EVERYTHING:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/binance/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Binance*.py'))
@ -471,22 +478,22 @@ if FROZEN:
# static secp256-zkp ecmult context
#
host_env = Environment(ENV=os.environ)
host_env.Replace(
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(
)
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(
)
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',
)
)
#
# Program objects
@ -494,14 +501,16 @@ secp256k1_zkp_ecmult_static_context = host_env.Command(
obj_program = []
obj_program.extend(env.Object(source=SOURCE_MOD))
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
if EVERYTHING:
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON))
obj_program.extend(env.Object(source=SOURCE_UNIX))
if FROZEN:
obj_program.extend(env.Object(source=source_mpyc))
env.Depends(obj_program, qstr_generated)
env.Depends(obj_program, secp256k1_zkp_ecmult_static_context)
if EVERYTHING:
env.Depends(obj_program, secp256k1_zkp_ecmult_static_context)
program = env.Command(
target='micropython',