Commit Graph

144 Commits

Author SHA1 Message Date
Scott Shawcroft 168c40e940
Merge pull request #8508 from dhalbert/v1.21-merge
V1.21 merge
2023-10-24 15:36:06 -07:00
Jeff Epler 7ab5252cdd
Add CIRCUITPY_MESSAGE_COMPRESSION_LEVEL
to trade compile speed & flash size

Initially enable the faster mode on rp2040 and espressif, where there's
usually plenty of flash available (these advanced techniques save hundreds
to thousands of bytes, which is important on a lot of old samd21 boards
but is a drop in the lake of a 4MB flash chip)
2023-10-20 19:18:18 +01:00
Dan Halbert 4b42a6f4a0 restore old uzlib; remove remaining U and u prefixes 2023-10-19 21:29:57 -04:00
Dan Halbert f2ebe6839c Initial MicroPython v1.21.0 merge; not compiled yet 2023-10-18 17:49:14 -04:00
Scott Shawcroft 01aec147ca
Add windows/fmode.c for mpy-cross 2023-10-11 10:04:02 -07:00
Scott Shawcroft 22a44c6003
Try and fix mpy-cross variants 2023-10-11 10:03:46 -07:00
Jeff Epler e7c74f273c
add translation to mpy-cross 2023-09-20 11:46:03 -05:00
Jeff Epler 1c611f6474
file not used any longer 2023-09-20 11:45:54 -05:00
Jeff Epler a715f089f4
mpy-cross needs to know it's targeting circuitpython 2023-09-20 11:23:24 -05:00
Dan Halbert 2c0fa0f7dc initial merge from v1.20.0; just satisifying conflicts 2023-09-19 11:10:12 -04:00
Jeff Epler 412e242d28
Fix `mpy-cross -X native` 2023-08-19 13:44:13 -05:00
Angus Gratton cec3ff5526 mpy-cross: Fix source file name in file-not-found error.
Found by Ruff with F821.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-16 16:13:01 +10:00
Dan Halbert d582407b06 pre-commit fixes 2023-08-14 00:59:22 -04:00
Dan Halbert 1b19ed4c39 change compilation verbosity options; fix mpy-cross 2023-08-12 13:38:17 -04:00
Dan Halbert fe0e2f13bc wip; fix qstr processing 2023-08-10 20:06:32 -04:00
Dan Halbert 0d4bc8c163 initial v1.19.1 merge; not compiled yet 2023-08-01 13:50:05 -04:00
Armin Brauns 14374850ce mpy-cross: Allow specifying stdin as input without --.
This way, a bare `-` is never interpreted as an option, even before
`--`. Filenames starting with `-` still need to be put after `--`.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-07-24 23:41:50 +10:00
Armin Brauns 3164749b3d mpy-cross: When reading from stdin, write output to stdout.
Unless -o is given, output defaults to stdout unless a source file is
given (in which case the source file name is used to derive an output
file name).

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-07-24 23:41:50 +10:00
Armin Brauns 6a61e4ecd1 mpy-cross: Allow reading from stdin and writing to stdout.
Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-07-24 23:41:50 +10:00
Armin Brauns 625e03d2dc mpy-cross: Allow specifying source files starting with -.
Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-07-24 23:32:11 +10:00
flom84 3ca0131ddd Fix mpy-cross compile error with GCC13.
- GCC13 reports the following error when compiling mpy-cross:

