From b98a1db6eecf9fe3e481e5efa81d0ac154f5f750 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 2 Jan 2018 19:59:40 +0100 Subject: [PATCH] embed: cleanup unused modules --- Makefile | 4 ++-- SConscript.firmware | 6 ------ SConscript.unix | 15 +++------------ embed/firmware/mpconfigport.h | 4 ++-- embed/unix/mpconfigport.h | 11 ++++++----- src/trezor/res/__init__.py | 5 +---- 6 files changed, 14 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index fa45c00c9..acd1c095c 100644 --- a/Makefile +++ b/Makefile @@ -100,10 +100,10 @@ build_reflash: ## build reflash firmware + reflash image build_firmware: res build_cross ## build firmware with frozen modules $(SCONS) CFLAGS="$(CFLAGS)" $(FIRMWARE_BUILD_DIR)/firmware.bin -build_unix: ## build unix port +build_unix: res ## build unix port $(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) -build_unix_noui: ## 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_NOUI=1 build_cross: ## build mpy-cross port diff --git a/SConscript.firmware b/SConscript.firmware index 3f2a689a8..08085cdb7 100644 --- a/SConscript.firmware +++ b/SConscript.firmware @@ -107,7 +107,6 @@ SOURCE_MICROPYTHON = [ 'vendor/micropython/extmod/moductypes.c', 'vendor/micropython/extmod/moduheapq.c', 'vendor/micropython/extmod/modutimeq.c', - 'vendor/micropython/extmod/moduzlib.c', 'vendor/micropython/extmod/utime_mphal.c', 'vendor/micropython/lib/embed/abort_.c', 'vendor/micropython/lib/libc/string0.c', @@ -168,16 +167,11 @@ SOURCE_MICROPYTHON = [ 'vendor/micropython/py/map.c', 'vendor/micropython/py/modarray.c', 'vendor/micropython/py/modbuiltins.c', - 'vendor/micropython/py/modcmath.c', - 'vendor/micropython/py/modcollections.c', 'vendor/micropython/py/modgc.c', - 'vendor/micropython/py/modio.c', 'vendor/micropython/py/modmath.c', 'vendor/micropython/py/modmicropython.c', 'vendor/micropython/py/modstruct.c', 'vendor/micropython/py/modsys.c', - 'vendor/micropython/py/modthread.c', - 'vendor/micropython/py/moduerrno.c', 'vendor/micropython/py/mpprint.c', 'vendor/micropython/py/mpstate.c', 'vendor/micropython/py/mpz.c', diff --git a/SConscript.unix b/SConscript.unix index bd2cb93a9..6b32db980 100644 --- a/SConscript.unix +++ b/SConscript.unix @@ -103,9 +103,9 @@ SOURCE_MOD += [ ] # modutime -# SOURCE_MOD += [ -# 'embed/firmware/modutime.c', -# ] +SOURCE_MOD += [ + 'vendor/micropython/ports/unix/modtime.c', +] SOURCE_MICROPYTHON = [ 'vendor/micropython/extmod/modubinascii.c', @@ -114,7 +114,6 @@ SOURCE_MICROPYTHON = [ 'vendor/micropython/extmod/modutimeq.c', 'vendor/micropython/extmod/utime_mphal.c', 'vendor/micropython/lib/mp-readline/readline.c', - 'vendor/micropython/lib/timeutils/timeutils.c', 'vendor/micropython/py/argcheck.c', 'vendor/micropython/py/asmarm.c', 'vendor/micropython/py/asmbase.c', @@ -141,16 +140,11 @@ SOURCE_MICROPYTHON = [ 'vendor/micropython/py/map.c', 'vendor/micropython/py/modarray.c', 'vendor/micropython/py/modbuiltins.c', - 'vendor/micropython/py/modcmath.c', - 'vendor/micropython/py/modcollections.c', 'vendor/micropython/py/modgc.c', - 'vendor/micropython/py/modio.c', 'vendor/micropython/py/modmath.c', 'vendor/micropython/py/modmicropython.c', 'vendor/micropython/py/modstruct.c', 'vendor/micropython/py/modsys.c', - 'vendor/micropython/py/modthread.c', - 'vendor/micropython/py/moduerrno.c', 'vendor/micropython/py/mpprint.c', 'vendor/micropython/py/mpstate.c', 'vendor/micropython/py/mpz.c', @@ -222,10 +216,7 @@ SOURCE_UNIX = [ 'vendor/micropython/ports/unix/main.c', 'vendor/micropython/ports/unix/gccollect.c', 'vendor/micropython/ports/unix/unix_mphal.c', - 'vendor/micropython/ports/unix/mpthreadport.c', 'vendor/micropython/ports/unix/input.c', - 'vendor/micropython/ports/unix/file.c', - 'vendor/micropython/ports/unix/modtime.c', 'vendor/micropython/ports/unix/alloc.c', 'embed/unix/common.c', 'embed/unix/flash.c', diff --git a/embed/firmware/mpconfigport.h b/embed/firmware/mpconfigport.h index cc5e4d284..fd2359d7d 100644 --- a/embed/firmware/mpconfigport.h +++ b/embed/firmware/mpconfigport.h @@ -100,6 +100,7 @@ #define MICROPY_PY_BUILTINS_HELP_MODULES (0) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) +#define MICROPY_PY_COLLECTIONS (0) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0) #define MICROPY_PY_CMATH (0) @@ -141,8 +142,7 @@ #define MICROPY_PY_TREZORUTILS (1) // extra built in names to add to the global namespace -#define MICROPY_PORT_BUILTINS \ - { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, +#define MICROPY_PORT_BUILTINS // extra built in modules to add to the list of known ones extern const struct _mp_obj_module_t mp_module_utime; diff --git a/embed/unix/mpconfigport.h b/embed/unix/mpconfigport.h index 620315f62..ba4d18f79 100644 --- a/embed/unix/mpconfigport.h +++ b/embed/unix/mpconfigport.h @@ -94,15 +94,17 @@ #else #define MICROPY_PY_SYS_PLATFORM "linux" #endif -#define MICROPY_PY_SYS_MAXSIZE (1) -#define MICROPY_PY_SYS_STDFILES (1) +#define MICROPY_PY_SYS_MAXSIZE (0) +#define MICROPY_PY_SYS_STDFILES (0) #define MICROPY_PY_SYS_EXC_INFO (1) +#define MICROPY_PY_COLLECTIONS (0) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0) #endif #define MICROPY_PY_CMATH (0) -#define MICROPY_PY_IO_FILEIO (1) +#define MICROPY_PY_IO (0) +#define MICROPY_PY_IO_FILEIO (0) #define MICROPY_PY_IO_RESOURCE_STREAM (0) #define MICROPY_PY_GC_COLLECT_RETVAL (1) #define MICROPY_MODULE_FROZEN_STR (0) @@ -330,8 +332,7 @@ void mp_unix_mark_exec(void); #endif #endif -#define MICROPY_PORT_BUILTINS \ - { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, +#define MICROPY_PORT_BUILTINS #define MP_STATE_PORT MP_STATE_VM diff --git a/src/trezor/res/__init__.py b/src/trezor/res/__init__.py index 30e72c3e4..47028d20a 100644 --- a/src/trezor/res/__init__.py +++ b/src/trezor/res/__init__.py @@ -8,10 +8,7 @@ def load(name): ''' Loads resource of a given name as bytes. ''' - if resdata and name in resdata: - return resdata[name] - with open(name, 'rb') as f: - return f.read() + return resdata[name] def gettext(message):