mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
core: re-enable frozen modules in the emulator build
This commit is contained in:
parent
b865ee7656
commit
6e6ff78ce0
@ -108,6 +108,9 @@ build_unix: res ## build unix port
|
|||||||
build_unix_noui: res ## build unix port without UI support
|
build_unix_noui: res ## build unix port without UI support
|
||||||
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_NOUI=1
|
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_NOUI=1
|
||||||
|
|
||||||
|
build_unix_noui_frozen: res build_cross ## build unix port without UI support with frozen modules
|
||||||
|
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_NOUI=1 TREZOR_FROZEN=1
|
||||||
|
|
||||||
build_unix_raspi: res ## build unix port for Raspberry Pi
|
build_unix_raspi: res ## build unix port for Raspberry Pi
|
||||||
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_RASPI=1
|
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_RASPI=1
|
||||||
|
|
||||||
|
@ -411,6 +411,7 @@ env.Ignore(qstr_collected, qstr_generated)
|
|||||||
# Frozen modules
|
# Frozen modules
|
||||||
#
|
#
|
||||||
|
|
||||||
|
if True:
|
||||||
if env.get('TREZOR_MODEL') == '1':
|
if env.get('TREZOR_MODEL') == '1':
|
||||||
SOURCE_PY_DIR = 'src1/'
|
SOURCE_PY_DIR = 'src1/'
|
||||||
else:
|
else:
|
||||||
@ -463,6 +464,7 @@ 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_STMHAL))
|
||||||
obj_program.extend(env.Object(source=SOURCE_TREZORHAL))
|
obj_program.extend(env.Object(source=SOURCE_TREZORHAL))
|
||||||
|
if True:
|
||||||
obj_program.extend(env.Object(source=source_mpyc))
|
obj_program.extend(env.Object(source=source_mpyc))
|
||||||
|
|
||||||
VENDORHEADER = 'embed/vendorheader/vendorheader_' + ('unsafe_signed_prod.bin' if ARGUMENTS.get('PRODUCTION', '0') == '0' else 'satoshilabs_signed_prod.bin')
|
VENDORHEADER = 'embed/vendorheader/vendorheader_' + ('unsafe_signed_prod.bin' if ARGUMENTS.get('PRODUCTION', '0') == '0' else 'satoshilabs_signed_prod.bin')
|
||||||
|
@ -5,9 +5,8 @@ import os
|
|||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
SOURCE_MOD_SECP256K1_ZKP = []
|
|
||||||
SOURCE_MOD = []
|
SOURCE_MOD = []
|
||||||
LIBS_MOD = []
|
SOURCE_MOD_SECP256K1_ZKP = []
|
||||||
|
|
||||||
# modtrezorconfig
|
# modtrezorconfig
|
||||||
CPPPATH_MOD += [
|
CPPPATH_MOD += [
|
||||||
@ -73,6 +72,7 @@ SOURCE_MOD += [
|
|||||||
'vendor/trezor-crypto/hasher.c',
|
'vendor/trezor-crypto/hasher.c',
|
||||||
'vendor/trezor-crypto/hmac.c',
|
'vendor/trezor-crypto/hmac.c',
|
||||||
'vendor/trezor-crypto/memzero.c',
|
'vendor/trezor-crypto/memzero.c',
|
||||||
|
'vendor/trezor-crypto/nem.c',
|
||||||
'vendor/trezor-crypto/nist256p1.c',
|
'vendor/trezor-crypto/nist256p1.c',
|
||||||
'vendor/trezor-crypto/pbkdf2.c',
|
'vendor/trezor-crypto/pbkdf2.c',
|
||||||
'vendor/trezor-crypto/rand.c',
|
'vendor/trezor-crypto/rand.c',
|
||||||
@ -80,12 +80,11 @@ SOURCE_MOD += [
|
|||||||
'vendor/trezor-crypto/secp256k1.c',
|
'vendor/trezor-crypto/secp256k1.c',
|
||||||
'vendor/trezor-crypto/sha2.c',
|
'vendor/trezor-crypto/sha2.c',
|
||||||
'vendor/trezor-crypto/sha3.c',
|
'vendor/trezor-crypto/sha3.c',
|
||||||
'vendor/trezor-crypto/nem.c',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# libsecp256k1-zkp
|
# libsecp256k1-zkp
|
||||||
CPPPATH_MOD += [
|
CPPPATH_MOD += [
|
||||||
'vendor/secp256k1-zkp/',
|
'vendor/secp256k1-zkp',
|
||||||
'vendor/secp256k1-zkp/src',
|
'vendor/secp256k1-zkp/src',
|
||||||
'vendor/secp256k1-zkp/include',
|
'vendor/secp256k1-zkp/include',
|
||||||
]
|
]
|
||||||
@ -314,12 +313,12 @@ env.Replace(
|
|||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
COPT=env.get('OPTIMIZE', env.get('ENV').get('OPTIMIZE', '-Os')),
|
COPT=env.get('OPTIMIZE', env.get('ENV').get('OPTIMIZE', '-Os')),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT -DMPZ_DIG_SIZE=16 '
|
||||||
'-g3 '
|
'-g3 '
|
||||||
'-std=gnu99 -Wall -Werror -Wuninitialized '
|
'-std=gnu99 -Wall -Werror -Wuninitialized '
|
||||||
'-fdata-sections -ffunction-sections ' + CCFLAGS_MOD,
|
'-fdata-sections -ffunction-sections ' + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LIBS=['m'] + LIBS_MOD,
|
LIBS=['m'],
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
'.',
|
'.',
|
||||||
'embed/unix',
|
'embed/unix',
|
||||||
@ -373,6 +372,30 @@ qstr_generated = env.GenerateQstrDefs(
|
|||||||
|
|
||||||
env.Ignore(qstr_collected, qstr_generated)
|
env.Ignore(qstr_collected, qstr_generated)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Frozen modules
|
||||||
|
#
|
||||||
|
|
||||||
|
if ARGUMENTS.get('TREZOR_FROZEN', 0):
|
||||||
|
if env.get('TREZOR_MODEL') == '1':
|
||||||
|
SOURCE_PY_DIR = 'src1/'
|
||||||
|
else:
|
||||||
|
SOURCE_PY_DIR = 'src/'
|
||||||
|
|
||||||
|
# TODO: recursive Glob
|
||||||
|
SOURCE_PY = Glob(SOURCE_PY_DIR + '*.py')
|
||||||
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + '*/*.py'))
|
||||||
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + '*/*/*.py'))
|
||||||
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + '*/*/*/*.py'))
|
||||||
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + '*/*/*/*/*.py'))
|
||||||
|
|
||||||
|
source_mpy = env.FrozenModule(source=SOURCE_PY, source_dir=SOURCE_PY_DIR)
|
||||||
|
|
||||||
|
source_mpyc = env.FrozenCFile(
|
||||||
|
target='frozen_mpy.c', source=source_mpy, qstr_header=qstr_preprocessed)
|
||||||
|
|
||||||
|
env.Depends(source_mpyc, qstr_generated)
|
||||||
|
|
||||||
#
|
#
|
||||||
# static secp256-zkp ecmult context
|
# static secp256-zkp ecmult context
|
||||||
#
|
#
|
||||||
@ -399,10 +422,12 @@ secp256k1_zkp_ecmult_static_context = host_env.Command(
|
|||||||
#
|
#
|
||||||
|
|
||||||
obj_program = []
|
obj_program = []
|
||||||
obj_program += env.Object(source=SOURCE_MOD)
|
obj_program.extend(env.Object(source=SOURCE_MOD))
|
||||||
obj_program += env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function')
|
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
|
||||||
obj_program += env.Object(source=SOURCE_MICROPYTHON)
|
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON))
|
||||||
obj_program += env.Object(source=SOURCE_UNIX)
|
obj_program.extend(env.Object(source=SOURCE_UNIX))
|
||||||
|
if ARGUMENTS.get('TREZOR_FROZEN', 0):
|
||||||
|
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)
|
env.Depends(obj_program, secp256k1_zkp_ecmult_static_context)
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
#define MICROPY_STREAMS_POSIX_API (1)
|
#define MICROPY_STREAMS_POSIX_API (1)
|
||||||
#define MICROPY_OPT_COMPUTED_GOTO (1)
|
#define MICROPY_OPT_COMPUTED_GOTO (1)
|
||||||
#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
|
#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
|
||||||
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (1)
|
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
|
||||||
#endif
|
#endif
|
||||||
#define MICROPY_CAN_OVERRIDE_BUILTINS (0)
|
#define MICROPY_CAN_OVERRIDE_BUILTINS (0)
|
||||||
#define MICROPY_PY_FUNCTION_ATTRS (1)
|
#define MICROPY_PY_FUNCTION_ATTRS (1)
|
||||||
|
@ -7,7 +7,7 @@ BEGIN {
|
|||||||
COLOR_RESET = "\033[0m"
|
COLOR_RESET = "\033[0m"
|
||||||
} /^[a-zA-Z0-9_-]+:.*?## / {
|
} /^[a-zA-Z0-9_-]+:.*?## / {
|
||||||
printf COLOR_DARKGREEN
|
printf COLOR_DARKGREEN
|
||||||
printf " make %-20s", $1
|
printf " make %-22s", $1
|
||||||
printf COLOR_RESET
|
printf COLOR_RESET
|
||||||
printf " %s\n", $2
|
printf " %s\n", $2
|
||||||
} /^##(.*)/ {
|
} /^##(.*)/ {
|
||||||
|
Loading…
Reference in New Issue
Block a user