main.c:313:6: error: conflicting types for ‘mp_import_stat’ due to enum/integer mismatch; have ‘uint(const char *)’ {aka ‘unsigned int(const char *)’} [-Werror=enum-int-mismatch]
  313 | uint mp_import_stat(const char *path) {
      |      ^~~~~~~~~~~~~~
In file included from ../py/compile.h:29,
                 from main.c:11:
../py/lexer.h:205:18: note: previous declaration of ‘mp_import_stat’ with type ‘mp_import_stat_t(const char *)’
  205 | mp_import_stat_t mp_import_stat(const char *path);
      |                  ^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [../py/mkrules.mk:62: build/main.o] Error 1
2023-04-11 19:38:27 +02:00
Damien George 3257243998 mpy-cross/main: Fix return type of mp_import_stat.
Fixes issue #10951.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-07 14:47:21 +11:00
stijn 7e9a15966a mpy-cross: Force forward slashes in paths.
Code in tools/mpy-tool.py and py/frozenmod.c relies on the source file
path encoded in a .mpy file to have forward slashes (e.g. by searching
for '/__init__.py').  Enforce that when creating these files, thereby
fixing import of .mpy files and frozen modules not working before
because they could have backslashes when built with the windows port.
2023-02-01 13:10:00 +11:00
stijn 9c7ff87643 all: Keep msvc build output in build/ directories.
This follow the change made for Makefile-based projects in b2e82402.
2022-12-13 17:18:53 +11:00
Damien George 2283b6d68f py: Pass in address to compiled module instead of returning it.
This change makes it so the compiler and persistent code loader take a
mp_compiled_module_t* as their last argument, instead of returning this
struct.  This eliminates a duplicate context variable for all callers of
these functions (because the context is now stored in the
mp_compiled_module_t by the caller), and also eliminates any confusion
about which context to use after the mp_compile_to_raw_code or
mp_raw_code_load function returns (because there is now only one context,
that stored in mp_compiled_module_t.context).

Reduces code size by 16 bytes on ARM Cortex-based ports.

Signed-off-by: Damien George <damien@micropython.org>
2022-12-08 12:27:23 +11:00
David Lechner ac5934c96b mpy-cross/main: Add MSVC-compatible architecture checks.
MSVC doesn't define `__i386__` or `__x86_64__` so we have to check
`_M_IX86` and `_M_X64` as well.

Signed-off-by: David Lechner <david@pybricks.com>
2022-11-18 15:17:29 +11:00
Jim Mussared f31a358eb2 mpy-cross/main: Don't set a default native architecture.
If `-march` isn't set then it means the user hasn't thought about it, or in
the case of freezing, MPY_CROSS_FLAGS isn't set.  It's almost certainly
going to lead to problems, as there's no reason why the host architecture
is likely to be the right choice.

Compiling regular Python code is unaffected, but if `@native`/`@viper` is
used, the compiler will raise `SyntaxError: invalid arch`.

For situations where you explicitly want to use the host architecture (e.g.
for running tests on the unix port), added -march=host that keeps the old
behavior.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-11-17 22:37:45 +11:00
Jim Mussared d6d8722558 extmod: Make extmod.mk self-contained.
This makes it so that all a port needs to do is set the relevant variables
and "include extmod.mk" and doesn't need to worry about adding anything to
OBJ, CFLAGS, SRC_QSTR, etc.

Make all extmod variables (src, flags, etc) private to extmod.mk.

Also move common/shared, extmod-related fragments (e.g. wiznet, cyw43,
bluetooth) into extmod.mk.

Now that SRC_MOD, CFLAGS_MOD, CXXFLAGS_MOD are unused by both extmod.mk
(and user-C-modules in a previous commit), remove all uses of them from
port makefiles.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-11 23:31:49 +11:00
Jeff Epler 6c3cdceb45
Implement scan, connect, ping
My pings go out, and then they come back

```py
import os
import wifi
import ipaddress

wifi.radio.connect(os.getenv('WIFI_SSID'), os.getenv('WIFI_PASSWORD'))
ipv4 = ipaddress.ip_address("8.8.4.4")
print("Ping google.com: %f ms" % (wifi.radio.ping(ipv4)*1000))
```
2022-09-28 10:06:33 -05:00
Jim Mussared e4d90be680 mpy-cross/mpy_cross: Add docstrings to public methods. 2022-09-28 11:47:11 +10:00
Jim Mussared 370a87dd12 mpy-cross/mpy_cross: Add list of architectures to `__all__`.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-28 11:47:11 +10:00
Jim Mussared ee1b4a2026 mpy-cross/mpy_cross: Add a way to query the mpy version.
This returns the mpy version and sub-version for files compiled with this
mpy-cross binary.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-28 11:47:11 +10:00
Jim Mussared 71050870b8 mpy-cross/mpy_cross: Fix default path to mpy-cross binary.
Needed to be updated to use build/mpy-cross.

Also fixes some other issues in the Python wrapper:
 - Rename find_mpy_cross_binary to _find_mpy_cross_binary
 - Fix passing of -march arg.
 - Decode stdout from subprocess.
 - Print stdout from mpy-cross in __main__.py.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-28 11:37:22 +10:00
Jim Mussared d94141e147 py/persistentcode: Introduce .mpy sub-version.
The intent is to allow us to make breaking changes to the native ABI (e.g.
changes to dynruntime.h) without needing the bytecode version to increment.

With this commit the two bits previously used for the feature flags (but
now unused as of .mpy version 6) encode a sub-version.  A bytecode-only
.mpy file can be loaded as long as MPY_VERSION matches, but a native .mpy
(i.e. one with an arch set) must also match MPY_SUB_VERSION.  This allows 3
additional updates to the native ABI per bytecode revision.

The sub-version is set to 1 because the previous commits that changed the
layout of mp_obj_type_t have changed the native ABI.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2022-09-19 23:19:55 +10:00
Jim Mussared e42809531f mpy-cross/mpy_cross: Add Python wrapper for mpy-cross.
Rather than invoking mpy-cross directly via system/subprocess in our build
tools and other tools, this provides a Python interface for it.

Based on https://gitlab.com/alelec/mpy_cross (with the intention of
eventually replacing that as the "official" pypi distribution once setup.py
etc are added).

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-05 17:06:09 +10:00
Chris Waggoner b1efc1340a mpy-cross,unix: Include alloca.h for NetBSD. 2022-08-23 13:39:18 +10:00
Damien George ec24cd1d25 mpy-cross,unix: Remove .gitignore file.
Now that all build artefacts are placed in a build/ directory the gitignore
is no longer needed.

