1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-28 00:58:09 +00:00

core: re-enable frozen modules in the emulator build

This commit is contained in:
Pavol Rusnak 2019-05-01 13:39:44 +02:00
parent b865ee7656
commit 6e6ff78ce0
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 57 additions and 27 deletions

View File

@ -108,6 +108,9 @@ build_unix: res ## build unix port
build_unix_noui: res ## build unix port without UI support
$(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
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_RASPI=1

View File

@ -411,24 +411,25 @@ env.Ignore(qstr_collected, qstr_generated)
# Frozen modules
#
if env.get('TREZOR_MODEL') == '1':
SOURCE_PY_DIR = 'src1/'
else:
SOURCE_PY_DIR = 'src/'
if True:
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'))
# 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_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)
source_mpyc = env.FrozenCFile(
target='frozen_mpy.c', source=source_mpy, qstr_header=qstr_preprocessed)
env.Depends(source_mpyc, qstr_generated)
env.Depends(source_mpyc, qstr_generated)
#
# static secp256-zkp ecmult context
@ -463,7 +464,8 @@ 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_STMHAL))
obj_program.extend(env.Object(source=SOURCE_TREZORHAL))
obj_program.extend(env.Object(source=source_mpyc))
if True:
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')

View File

@ -5,9 +5,8 @@ import os
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
SOURCE_MOD_SECP256K1_ZKP = []
SOURCE_MOD = []
LIBS_MOD = []
SOURCE_MOD_SECP256K1_ZKP = []
# modtrezorconfig
CPPPATH_MOD += [
@ -73,6 +72,7 @@ SOURCE_MOD += [
'vendor/trezor-crypto/hasher.c',
'vendor/trezor-crypto/hmac.c',
'vendor/trezor-crypto/memzero.c',
'vendor/trezor-crypto/nem.c',
'vendor/trezor-crypto/nist256p1.c',
'vendor/trezor-crypto/pbkdf2.c',
'vendor/trezor-crypto/rand.c',
@ -80,12 +80,11 @@ SOURCE_MOD += [
'vendor/trezor-crypto/secp256k1.c',
'vendor/trezor-crypto/sha2.c',
'vendor/trezor-crypto/sha3.c',
'vendor/trezor-crypto/nem.c',
]
# libsecp256k1-zkp
CPPPATH_MOD += [
'vendor/secp256k1-zkp/',
'vendor/secp256k1-zkp',
'vendor/secp256k1-zkp/src',
'vendor/secp256k1-zkp/include',
]
@ -314,12 +313,12 @@ env.Replace(
env.Replace(
COPT=env.get('OPTIMIZE', env.get('ENV').get('OPTIMIZE', '-Os')),
CCFLAGS='$COPT '
CCFLAGS='$COPT -DMPZ_DIG_SIZE=16 '
'-g3 '
'-std=gnu99 -Wall -Werror -Wuninitialized '
'-fdata-sections -ffunction-sections ' + CCFLAGS_MOD,
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
LIBS=['m'] + LIBS_MOD,
LIBS=['m'],
CPPPATH=[
'.',
'embed/unix',
@ -373,6 +372,30 @@ qstr_generated = env.GenerateQstrDefs(
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
#
@ -399,10 +422,12 @@ secp256k1_zkp_ecmult_static_context = host_env.Command(
#
obj_program = []
obj_program += env.Object(source=SOURCE_MOD)
obj_program += env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function')
obj_program += env.Object(source=SOURCE_MICROPYTHON)
obj_program += env.Object(source=SOURCE_UNIX)
obj_program.extend(env.Object(source=SOURCE_MOD))
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 ARGUMENTS.get('TREZOR_FROZEN', 0):
obj_program.extend(env.Object(source=source_mpyc))
env.Depends(obj_program, qstr_generated)
env.Depends(obj_program, secp256k1_zkp_ecmult_static_context)

View File

@ -70,7 +70,7 @@
#define MICROPY_STREAMS_POSIX_API (1)
#define MICROPY_OPT_COMPUTED_GOTO (1)
#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
#define MICROPY_CAN_OVERRIDE_BUILTINS (0)
#define MICROPY_PY_FUNCTION_ATTRS (1)

View File

@ -7,7 +7,7 @@ BEGIN {
COLOR_RESET = "\033[0m"
} /^[a-zA-Z0-9_-]+:.*?## / {
printf COLOR_DARKGREEN
printf " make %-20s", $1
printf " make %-22s", $1
printf COLOR_RESET
printf " %s\n", $2
} /^##(.*)/ {