Skip to content
Snippets Groups Projects
Commit f9448ddc authored by Damien George's avatar Damien George
Browse files

minimal: Add example of frozen persistent bytecode (.mpy file).

frozentest.py is frozen into the binary as frozen bytecode.  The .mpy
file is included so that there is no dependency on the cross compiler.
parent 0a2e9650
Branches
No related tags found
No related merge requests found
...@@ -50,6 +50,7 @@ SRC_C = \ ...@@ -50,6 +50,7 @@ SRC_C = \
lib/utils/pyexec.c \ lib/utils/pyexec.c \
lib/libc/string0.c \ lib/libc/string0.c \
lib/mp-readline/readline.c \ lib/mp-readline/readline.c \
$(BUILD)/_frozen_mpy.c \
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
...@@ -59,6 +60,10 @@ else ...@@ -59,6 +60,10 @@ else
all: $(BUILD)/firmware.elf all: $(BUILD)/firmware.elf
endif endif
$(BUILD)/_frozen_mpy.c: frozentest.mpy
$(ECHO) "MISC freezing bytecode"
$(Q)../tools/mpy-tool.py -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h -mlongint-impl=none $^ > $@
$(BUILD)/firmware.elf: $(OBJ) $(BUILD)/firmware.elf: $(OBJ)
$(ECHO) "LINK $@" $(ECHO) "LINK $@"
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
print('uPy')
print('a long string that is not interned')
print('a string that has unicode αβγ chars')
print(b'bytes 1234\x01')
print(123456789)
for i in range(4):
print(i)
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// options to control how Micro Python is built // options to control how Micro Python is built
#define MICROPY_QSTR_BYTES_IN_HASH (1) #define MICROPY_QSTR_BYTES_IN_HASH (1)
#define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool
#define MICROPY_ALLOC_PATH_MAX (256) #define MICROPY_ALLOC_PATH_MAX (256)
#define MICROPY_ALLOC_PARSE_CHUNK_INIT (16) #define MICROPY_ALLOC_PARSE_CHUNK_INIT (16)
#define MICROPY_EMIT_X64 (0) #define MICROPY_EMIT_X64 (0)
...@@ -43,7 +44,7 @@ ...@@ -43,7 +44,7 @@
#define MICROPY_PY_IO (0) #define MICROPY_PY_IO (0)
#define MICROPY_PY_STRUCT (0) #define MICROPY_PY_STRUCT (0)
#define MICROPY_PY_SYS (0) #define MICROPY_PY_SYS (0)
#define MICROPY_MODULE_FROZEN (0) #define MICROPY_MODULE_FROZEN_MPY (1)
#define MICROPY_CPYTHON_COMPAT (0) #define MICROPY_CPYTHON_COMPAT (0)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment