Commit ad81a2e6 authored by Damien George's avatar Damien George

minimal: Add ability and description to build without the compiler.

parent 3b2fd4df
...@@ -33,3 +33,15 @@ This version of the build will work out-of-the-box on a pyboard (and ...@@ -33,3 +33,15 @@ This version of the build will work out-of-the-box on a pyboard (and
anything similar), and will give you a MicroPython REPL on UART1 at 9600 anything similar), and will give you a MicroPython REPL on UART1 at 9600
baud. Pin PA13 will also be driven high, and this turns on the red LED on baud. Pin PA13 will also be driven high, and this turns on the red LED on
the pyboard. the pyboard.
## Building without the built-in MicroPython compiler
This minimal port can be built with the built-in MicroPython compiler
disabled. This will reduce the firmware by about 20k on a Thumb2 machine,
and by about 40k on 32-bit x86. Without the compiler the REPL will be
disabled, but pre-compiled scripts can still be executed.
To test out this feature, change the `MICROPY_ENABLE_COMPILER` config
option to "0" in the mpconfigport.h file in this directory. Then
recompile and run the firmware and it will execute the frozentest.py
file.
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "py/gc.h" #include "py/gc.h"
#include "lib/utils/pyexec.h" #include "lib/utils/pyexec.h"
#if MICROPY_ENABLE_COMPILER
void do_str(const char *src, mp_parse_input_kind_t input_kind) { void do_str(const char *src, mp_parse_input_kind_t input_kind) {
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0); mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
if (lex == NULL) { if (lex == NULL) {
...@@ -28,6 +29,7 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) { ...@@ -28,6 +29,7 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
} }
} }
#endif
static char *stack_top; static char *stack_top;
static char heap[2048]; static char heap[2048];
...@@ -40,6 +42,7 @@ int main(int argc, char **argv) { ...@@ -40,6 +42,7 @@ int main(int argc, char **argv) {
gc_init(heap, heap + sizeof(heap)); gc_init(heap, heap + sizeof(heap));
#endif #endif
mp_init(); mp_init();
#if MICROPY_ENABLE_COMPILER
#if MICROPY_REPL_EVENT_DRIVEN #if MICROPY_REPL_EVENT_DRIVEN
pyexec_event_repl_init(); pyexec_event_repl_init();
for (;;) { for (;;) {
...@@ -53,6 +56,9 @@ int main(int argc, char **argv) { ...@@ -53,6 +56,9 @@ int main(int argc, char **argv) {
#endif #endif
//do_str("print('hello world!', list(x+1 for x in range(10)), end='eol\\n')", MP_PARSE_SINGLE_INPUT); //do_str("print('hello world!', list(x+1 for x in range(10)), end='eol\\n')", MP_PARSE_SINGLE_INPUT);
//do_str("for i in range(10):\r\n print(i)", MP_PARSE_FILE_INPUT); //do_str("for i in range(10):\r\n print(i)", MP_PARSE_FILE_INPUT);
#else
pyexec_frozen_module("frozentest.py");
#endif
mp_deinit(); mp_deinit();
return 0; return 0;
} }
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
// options to control how Micro Python is built // options to control how Micro Python is built
// You can disable the built-in MicroPython compiler by setting the following
// config option to 0. If you do this then you won't get a REPL prompt, but you
// will still be able to execute pre-compiled scripts, compiled with mpy-cross.
#define MICROPY_ENABLE_COMPILER (1)
#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_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool
#define MICROPY_ALLOC_PATH_MAX (256) #define MICROPY_ALLOC_PATH_MAX (256)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment