Wykres commitów

316 Commity (c1530a0ce8e83811f88fbd4558ea7aaf27919ed8)

Autor SHA1 Wiadomość Data
Jim Mussared c1530a0ce8 unix: Refactor mpconfigport.h and mpconfigvariant.h.
This is a no-op for coverage and minimal.

The standard and dev variants have been merged and enable the same feature
set as a typical bare-metal board.  And remove the CI for the dev build.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-13 17:39:03 +10:00
Jim Mussared f4fed02537 unix/variants: Remove freedos and fast variants.
The freedos variant is untested by CI and is difficult to maintain.  The
fast variant is not a good name for what it does.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-13 17:37:55 +10:00
Andrew Leech 86676a43aa unix/mpconfigport: Enable MICROPY_ENABLE_FINALISER when VFS is used. 2022-09-13 13:06:56 +10:00
Jim Mussared 203dae41fb all: Update all manifest.py files to use new features.
Changes in this commit:
- Manifest include's now use the directory path where possible (no longer
  necessary to include the manifest.py file explicitly).
- Add manifest.py for all drivers and components that are referenced by
  port/board manifests.
- Replace all uses of freeze() with package()/module(), except for port and
  board modules.
- Use opt=3 everywhere, for consistency and to reduce code size.
- Use require() instead of include() for all micropython-lib references.
- Remove support for optional board-level manifest.py in mimxrt port, to
  make it behave the same as other ports (the board must set
  FROZEN_MANIFEST to a custom manifest.py, which can optionally include the
  default, port-level manifest).
- Also reinstates modules that were accidentally removed from the esp8266
  512k build in fbe9417b90.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2022-09-05 18:43:18 +10:00
Jim Mussared 64c62f8cf1 README: Simplify and update, and move unix section to separate file.
Changes are:
- Remove unix- and stm32-specific sections (move unix to its own
  README.md), stm32 was duplicated.
- Add links to GitHub Discussions and Discord.
- Update information about the project.
- Add a getting started section.
- Explain `make submodules`.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2022-08-30 13:11:33 +10:00
Jim Mussared 3a910b1565 py/objstr: Optimise mp_obj_new_str_from_vstr for known-safe strings.
The new `mp_obj_new_str_from_utf8_vstr` can be used when you know you
already have a unicode-safe string.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-26 16:44:35 +10:00
Jim Mussared 8a0ee5a5c0 py/objstr: Split mp_obj_str_from_vstr into bytes/str versions.
Previously the desired output type was specified.  Now make the type part
of the function name.  Because this function is used in a few places this
saves code size due to smaller call-site.

This makes `mp_obj_new_str_type_from_vstr` a private function of objstr.c
(which is almost the only place where the output type isn't a compile-time
constant).

This saves ~140 bytes on PYBV11.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-26 16:43:55 +10:00
Chris Waggoner b1efc1340a mpy-cross,unix: Include alloca.h for NetBSD. 2022-08-23 13:39:18 +10:00
Damien George 8f4c108025 all: Remove MICROPY_PY_IO_FILEIO config option.
Since commit e65d1e69e8 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-18 11:54:17 +10:00
Efi Weiss 98bd7e33b3 unix/modusocket: Support proto and flags arguments to getaddrinfo.
Signed-off-by: Efi Weiss <efiwiss@gmail.com>
2022-08-17 12:02:42 +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
Jim Mussared 28aaab9590 py/objstr: Add hex/fromhex to bytes/memoryview/bytearray.
These were added in Python 3.5.

Enabled via MICROPY_PY_BUILTINS_BYTES_HEX, and enabled by default for all
ports that currently have ubinascii.

Rework ubinascii to use the implementation of these methods.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-12 12:44:30 +10:00
David Yang b6651a7a89 unix/modjni: Add missing const qualifier. 2022-08-11 14:09:16 +10:00
Damien George d53c3b6ade unix/variants: Remove variant suffix from executable filename.
The executable now lives in the build directory, and since the build
directory already contains the variant name there is no need to also add
it to the executable.

Signed-off-by: Damien George <damien@micropython.org>
2022-08-11 13:34:34 +10:00
Daniel Jour 47c84286e8 all: Fix paths to mpy-cross and micropython binaries.
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-08-11 13:31:13 +10:00
David Lechner 3c32ca6e77 unix/unix_mphal: Allow overriding hal time functions.
This adds #ifdefs around each of the mp_hal_* time functions for the unix
port.  This allows variants to override individual functions as needed.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-29 11:06:12 +10:00
Jim Mussared 092784da19 ports: Remove unused mp_type_{fileio/textio} macros in mpconfigport.h.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-26 18:07:22 +10:00
Rob Knegjens d2e4cf00cc unix: Enable MICROPY_GC_SPLIT_HEAP on coverage build.
With a new option to evenly split the GC heap over multiple areas.  This
adds code coverage for gc_add() and code associated with
MICROPY_GC_SPLIT_HEAP.
2022-07-23 00:43:08 +10:00
David Lechner 03fb671833 unix/mpconfigport: Allow overriding MICROPY_EVENT_POLL_HOOK.
This allows variants to supply their own `MICROPY_EVENT_POLL_HOOK`.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-19 11:24:42 +10:00
David Lechner c947c25294 unix/Makefile: Only checkout libffi submodule when used.
This moves the libffi submodule variable modifier inside of the if
statement where it is actually used so that the submodule will only be
checked out if it is actually being used.

A new DEPLIBS variable is also introduced to prevent building the libffi
submodule when not needed.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-19 11:17:16 +10:00
Damien George b89422ceaa extmod: Always use custom mbedtls error message code.
All ports that use mbedtls use the custom error messages in
mp_mbedtls_errors.c.  This commit simplifies the build so that ports don't
need to explicitly add this file, it's now used by default when mbedtls is
enabled.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-18 22:55:22 +10:00
Damien George b87f796ef5 unix/Makefile: Only include axtls in GIT_SUBMODULES list when enabled.
Signed-off-by: Damien George <damien@micropython.org>
2022-07-18 22:45:38 +10:00
Damien George 13c78ab6fe unix/mpconfigport: Switch ussl from axtls to mbedtls.
The reasons to make this switch are:
- The axtls library is not being maintained/updated, mbedtls is.
- So CI and tests can run against mbedtls, which is now the main TLS
  library used by the ports (eg stm32, rp2, mimxrt, esp32). Only esp8266
  uses axtls.

Increases unix standard build on x86-64 by about 89000 bytes.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-18 22:43:01 +10:00
Damien George 26dec1fafb unix/mbedtls: Add custom config for mbedtls.
Based on existing bare-metal config from stm32.  Also uses shorter error
messages from lib/mbedtls_errors.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-18 22:42:51 +10:00
Damien George e30e7ced6f unix/mpconfigport: Make MICROPY_EVENT_POLL_HOOK call usleep directly.
So that MICROPY_EVENT_POLL_HOOK can be used without including py/mphal.h.

Signed-off-by: Damien George <damien@micropython.org>
2022-07-18 18:12:39 +10:00
David Lechner 7e4b205cb0 py/mpstate: Drop MICROPY_PORT_ROOT_POINTERS from mp_state_vm_t.
All in-tree uses of MICROPY_PORT_ROOT_POINTERS have been replaced with
MP_REGISTER_ROOT_POINTER(), so now we can remove both
MICROPY_PORT_ROOT_POINTERS and MICROPY_BOARD_ROOT_POINTERS from the code
and remaining config files.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:51:16 +10:00
David Lechner e531b72b56 extmod/nimble: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register bluetooth_nimble_memory
and bluetooth_nimble_root_pointers and removes the same from all
mpconfigport.h.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:50:14 +10:00
David Lechner 8fa6191f95 extmod/btstack: Use MP_REGISTER_ROOT_POINTER().
This uses MP_REGISTER_ROOT_POINTER() to register
bluetooth_btstack_root_pointers and removes the same from all
mpconfigport.h.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:49:51 +10:00
David Lechner e5631d9595 unix/alloc: Use MP_REGISTER_ROOT_POINTER() for mmap_region_head.
This uses MP_REGISTER_ROOT_POINTER() to register mmap_region_head and
removes the same from mpconfigport.h.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18 13:49:09 +10:00
David Lechner 81dbea1ce3 shared/readline: Use MP_REGISTER_ROOT_POINTER().
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-07-18 13:48:49 +10:00
David Lechner 093c4b6b26 unix/main: Restore tty settings on nlr_jump_fail().
Since nlr_jump_fail() exits the process, it can leave the terminal in raw
mode which means characters are not echoed.  Fix this by restoring the
original terminal mode.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-12 17:20:37 +10:00
David Lechner 5ab7dfe6db unix/moduos: Include errno.h.
The file `ports/unix/moduos.c` uses `errno` so it needs to include
`errno.h`, otherwise a compiler error can occur.

Signed-off-by: David Lechner <david@pybricks.com>
2022-07-05 23:44:07 +10:00
Damien George afa4d0a4b7 unix/variants/dev: Allow all config options to be overridden.
They can be overridden on the make command line, for example.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-29 12:48:33 +10:00
Damien George 510bea9383 unix/variants/coverage: Change config to use ROM level everything.
This ROM level is not yet fully defined, but it at least enables
MICROPY_PY_SYS_TRACEBACKLIMIT.  The coverage build should have everything
enabled, so it makes sense to use this ROM level for it.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-29 12:48:33 +10:00
Damien George fad978ae5f unix/variants: Enable remaining options on dev,coverage from ROM extra.
So that the default configuration for the dev and coverage variants
includes all options set by MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES.

Note that enabling MICROPY_PY_SYS_STDIO_BUFFER on unix doesn't do anything
because unix doesn't use shared/runtime/sys_stdio_mphal.c.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-29 12:23:11 +10:00
Damien George fe55d3e016 unix/variants: Move setting of MICROPY_PY_USELECT to port config file.
The default is the same as before: MICROPY_PY_USELECT=0 and
MICROPY_PY_USELECT_POSIX=1.  But now this can be easily overridden at the
make command-line using, eg:

    make VARIANT=dev CFLAGS_EXTRA=-DMICROPY_PY_USELECT=1

Signed-off-by: Damien George <damien@micropython.org>
2022-06-29 12:22:56 +10:00
David Lechner c118b5d0e4 extmod/extmod.mk: Separate out extmod file list from py.mk to extmod.mk.
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-06-21 00:14:34 +10:00
Damien George ac3fb974bc unix/variants: Enable seeding random module on import in dev, coverage.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 23:41:49 +10:00
Damien George d2f018bff1 unix,windows: Factor out code that generates random bytes to a new func.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-07 23:41:30 +10:00
stijn 5bb2a85d74 windows: Use BCryptGenRandom to implement os.urandom.
Fix urandom not working on windows (there's no /dev/urandom) by using
a proper cryptographic random function (same one as CPython >= 3.11).
2022-06-07 23:32:30 +10:00
Damien George efe23aca71 all: Remove third argument to MP_REGISTER_MODULE.
It's no longer needed because this macro is now processed after
preprocessing the source code via cpp (in the qstr extraction stage), which
means unused MP_REGISTER_MODULE's are filtered out by the preprocessor.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 16:31:37 +10:00
Damien George 6e71cde6aa ports: Use default VFS config for import_stat and builtin_open.
For ports with MICROPY_VFS and MICROPY_PY_IO enabled their configuration
can now be simplified to use the defaults for mp_import_stat and
mp_builtin_open.

This commit makes no functional change, except for the following minor
points:
- the built-in "open" is removed from the minimal port (it previously did
  nothing)
- the duplicate built-in "input" is removed from the esp32 port
- qemu-arm now delegates to VFS import/open

Signed-off-by: Damien George <damien@micropython.org>
2022-05-25 13:04:45 +10:00
David Lechner c012318d74 unix: Implement `-X realtime` command-line option on macOS.
This adds a new command line option to the unix port `-X realtime` to
enable realtime priority on threads.  This enables high precision timers
for applications that need more accurate timers.

Related docs:
https://developer.apple.com/library/archive/technotes/tn2169/_index.html

Fixes issue #8621.

Signed-off-by: David Lechner <david@pybricks.com>
2022-05-24 00:51:47 +10:00
David Lechner be5657b64f ports: Rename thread_t to mp_thread_t.
This adds the `mp_` prefix to the `thread_t` type.  The name `thread_t`
conflicts with the same in `mach/mach_types.h` on macOS.

Signed-off-by: David Lechner <david@lechnology.com>
2022-05-24 00:51:23 +10:00
Jim Mussared 63431a5536 unix: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:57:09 +10:00
Jim Mussared 4eab44a1ec extmod: Make extmod modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:49:12 +10:00
Damien George 5b700b0af9 all: Reformat remaining C code that doesn't have a space after a comma.
Signed-off-by: Damien George <damien@micropython.org>
2022-05-05 13:30:40 +10:00
Damien George fca5701f74 py/malloc: Introduce m_tracked_calloc, m_tracked_free functions.
Enabled by MICROPY_TRACKED_ALLOC.

Signed-off-by: Damien George <damien@micropython.org>
2022-05-05 10:31:50 +10:00
Jim Mussared 0e7bfc88c6 all: Use mp_obj_malloc everywhere it's applicable.
This replaces occurences of

    foo_t *foo = m_new_obj(foo_t);
    foo->base.type = &foo_type;

with

    foo_t *foo = mp_obj_malloc(foo_t, &foo_type);

Excludes any places where base is a sub-field or when new0/memset is used.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-03 22:28:14 +10:00
Damien George 402df833fe py/modsys: Introduce sys.implementation._machine constant.
This contains a string useful for identifying the underlying machine.  This
string is kept consistent with the second part of the REPL banner via the
new config option MICROPY_BANNER_MACHINE.

This makes os.uname() more or less redundant, as all the information in
os.uname() is now available in the sys module.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-28 17:23:03 +10:00