Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
circuitpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
circuitpython
Commits
ad81a2e6
Commit
ad81a2e6
authored
Feb 27, 2017
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minimal: Add ability and description to build without the compiler.
parent
3b2fd4df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
0 deletions
+23
-0
minimal/README.md
minimal/README.md
+12
-0
minimal/main.c
minimal/main.c
+6
-0
minimal/mpconfigport.h
minimal/mpconfigport.h
+5
-0
No files found.
minimal/README.md
View file @
ad81a2e6
...
...
@@ -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
baud. Pin PA13 will also be driven high, and this turns on the red LED on
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.
minimal/main.c
View file @
ad81a2e6
...
...
@@ -9,6 +9,7 @@
#include "py/gc.h"
#include "lib/utils/pyexec.h"
#if MICROPY_ENABLE_COMPILER
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
);
if
(
lex
==
NULL
)
{
...
...
@@ -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
);
}
}
#endif
static
char
*
stack_top
;
static
char
heap
[
2048
];
...
...
@@ -40,6 +42,7 @@ int main(int argc, char **argv) {
gc_init
(
heap
,
heap
+
sizeof
(
heap
));
#endif
mp_init
();
#if MICROPY_ENABLE_COMPILER
#if MICROPY_REPL_EVENT_DRIVEN
pyexec_event_repl_init
();
for
(;;)
{
...
...
@@ -53,6 +56,9 @@ int main(int argc, char **argv) {
#endif
//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);
#else
pyexec_frozen_module
(
"frozentest.py"
);
#endif
mp_deinit
();
return
0
;
}
...
...
minimal/mpconfigport.h
View file @
ad81a2e6
...
...
@@ -2,6 +2,11 @@
// 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_EXTRA_POOL mp_qstr_frozen_const_pool
#define MICROPY_ALLOC_PATH_MAX (256)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment