summaryrefslogtreecommitdiff
path: root/examples/embedding
AgeCommit message (Collapse)Author
2024-02-15embed: Improve stack top estimation.YAMAMOTO Takashi
Obtaining the stack-top via a few function calls may yield a pointer which is too deep within the stack. So require the user to obtain it from a higher level (or via some other means). Fixes issue #11781. Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
2024-01-31examples/embedding: Add -fno-common to the sample compiler flags.Angus Gratton
This makes no difference when files are linked directly into a target application, but on macOS additional steps are needed to index common symbols in static libraries. See https://stackoverflow.com/a/26581710 By not creating any common symbols, this problem is bypassed. This will also trigger linker errors if there are cases where the same symbol is defined in the host application. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-06-08all: Rename *umodule*.c to remove the "u" prefix.Jim Mussared
Updates any includes, and references from Makefiles/CMake. This essentially reverts what was done long ago in commit 136b5cbd7669e8318f8455fc2706da97a5b7994c This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-04-27all: Fix spelling mistakes based on codespell check.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-01-20examples/embedding: Rework example to use ports/embed.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-10-11all: Use += rather than = everywhere for CFLAGS/LDFLAGS/LIBS.Jim Mussared
This avoids a surprise where an = can cancel out an earlier +=. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-18all: Remove MICROPY_PY_IO_FILEIO config option.Damien George
Since commit e65d1e69e88268145ff0e7e73240f028885915be there is no longer an io.FileIO class, so this option is no longer needed. This option also controlled whether or not files supported being opened in binary mode (eg 'rb'), and could, if disabled, lead to confusion as to why opening a file in binary mode silently did the wrong thing (it would just open in text mode if MICROPY_PY_IO_FILEIO was disabled). The various VFS implementations (POSIX, FAT, LFS) were the only places where enabling this option made a difference, and in almost all cases where one of these filesystems were enabled, MICROPY_PY_IO_FILEIO was also enabled. So it makes sense to just unconditionally enable this feature (ability to open a file in binary mode) in all cases, and so just remove this config option altogether. That makes configuration simpler and means binary file support always exists (and opening a file in binary mode is arguably more fundamental than opening in text mode, so if anything should be configurable then it should be the ability to open in text mode). Signed-off-by: Damien George <damien@micropython.org>
2022-08-11all: Fix paths to mpy-cross and micropython binaries.Daniel Jour
Binaries built using the Make build system now no longer appear in the working directory of the build, but rather in the build directory. Thus some paths had to be adjusted.
2022-07-18examples/embedding: Remove obsolete axtls build target.Damien George
axtls is now built as part of the standard make process, using rules in extmod/extmod.mk. Signed-off-by: Damien George <damien@micropython.org>
2022-07-18shared/readline: Use MP_REGISTER_ROOT_POINTER().David Lechner
This uses MP_REGISTER_ROOT_POINTER() to register the readline_history root pointer array used by shared/readline.c and removes the registration from all mpconfigport.h files. This also required adding a new MICROPY_READLINE_HISTORY_SIZE config option since not all ports used the same sized array. Signed-off-by: David Lechner <david@pybricks.com>
2022-06-21extmod/extmod.mk: Separate out extmod file list from py.mk to extmod.mk.David Lechner
This separates extmod source files from `py.mk`. Previously, `py.mk` assumed that every consumer of the py/ directory also wanted to include extmod/. However, this is not the case. For example, building mpy-cross uses py/ but doesn't need extmod/. This commit moves all extmod-specific items from `py.mk` to `extmod.mk` and explicitly includes `extmod.mk` in ports that use it. Signed-off-by: David Lechner <david@pybricks.com>
2022-05-25py/builtin: Clean up and simplify import_stat and builtin_open config.Damien George
The following changes are made: - If MICROPY_VFS is enabled then mp_vfs_import_stat and mp_vfs_open are automatically used for mp_import_stat and mp_builtin_open respectively. - If MICROPY_PY_IO is enabled then "open" is automatically included in the set of builtins, and points to mp_builtin_open_obj. This helps to clean up and simplify the most common port configuration. Signed-off-by: Damien George <damien@micropython.org>
2022-03-25examples/embedding: Fix build with updated sys and os modules.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2021-09-16all: Remove MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE.Jim Mussared
This commit removes all parts of code associated with the existing MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE optimisation option, including the -mcache-lookup-bc option to mpy-cross. This feature originally provided a significant performance boost for Unix, but wasn't able to be enabled for MCU targets (due to frozen bytecode), and added significant extra complexity to generating and distributing .mpy files. The equivalent performance gain is now provided by the combination of MICROPY_OPT_LOAD_ATTR_FAST_PATH and MICROPY_OPT_MAP_LOOKUP_CACHE (which has been enabled on the unix port in the previous commit). It's hard to provide precise performance numbers, but tests have been run on a wide variety of architectures (x86-64, ARM Cortex, Aarch64, RISC-V, xtensa) and they all generally agree on the qualitative improvements seen by the combination of MICROPY_OPT_LOAD_ATTR_FAST_PATH and MICROPY_OPT_MAP_LOOKUP_CACHE. For example, on a "quiet" Linux x64 environment (i3-5010U @ 2.10GHz) the change from CACHE_MAP_LOOKUP_IN_BYTECODE, to LOAD_ATTR_FAST_PATH combined with MAP_LOOKUP_CACHE is: diff of scores (higher is better) N=2000 M=2000 bccache -> attrmapcache diff diff% (error%) bm_chaos.py 13742.56 -> 13905.67 : +163.11 = +1.187% (+/-3.75%) bm_fannkuch.py 60.13 -> 61.34 : +1.21 = +2.012% (+/-2.11%) bm_fft.py 113083.20 -> 114793.68 : +1710.48 = +1.513% (+/-1.57%) bm_float.py 256552.80 -> 243908.29 : -12644.51 = -4.929% (+/-1.90%) bm_hexiom.py 521.93 -> 625.41 : +103.48 = +19.826% (+/-0.40%) bm_nqueens.py 197544.25 -> 217713.12 : +20168.87 = +10.210% (+/-3.01%) bm_pidigits.py 8072.98 -> 8198.75 : +125.77 = +1.558% (+/-3.22%) misc_aes.py 17283.45 -> 16480.52 : -802.93 = -4.646% (+/-0.82%) misc_mandel.py 99083.99 -> 128939.84 : +29855.85 = +30.132% (+/-5.88%) misc_pystone.py 83860.10 -> 82592.56 : -1267.54 = -1.511% (+/-2.27%) misc_raytrace.py 21490.40 -> 22227.23 : +736.83 = +3.429% (+/-1.88%) This shows that the new optimisations are at least as good as the existing inline-bytecode-caching, and are sometimes much better (because the new ones apply caching to a wider variety of map lookups). The new optimisations can also benefit code generated by the native emitter, because they apply to the runtime rather than the generated code. The improvement for the native emitter when LOAD_ATTR_FAST_PATH and MAP_LOOKUP_CACHE are enabled is (same Linux environment as above): diff of scores (higher is better) N=2000 M=2000 native -> nat-attrmapcache diff diff% (error%) bm_chaos.py 14130.62 -> 15464.68 : +1334.06 = +9.441% (+/-7.11%) bm_fannkuch.py 74.96 -> 76.16 : +1.20 = +1.601% (+/-1.80%) bm_fft.py 166682.99 -> 168221.86 : +1538.87 = +0.923% (+/-4.20%) bm_float.py 233415.23 -> 265524.90 : +32109.67 = +13.756% (+/-2.57%) bm_hexiom.py 628.59 -> 734.17 : +105.58 = +16.796% (+/-1.39%) bm_nqueens.py 225418.44 -> 232926.45 : +7508.01 = +3.331% (+/-3.10%) bm_pidigits.py 6322.00 -> 6379.52 : +57.52 = +0.910% (+/-5.62%) misc_aes.py 20670.10 -> 27223.18 : +6553.08 = +31.703% (+/-1.56%) misc_mandel.py 138221.11 -> 152014.01 : +13792.90 = +9.979% (+/-2.46%) misc_pystone.py 85032.14 -> 105681.44 : +20649.30 = +24.284% (+/-2.25%) misc_raytrace.py 19800.01 -> 23350.73 : +3550.72 = +17.933% (+/-2.79%) In summary, compared to MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE, the new MICROPY_OPT_LOAD_ATTR_FAST_PATH and MICROPY_OPT_MAP_LOOKUP_CACHE options: - are simpler; - take less code size; - are faster (generally); - work with code generated by the native emitter; - can be used on embedded targets with a small and constant RAM overhead; - allow the same .mpy bytecode to run on all targets. See #7680 for further discussion. And see also #7653 for a discussion about simplifying mpy-cross options. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-07-12all: Update to point to files in new shared/ directory.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2021-04-09examples/embedding: Fix example so it compiles again.Santeri Paavolainen
There were a few changes that had broken this example, specifically 2cdf1d25f59409b6130c0e8b6cf50300aed2d7e6 removed file.c from ports/unix. And (at least for MacOS) mp_state_ctx must be placed in the BSS with -fno-common so it is visible to the linker. Signed-off-by: Santeri Paavolainen <santtu@iki.fi>
2021-02-04all: Rename BYTES_PER_WORD to MP_BYTES_PER_OBJ_WORD.Damien George
The "word" referred to by BYTES_PER_WORD is actually the size of mp_obj_t which is not always the same as the size of a pointer on the target architecture. So rename this config value to better reflect what it measures, and also prefix it with MP_. For uses of BYTES_PER_WORD in setting the stack limit this has been changed to sizeof(void *), because the stack usually grows with machine-word sized values (eg an nlr_buf_t has many machine words in it). Signed-off-by: Damien George <damien@micropython.org>
2020-04-30all: Fix auto-enable of MICROPY_GCREGS_SETJMP to select GC behaviour.Damien George
Only enable it if MICROPY_GCREGS_SETJMP is not already defined, and no supported architecture is defined.
2020-04-29all: Factor gchelper code to one place and use it for unix & ARM ports.Jim Mussared
No functionality change is intended with this commit, it just consolidates the separate implementations of GC helper code to the lib/utils/ directory as a general set of helper functions useful for any port. This reduces duplication of code, and makes it easier for future ports or embedders to get the GC implementation correct. Ports should now link against gchelper_native.c and either gchelper_m0.s or gchelper_m3.s (currently only Cortex-M is supported but other architectures can follow), or use the fallback gchelper_generic.c which will work on x86/x64/ARM. The gc_helper_get_sp function from gchelper_m3.s is not really GC related and was only used by cc3200, so it has been moved to that port and renamed to cortex_m3_get_sp.
2019-11-11examples/embedding: Remove obsolete fatfs files from build.Damien George
2019-10-29examples/embedding: Replace symlink of mpconfigport.h with real file.Damien George
2019-08-28py: Add global default_emit_opt variable to make emit kind persistent.Damien George
mp_compile no longer takes an emit_opt argument, rather this setting is now provided by the global default_emit_opt variable. Now, when -X emit=native is passed as a command-line option, the emitter will be set for all compiled modules (included imports), not just the top-level script. In the future there could be a way to also set this variable from a script. Fixes issue #4267.
2018-09-14examples/embedding: Fix hard-coded MP_QSTR_ value.Damien George
2018-09-14examples/embedding: Fix reference to freed memory, lexer src name.Dave Hylands
This issue was brought up by BramPeters in the forum: https://forum.micropython.org/viewtopic.php?p=30066
2018-06-18examples/embedding: Add code markup and fix typo in README.md.Damien George
2018-02-23examples/embedding: Don't prefix $(MPTOP) to ports/unix source files.Damien George
Otherwise the build process puts the corresponding output object files in two directories lower, not in build/ports/unix.
2018-02-22examples/embedding: Update broken paths to use correct $(MPTOP).talljosh
Some ".." need to be changed to $(MPTOP), and in some places "ports/" needs to be inserted to get to the "ports/unix/" subdir.
2018-02-14unix/Makefile,embedding/Makefile: Remove obsolete use of STMHAL_SRC_C.Damien George
2017-08-21all: Make static dicts use mp_rom_map_elem_t type and MP_ROM_xxx macros.Damien George
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-07-19all: Remove trailing spaces, per coding conventions.Damien George
2017-06-07examples/embedding: Use core-provided KeyboardInterrupt object.Damien George
2017-05-29various: Spelling fixesVille Skyttä
2017-04-01all: Move BYTES_PER_WORD definition from ports to py/mpconfig.hDamien George
It can still be overwritten by a port in mpconfigport.h but for almost all cases one can use the provided default.
2017-03-31all: Use full path name when including mp-readline/timeutils/netutils.Damien George
This follows the pattern of how all other headers are now included, and makes it explicit where the header file comes from. This patch also removes -I options from Makefile's that specify the mp-readline/timeutils/ netutils directories, which are no longer needed.
2017-03-23all/Makefile: Remove -ansi from GCC flags, its ignored anyway.Krzysztof Blazewicz
The -ansi flag is used for C dialect selection and it is equivalent to -std=c90. Because it goes right before -std=gnu99 it is ignored as for conflicting flags GCC always uses the last one.
2017-03-14examples/embedding: Place lexer constructor within NLR handler block.Damien George
The lexer constructor may now raise an exception and it needs to be caught.
2017-02-15examples/embedding/README: Convert to markdown, grammar and clarity fixes.Paul Sokolovsky
2016-11-16py: Factor out persistent-code reader into separate files.Damien George
Implementations of persistent-code reader are provided for POSIX systems and systems using FatFS. Macros to use these are MICROPY_READER_POSIX and MICROPY_READER_FATFS respectively. If an alternative implementation is needed then a port can define the function mp_reader_new_file.
2016-08-15ports: Remove typedef of machine_ptr_t, it's no longer needed.Damien George
This type was used only for the typedef of mp_obj_t, which is now defined by the object representation. So we can now remove this unused typedef, to simplify the mpconfigport.h file.
2016-07-22examples/embedding: Add README.Paul Sokolovsky
2016-07-22examples/embedding: Example for embedding MicroPython in an app.Paul Sokolovsky