Signed-off-by: Damien George <damien@micropython.org>
2022-08-12 16:38:04 +10:00
David Yang d7ef90122e mpy-cross/Makefile: Respect existing CFLAGS and LDFLAGS. 2022-08-08 23:45:32 +10:00
Dan Halbert 8b4a5816bd don't specify -sdk in Makefile.m1 for mpy-cross 2022-07-27 22:51:14 -04:00
stijn c4adeb2e08 windows: Provide a definition for MP_ALWAYSINLINE. 2022-07-18 23:24:46 +10:00
Scott Shawcroft b690107850
Fix mpy-cross again 2022-06-02 12:33:51 -07:00
Scott Shawcroft 0d257fc4f8
Fix mpy-cross and unix builds 2022-06-02 12:30:19 -07:00
Scott Shawcroft 3cc46c74b9
Fix compiles 2022-05-27 15:39:55 -07:00
Damien George 4290d51320 py/emitinlinethumb: Make float instruction use dynamically selectable.
This allows mpy-cross to dynamically select whether ARMv7-M float
instructions are supported in @micropython.asm_thumb functions.

Signed-off-by: Damien George <damien@micropython.org>
2022-05-26 12:22:07 +10:00
Damien George cca08922d9 py/emitinlinethumb: Make ARMv7-M instruction use dynamically selectable.
This follows on from a5324a1074 and allows
mpy-cross to dynamically select whether ARMv7-M instructions are supported
in @micropython.asm_thumb functions.

The config option MICROPY_EMIT_INLINE_THUMB_ARMV7M is no longer needed, it
is now controlled by MICROPY_EMIT_THUMB_ARMV7M.

Signed-off-by: Damien George <damien@micropython.org>
2022-05-26 11:54:48 +10:00
Damien George 5956466c0e py/builtin: Clean up and simplify import_stat and builtin_open config.
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-05-25 13:04:45 +10:00
Damien George 0e28a1f0e5 mpy-cross: Add armv6m architecture option.
Signed-off-by: Damien George <damien@micropython.org>
2022-05-23 23:01:25 +10:00
Damien George c49d5207e9 py/persistentcode: Remove unicode feature flag from .mpy file.
Prior to this commit, even with unicode disabled .py and .mpy files could
contain unicode characters, eg by entering them directly in a string as
utf-8 encoded.

The only thing the compiler disallowed (with unicode disabled) was using
\uxxxx and \Uxxxxxxxx notation to specify a character within a string with
value >= 0x100; that would give a SyntaxError.

With this change mpy-cross will now accept \u and \U notation to insert a
character with value >= 0x100 into a string (because the -mno-unicode
option is now gone, there's no way to forbid this).  The runtime will
happily work with strings with such characters, just like it already works
with strings with characters that were utf-8 encoded directly.

This change simplifies things because there are no longer any feature
flags in .mpy files, and any bytecode .mpy will now run on any target.

Signed-off-by: Damien George <damien@micropython.org>
2022-05-17 12:51:54 +10:00
Jeff Epler b5ab73b111
whole conditional block no longer needed 2022-04-09 09:55:10 -05:00
lady ada d3a989f274 not sure why this changed...but it changed in mingw64? 2022-04-08 16:55:49 -04:00