mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-17 20:18:10 +00:00
core: preparations for bitcoin-only firmware
This commit is contained in:
parent
76719bab65
commit
132c841752
@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
EVERYTHING = True
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
SOURCE_MOD = []
|
SOURCE_MOD = []
|
||||||
SOURCE_MOD_SECP256K1_ZKP = []
|
if EVERYTHING:
|
||||||
|
SOURCE_MOD_SECP256K1_ZKP = []
|
||||||
|
|
||||||
PYOPT = ARGUMENTS.get('PYOPT', '1')
|
PYOPT = ARGUMENTS.get('PYOPT', '1')
|
||||||
FROZEN = True
|
FROZEN = True
|
||||||
@ -32,11 +35,11 @@ CPPDEFINES_MOD += [
|
|||||||
'AES_192',
|
'AES_192',
|
||||||
'RAND_PLATFORM_INDEPENDENT',
|
'RAND_PLATFORM_INDEPENDENT',
|
||||||
('USE_KECCAK', '1'),
|
('USE_KECCAK', '1'),
|
||||||
('USE_ETHEREUM', '1'),
|
('USE_ETHEREUM', '1' if EVERYTHING else '0'),
|
||||||
('USE_MONERO', '1'),
|
('USE_MONERO', '1' if EVERYTHING else '0'),
|
||||||
('USE_CARDANO', '1'),
|
('USE_CARDANO', '1' if EVERYTHING else '0'),
|
||||||
('USE_NEM', '1'),
|
('USE_NEM', '1' if EVERYTHING else '0'),
|
||||||
('USE_EOS', '1'),
|
('USE_EOS', '1' if EVERYTHING else '0'),
|
||||||
]
|
]
|
||||||
SOURCE_MOD += [
|
SOURCE_MOD += [
|
||||||
'embed/extmod/modtrezorcrypto/modtrezorcrypto.c',
|
'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-keccak.c',
|
||||||
'vendor/trezor-crypto/ed25519-donna/ed25519-sha3.c',
|
'vendor/trezor-crypto/ed25519-donna/ed25519-sha3.c',
|
||||||
'vendor/trezor-crypto/ed25519-donna/modm-donna-32bit.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/groestl.c',
|
||||||
'vendor/trezor-crypto/hasher.c',
|
'vendor/trezor-crypto/hasher.c',
|
||||||
'vendor/trezor-crypto/hmac.c',
|
'vendor/trezor-crypto/hmac.c',
|
||||||
@ -91,34 +91,41 @@ SOURCE_MOD += [
|
|||||||
'vendor/trezor-crypto/shamir.c',
|
'vendor/trezor-crypto/shamir.c',
|
||||||
'vendor/trezor-crypto/slip39.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
|
# libsecp256k1-zkp
|
||||||
CPPPATH_MOD += [
|
if EVERYTHING:
|
||||||
'vendor/secp256k1-zkp',
|
CPPPATH_MOD += [
|
||||||
'vendor/secp256k1-zkp/src',
|
'vendor/secp256k1-zkp',
|
||||||
'vendor/secp256k1-zkp/include',
|
'vendor/secp256k1-zkp/src',
|
||||||
]
|
'vendor/secp256k1-zkp/include',
|
||||||
CPPDEFINES_MOD += [
|
]
|
||||||
'SECP256K1_BUILD',
|
CPPDEFINES_MOD += [
|
||||||
'USE_ASM_ARM',
|
'SECP256K1_BUILD',
|
||||||
'USE_NUM_NONE',
|
'USE_ASM_ARM',
|
||||||
'USE_FIELD_INV_BUILTIN',
|
'USE_NUM_NONE',
|
||||||
'USE_SCALAR_INV_BUILTIN',
|
'USE_FIELD_INV_BUILTIN',
|
||||||
'USE_EXTERNAL_ASM',
|
'USE_SCALAR_INV_BUILTIN',
|
||||||
'USE_FIELD_10X26',
|
'USE_EXTERNAL_ASM',
|
||||||
'USE_SCALAR_8X32',
|
'USE_FIELD_10X26',
|
||||||
'USE_ECMULT_STATIC_PRECOMPUTATION',
|
'USE_SCALAR_8X32',
|
||||||
'USE_EXTERNAL_DEFAULT_CALLBACKS',
|
'USE_ECMULT_STATIC_PRECOMPUTATION',
|
||||||
('ECMULT_WINDOW_SIZE', '8'),
|
'USE_EXTERNAL_DEFAULT_CALLBACKS',
|
||||||
'ENABLE_MODULE_GENERATOR',
|
('ECMULT_WINDOW_SIZE', '8'),
|
||||||
'ENABLE_MODULE_RANGEPROOF',
|
'ENABLE_MODULE_GENERATOR',
|
||||||
'ENABLE_MODULE_RECOVERY',
|
'ENABLE_MODULE_RANGEPROOF',
|
||||||
'ENABLE_MODULE_ECDH',
|
'ENABLE_MODULE_RECOVERY',
|
||||||
]
|
'ENABLE_MODULE_ECDH',
|
||||||
SOURCE_MOD_SECP256K1_ZKP += [
|
]
|
||||||
'vendor/secp256k1-zkp/src/secp256k1.c',
|
SOURCE_MOD_SECP256K1_ZKP += [
|
||||||
'vendor/secp256k1-zkp/src/asm/field_10x26_arm.s'
|
'vendor/secp256k1-zkp/src/secp256k1.c',
|
||||||
]
|
'vendor/secp256k1-zkp/src/asm/field_10x26_arm.s'
|
||||||
|
]
|
||||||
|
|
||||||
# modtrezorio
|
# modtrezorio
|
||||||
SOURCE_MOD += [
|
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'))
|
||||||
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 + 'apps/binance/*.py'))
|
||||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Binance*.py'))
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Binance*.py'))
|
||||||
|
|
||||||
@ -508,22 +515,22 @@ if FROZEN:
|
|||||||
# static secp256-zkp ecmult context
|
# static secp256-zkp ecmult context
|
||||||
#
|
#
|
||||||
|
|
||||||
host_env = Environment(ENV=os.environ)
|
if EVERYTHING:
|
||||||
host_env.Replace(
|
host_env = Environment(ENV=os.environ)
|
||||||
CC=os.getenv('CC_FOR_BUILD') or 'gcc',
|
host_env.Replace(
|
||||||
COPT='-O2',
|
CC=os.getenv('CC_FOR_BUILD') or 'gcc',
|
||||||
CPPPATH='vendor/secp256k1-zkp',
|
COPT='-O2',
|
||||||
)
|
CPPPATH='vendor/secp256k1-zkp',
|
||||||
gen_context = host_env.Program(
|
)
|
||||||
target='vendor/secp256k1-zkp/gen_context',
|
gen_context = host_env.Program(
|
||||||
source='vendor/secp256k1-zkp/src/gen_context.c',
|
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',
|
target='vendor/secp256k1-zkp/src/ecmult_static_context.h',
|
||||||
source='vendor/secp256k1-zkp/gen_context',
|
source='vendor/secp256k1-zkp/gen_context',
|
||||||
action='cd ${SOURCE.dir}; ./gen_context',
|
action='cd ${SOURCE.dir}; ./gen_context',
|
||||||
)
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Program objects
|
# Program objects
|
||||||
@ -531,7 +538,8 @@ secp256k1_zkp_ecmult_static_context = host_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_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_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'))
|
||||||
@ -559,7 +567,8 @@ obj_program.extend(
|
|||||||
' $SOURCE $TARGET', ))
|
' $SOURCE $TARGET', ))
|
||||||
|
|
||||||
env.Depends(obj_program, qstr_generated)
|
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(
|
program_elf = env.Command(
|
||||||
target='firmware.elf',
|
target='firmware.elf',
|
||||||
|
@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
EVERYTHING = True
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
SOURCE_MOD = []
|
SOURCE_MOD = []
|
||||||
SOURCE_MOD_SECP256K1_ZKP = []
|
if EVERYTHING:
|
||||||
|
SOURCE_MOD_SECP256K1_ZKP = []
|
||||||
|
|
||||||
PYOPT = ARGUMENTS.get('PYOPT', '1')
|
PYOPT = ARGUMENTS.get('PYOPT', '1')
|
||||||
FROZEN = ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0)
|
FROZEN = ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0)
|
||||||
@ -31,11 +34,11 @@ CPPDEFINES_MOD += [
|
|||||||
'AES_128',
|
'AES_128',
|
||||||
'AES_192',
|
'AES_192',
|
||||||
('USE_KECCAK', '1'),
|
('USE_KECCAK', '1'),
|
||||||
('USE_ETHEREUM', '1'),
|
('USE_ETHEREUM', '1' if EVERYTHING else '0'),
|
||||||
('USE_MONERO', '1'),
|
('USE_MONERO', '1' if EVERYTHING else '0'),
|
||||||
('USE_CARDANO', '1'),
|
('USE_CARDANO', '1' if EVERYTHING else '0'),
|
||||||
('USE_NEM', '1'),
|
('USE_NEM', '1' if EVERYTHING else '0'),
|
||||||
('USE_EOS', '1'),
|
('USE_EOS', '1' if EVERYTHING else '0'),
|
||||||
]
|
]
|
||||||
SOURCE_MOD += [
|
SOURCE_MOD += [
|
||||||
'embed/extmod/modtrezorcrypto/modtrezorcrypto.c',
|
'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-keccak.c',
|
||||||
'vendor/trezor-crypto/ed25519-donna/ed25519-sha3.c',
|
'vendor/trezor-crypto/ed25519-donna/ed25519-sha3.c',
|
||||||
'vendor/trezor-crypto/ed25519-donna/modm-donna-32bit.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/groestl.c',
|
||||||
'vendor/trezor-crypto/hasher.c',
|
'vendor/trezor-crypto/hasher.c',
|
||||||
'vendor/trezor-crypto/hmac.c',
|
'vendor/trezor-crypto/hmac.c',
|
||||||
@ -89,31 +89,38 @@ SOURCE_MOD += [
|
|||||||
'vendor/trezor-crypto/shamir.c',
|
'vendor/trezor-crypto/shamir.c',
|
||||||
'vendor/trezor-crypto/slip39.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
|
# libsecp256k1-zkp
|
||||||
CPPPATH_MOD += [
|
if EVERYTHING:
|
||||||
'vendor/secp256k1-zkp',
|
CPPPATH_MOD += [
|
||||||
'vendor/secp256k1-zkp/src',
|
'vendor/secp256k1-zkp',
|
||||||
'vendor/secp256k1-zkp/include',
|
'vendor/secp256k1-zkp/src',
|
||||||
]
|
'vendor/secp256k1-zkp/include',
|
||||||
CPPDEFINES_MOD += [
|
]
|
||||||
'SECP256K1_BUILD',
|
CPPDEFINES_MOD += [
|
||||||
'USE_NUM_NONE',
|
'SECP256K1_BUILD',
|
||||||
'USE_FIELD_INV_BUILTIN',
|
'USE_NUM_NONE',
|
||||||
'USE_SCALAR_INV_BUILTIN',
|
'USE_FIELD_INV_BUILTIN',
|
||||||
'USE_FIELD_10X26',
|
'USE_SCALAR_INV_BUILTIN',
|
||||||
'USE_SCALAR_8X32',
|
'USE_FIELD_10X26',
|
||||||
'USE_ECMULT_STATIC_PRECOMPUTATION',
|
'USE_SCALAR_8X32',
|
||||||
'USE_EXTERNAL_DEFAULT_CALLBACKS',
|
'USE_ECMULT_STATIC_PRECOMPUTATION',
|
||||||
('ECMULT_WINDOW_SIZE', '8'),
|
'USE_EXTERNAL_DEFAULT_CALLBACKS',
|
||||||
'ENABLE_MODULE_GENERATOR',
|
('ECMULT_WINDOW_SIZE', '8'),
|
||||||
'ENABLE_MODULE_RANGEPROOF',
|
'ENABLE_MODULE_GENERATOR',
|
||||||
'ENABLE_MODULE_RECOVERY',
|
'ENABLE_MODULE_RANGEPROOF',
|
||||||
'ENABLE_MODULE_ECDH',
|
'ENABLE_MODULE_RECOVERY',
|
||||||
]
|
'ENABLE_MODULE_ECDH',
|
||||||
SOURCE_MOD_SECP256K1_ZKP += [
|
]
|
||||||
'vendor/secp256k1-zkp/src/secp256k1.c',
|
SOURCE_MOD_SECP256K1_ZKP += [
|
||||||
]
|
'vendor/secp256k1-zkp/src/secp256k1.c',
|
||||||
|
]
|
||||||
|
|
||||||
# modtrezorio
|
# modtrezorio
|
||||||
SOURCE_MOD += [
|
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'))
|
||||||
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 + 'apps/binance/*.py'))
|
||||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Binance*.py'))
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/Binance*.py'))
|
||||||
|
|
||||||
@ -471,22 +478,22 @@ if FROZEN:
|
|||||||
# static secp256-zkp ecmult context
|
# static secp256-zkp ecmult context
|
||||||
#
|
#
|
||||||
|
|
||||||
host_env = Environment(ENV=os.environ)
|
if EVERYTHING:
|
||||||
host_env.Replace(
|
host_env = Environment(ENV=os.environ)
|
||||||
CC=os.getenv('CC_FOR_BUILD') or 'gcc',
|
host_env.Replace(
|
||||||
COPT='-O2',
|
CC=os.getenv('CC_FOR_BUILD') or 'gcc',
|
||||||
CPPPATH='vendor/secp256k1-zkp',
|
COPT='-O2',
|
||||||
)
|
CPPPATH='vendor/secp256k1-zkp',
|
||||||
gen_context = host_env.Program(
|
)
|
||||||
target='vendor/secp256k1-zkp/gen_context',
|
gen_context = host_env.Program(
|
||||||
source='vendor/secp256k1-zkp/src/gen_context.c',
|
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',
|
target='vendor/secp256k1-zkp/src/ecmult_static_context.h',
|
||||||
source='vendor/secp256k1-zkp/gen_context',
|
source='vendor/secp256k1-zkp/gen_context',
|
||||||
action='cd ${SOURCE.dir}; ./gen_context',
|
action='cd ${SOURCE.dir}; ./gen_context',
|
||||||
)
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Program objects
|
# Program objects
|
||||||
@ -494,14 +501,16 @@ secp256k1_zkp_ecmult_static_context = host_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_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_MICROPYTHON))
|
||||||
obj_program.extend(env.Object(source=SOURCE_UNIX))
|
obj_program.extend(env.Object(source=SOURCE_UNIX))
|
||||||
if FROZEN:
|
if FROZEN:
|
||||||
obj_program.extend(env.Object(source=source_mpyc))
|
obj_program.extend(env.Object(source=source_mpyc))
|
||||||
|
|
||||||
env.Depends(obj_program, qstr_generated)
|
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(
|
program = env.Command(
|
||||||
target='micropython',
|
target='micropython',
|
||||||
|
Loading…
Reference in New Issue
Block a user