diff options
author | Dave Hylands <dhylands@gmail.com> | 2015-10-31 22:55:13 -0700 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-11-04 14:21:21 +0000 |
commit | 53ea2b5ce2f7088c871c6c264899e4eae7973859 (patch) | |
tree | a7c7eb8de69b04d361239f3cb39c1283bfb4a3d9 /teensy/main.c | |
parent | 074d713bfb845a87e557e608f5215f53694e7d01 (diff) | |
download | micropython-53ea2b5ce2f7088c871c6c264899e4eae7973859.tar.gz micropython-53ea2b5ce2f7088c871c6c264899e4eae7973859.zip |
teensy: Switch over to using frozen modules instead of memzip
I left memzip in for the time being, so you can choose in
the Makefile whether to USE_FROZEN or USE_MEMZIP.
It looks like using frozen saves about 2472 bytes (using my
set of 15 python files), mostly due to overheads in the
zip file format.
Diffstat (limited to 'teensy/main.c')
-rw-r--r-- | teensy/main.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/teensy/main.c b/teensy/main.c index c31be6e01b..417bde78be 100644 --- a/teensy/main.c +++ b/teensy/main.c @@ -22,6 +22,10 @@ #include "uart.h" #include "pin.h" +#if MICROPY_MODULE_FROZEN +#include "py/compile.h" +#include "py/frozenmod.h" +#endif extern uint32_t _heap_start; @@ -301,14 +305,27 @@ soft_reset: } #endif +#if MICROPY_MODULE_FROZEN + { + mp_lexer_t *lex = mp_find_frozen_module("boot", 4); + mp_parse_compile_execute(lex, MP_PARSE_FILE_INPUT, mp_globals_get(), mp_locals_get()); + } +#else if (!pyexec_file("/boot.py")) { flash_error(4); } +#endif // Turn bootup LED off led_state(PYB_LED_BUILTIN, 0); // run main script +#if MICROPY_MODULE_FROZEN + { + mp_lexer_t *lex = mp_find_frozen_module("main", 4); + mp_parse_compile_execute(lex, MP_PARSE_FILE_INPUT, mp_globals_get(), mp_locals_get()); + } +#else { vstr_t *vstr = vstr_new(); vstr_add_str(vstr, "/"); @@ -322,6 +339,7 @@ soft_reset: } vstr_free(vstr); } +#endif // enter REPL // REPL mode can change, or it can request a soft reset |