mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 09:28:13 +00:00
core: finish frozen modules support
This commit is contained in:
parent
ce4a1f2e1d
commit
87f14965c4
@ -105,11 +105,14 @@ build_firmware: res build_cross ## build firmware with frozen modules
|
|||||||
build_unix: res ## build unix port
|
build_unix: res ## build unix port
|
||||||
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS)
|
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS)
|
||||||
|
|
||||||
|
build_unix_frozen: res build_cross ## build unix port with frozen modules
|
||||||
|
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_FROZEN=1
|
||||||
|
|
||||||
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
|
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
|
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_NOUI=1 TREZOR_EMULATOR_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
|
||||||
|
@ -8,6 +8,8 @@ CPPDEFINES_MOD = []
|
|||||||
SOURCE_MOD = []
|
SOURCE_MOD = []
|
||||||
SOURCE_MOD_SECP256K1_ZKP = []
|
SOURCE_MOD_SECP256K1_ZKP = []
|
||||||
|
|
||||||
|
PYOPT = '1'
|
||||||
|
|
||||||
# modtrezorconfig
|
# modtrezorconfig
|
||||||
CPPPATH_MOD += [
|
CPPPATH_MOD += [
|
||||||
'embed/extmod/modtrezorconfig',
|
'embed/extmod/modtrezorconfig',
|
||||||
@ -134,6 +136,8 @@ if ARGUMENTS.get('TREZOR_EMULATOR_NOUI', 0):
|
|||||||
CPPDEFINES_MOD += ['TREZOR_EMULATOR_NOUI']
|
CPPDEFINES_MOD += ['TREZOR_EMULATOR_NOUI']
|
||||||
if ARGUMENTS.get('TREZOR_EMULATOR_RASPI', 0):
|
if ARGUMENTS.get('TREZOR_EMULATOR_RASPI', 0):
|
||||||
CPPDEFINES_MOD += ['TREZOR_EMULATOR_RASPI']
|
CPPDEFINES_MOD += ['TREZOR_EMULATOR_RASPI']
|
||||||
|
if ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0):
|
||||||
|
CPPDEFINES_MOD += ['TREZOR_EMULATOR_FROZEN']
|
||||||
|
|
||||||
# modtrezorutils
|
# modtrezorutils
|
||||||
SOURCE_MOD += [
|
SOURCE_MOD += [
|
||||||
@ -286,7 +290,7 @@ SOURCE_UNIX = [
|
|||||||
|
|
||||||
SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_UNIX
|
SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_UNIX
|
||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS=ARGUMENTS.get('CFLAGS', ''))
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPYOPT=%s' % (ARGUMENTS.get('CFLAGS', ''), PYOPT))
|
||||||
|
|
||||||
env.Tool('micropython')
|
env.Tool('micropython')
|
||||||
|
|
||||||
@ -313,7 +317,7 @@ 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 -DMPZ_DIG_SIZE=16 '
|
CCFLAGS='$COPT '
|
||||||
'-g3 '
|
'-g3 '
|
||||||
'-std=gnu99 -Wall -Werror -Wuninitialized '
|
'-std=gnu99 -Wall -Werror -Wuninitialized '
|
||||||
'-fdata-sections -ffunction-sections ' + CCFLAGS_MOD,
|
'-fdata-sections -ffunction-sections ' + CCFLAGS_MOD,
|
||||||
@ -343,7 +347,8 @@ env.Replace(
|
|||||||
MAKEQSTRDATA='$PYTHON vendor/micropython/py/makeqstrdata.py',
|
MAKEQSTRDATA='$PYTHON vendor/micropython/py/makeqstrdata.py',
|
||||||
MAKEVERSIONHDR='$PYTHON vendor/micropython/py/makeversionhdr.py',
|
MAKEVERSIONHDR='$PYTHON vendor/micropython/py/makeversionhdr.py',
|
||||||
MPY_TOOL='$PYTHON vendor/micropython/tools/mpy-tool.py',
|
MPY_TOOL='$PYTHON vendor/micropython/tools/mpy-tool.py',
|
||||||
MPY_CROSS='vendor/micropython/mpy-cross/mpy-cross', )
|
MPY_CROSS='vendor/micropython/mpy-cross/mpy-cross -O' + PYOPT
|
||||||
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Micropython version
|
# Micropython version
|
||||||
@ -376,7 +381,7 @@ env.Ignore(qstr_collected, qstr_generated)
|
|||||||
# Frozen modules
|
# Frozen modules
|
||||||
#
|
#
|
||||||
|
|
||||||
if ARGUMENTS.get('TREZOR_FROZEN', 0):
|
if ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0):
|
||||||
if env.get('TREZOR_MODEL') == '1':
|
if env.get('TREZOR_MODEL') == '1':
|
||||||
SOURCE_PY_DIR = 'src1/'
|
SOURCE_PY_DIR = 'src1/'
|
||||||
else:
|
else:
|
||||||
@ -426,7 +431,7 @@ 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_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 ARGUMENTS.get('TREZOR_FROZEN', 0):
|
if ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0):
|
||||||
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)
|
||||||
|
@ -28,6 +28,13 @@
|
|||||||
|
|
||||||
// options to control how MicroPython is built
|
// options to control how MicroPython is built
|
||||||
|
|
||||||
|
#ifdef TREZOR_EMULATOR_FROZEN
|
||||||
|
#define MICROPY_QSTR_EXTRA_POOL (mp_qstr_frozen_const_pool)
|
||||||
|
#define MICROPY_MODULE_FROZEN_MPY (1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MPZ_DIG_SIZE (16)
|
||||||
|
|
||||||
#define MICROPY_ALLOC_PATH_MAX (PATH_MAX)
|
#define MICROPY_ALLOC_PATH_MAX (PATH_MAX)
|
||||||
#define MICROPY_PERSISTENT_CODE_LOAD (1)
|
#define MICROPY_PERSISTENT_CODE_LOAD (1)
|
||||||
#if !defined(MICROPY_EMIT_X64) && defined(__x86_64__)
|
#if !defined(MICROPY_EMIT_X64) && defined(__x86_64__)
|
||||||
|
Loading…
Reference in New Issue
Block a user