Commit Graph

13260 Commits

Author SHA1 Message Date
Damien George
63f0e700f4 extmod/modure: Set subject begin_line so ^ doesn't match interior.
Fixes issue #8402.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-16 12:21:00 +11:00
Damien George
adfd57c5fe lib/re1.5: Distinguish between subject start-of-line and start-of-srch.
Otherwise a repeated sub/split will continue to match ^ to the start of
that search.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-16 12:21:00 +11:00
Damien George
1692cad673 py/showbc: Remove global variables and make DECODE_PTR work correctly.
The bytecode state variables mp_showbc_code_start and mp_showbc_constants
have been removed and made local variables passed into the various
functions.

As part of this, the DECODE_PTR macro is fixed so it extracts the relevant
pointer from the child_table (a regression introduced in
f2040bfc7e).

Signed-off-by: Damien George <damien@micropython.org>
2022-03-16 11:59:46 +11:00
Damien George
962ad8622e py/parse: Handle check for target small-int size in parser.
This means that all constants for EMIT_ARG(load_const_obj, obj) are created
in the parser (rather than some in the compiler).

Signed-off-by: Damien George <damien@micropython.org>
2022-03-16 00:41:10 +11:00
Damien George
3c7cab4e98 py/parse: Put const bytes objects in parse tree as const object.
Instead of as an intermediate qstr, which may unnecessarily intern the data
of the bytes object.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-16 00:41:10 +11:00
Damien George
65851ebb51 py/parse: Simplify handling of const int parse nodes.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-16 00:00:25 +11:00
Damien George
eec07332b1 unix/variants: Enable a few optimisations and features on dev, coverage.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 13:34:43 +11:00
Damien George
3c20ddb41a unix/variants: Use rom feature config for standard, dev, coverage.
This change is a no-op in terms of functionality.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 13:32:25 +11:00
Damien George
0ac3191d8c unix/mpconfigport.h: Collect together config options from extra level.
This change is a no-op in terms of functionality.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 13:29:13 +11:00
Damien George
ac2293161e py/modsys: Add optional mutable attributes sys.ps1/ps2 and use them.
This allows customising the REPL prompt strings.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 10:58:33 +11:00
Damien George
cac939ddc3 py/modsys: Add optional sys.tracebacklimit attribute.
With behaviour as per CPython.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 10:43:21 +11:00
Damien George
bc181550a4 py/modsys: Add optional attribute delegation.
To be enabled when needed by specific sys attributes.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 10:43:21 +11:00
Damien George
3356b5ef8d py/objmodule: Support delegating failed attr lookups.
This commit adds generic support for mutable module attributes on built in
modules, by adding support for an optional hook function for module
attribute lookup.  If a module wants to support additional attribute load/
store/delete (beyond what is in the constant, globals dict) then it should
add at the very end of its globals dict MP_MODULE_ATTR_DELEGATION_ENTRY().
This should point to a custom function which will handle any additional
attributes.

The mp_module_generic_attr() function is provided as a helper function for
additional attributes: it requires an array of qstrs (terminated in
MP_QSTRnull) and a corresponding array of objects (with a 1-1 mapping
between qstrs and objects).  If the qstr is found in the array then the
corresponding object is loaded/stored/deleted.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 10:35:44 +11:00
Damien George
d470c5a5ba tests/extmod/vfs_posix.py: Only test statvfs if it exists.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 00:41:03 +11:00
Damien George
0149cd6b8b windows: Switch to VFS subsystem and use VfsPosix.
Following the unix port.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-10 00:26:36 +11:00
Damien George
2b409ef8a4 unix/moduos: Convert module to use extmod version.
All variants now use extmod/moduos.c as their uos module implementation.
In particular this means they all have MICROPY_VFS enabled and use VfsPosix
for their filesystem.

As part of this, the available functions in uos become more consistent with
other ports:
- coverage variant gets uos.urandom
- minimal and standard variant get: unlink, chdir, getcwd, listdir

Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 21:13:57 +11:00
Damien George
ade2720e55 esp8266/moduos: Convert module to use extmod version.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 10:03:23 +11:00
Damien George
11b77263ef stm32/moduos: Convert module to use extmod version.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 10:03:23 +11:00
Damien George
9a3e1a1808 mimxrt/moduos: Convert module to use extmod version.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 10:03:23 +11:00
Damien George
20bfae1471 qemu-arm/moduos: Convert module to use extmod version.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 10:03:23 +11:00
Damien George
94077c6402 samd/moduos: Convert module to use extmod version.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 10:03:23 +11:00
Damien George
818be10bb5 zephyr/moduos: Convert module to use extmod version.
This also adds uos.unlink(), for all ports that use extmod/moduos.c.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 10:03:23 +11:00
Damien George
1c53d85162 esp32/moduos: Convert module to use extmod version.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 10:03:23 +11:00
Damien George
926b554daf extmod/moduos: Create general uos module to be used by all ports.
Based on the rp2 port version, with the rp2 port converted to use this
module.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 10:03:23 +11:00
iabdalkader
507ad03329 rp2: Add USB MSC support.
It is currently not enabled by default on any board.
2022-03-09 00:38:07 +11:00
Daniël van de Giessen
e2513bfe8d extmod/moduzlib: Fix parsing zlib header dict size.
From RFC 1950 section 2.2: "CINFO is the base-2 logarithm of the LZ77
window size, minus eight (CINFO=7 indicates a 32K window size)"

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2022-03-08 23:16:14 +11:00
robert-hh
e0b97013d0 mimxrt/hal/pwm_backport: Make PWM symmetric, and round division calcs.
Ensure the symmetry of PWM: the duty rate of X and Q channels was not 50%,
when it should have been.  That is evident at high frequencies, like 15Mhz
or 37.5 MHz.  At low frequencies the deviation mattered less.  The A/B
channels were fine.

Also round up or down non-integer division factors. Before, always the
floor value was used.
2022-03-08 23:11:17 +11:00
robert-hh
4774501cab mimxrt/eth: Avoid a race condition for Ethernet.
That caused Ethernet to lock up at high data rates after ~200MByte data
average in a row.  Tested now with data bursts up to 10 GByte and overall
data rates of ~8MByte/s at the Eth100 port.
2022-03-08 23:11:01 +11:00
robert-hh
04f92a2825 mimxrt/boards: Support using an optional board-specific manifest.py.
If the board directory contains a manifest.py file, it will be included.
File not found errors will be ignored.
2022-03-08 23:10:41 +11:00
robert-hh
c72dfbcef9 mimxrt/boards/TEENSY41: Use the same SPI1 pins for Teensy 4.0 and 4.1.
Teensy 4.1 used different pins for SPI1 than Teensy 4.0, which made the
boards unnecessarily different.
2022-03-08 23:09:47 +11:00
robert-hh
b0d460cd7d mimxrt/eth: Fix an Ethernet transmit error.
Sometimes frames could not be sent immediately because the controller was
still busy with previous frames.  Then, an error was returned to lwip.
This fix adds a limited number of retries for this busy state, waiting
100µs before the next attempt.  Typically the transmit succeeds now at the
second attempt.

Second change: Reset the controller for a clean state after soft reset.
2022-03-08 23:09:17 +11:00
robert-hh
5ea85b7a85 mimxrt/boards: Add board files for MIMXRT1015 and MIMXRT1015_EVK.
OCOTP_Init() has been removed from mphalport.c.  The library files are
missing for the MIMXRT1015, and for just reading the OCOTP the Init is not
required.
2022-03-08 23:08:44 +11:00
robert-hh
5cc50b9f1c mimxrt/machine_spi: Add omitted GPIO config.
The method was changed, but not for the CSx pins.  No functional change.
2022-03-08 23:08:30 +11:00
Philipp Ebensberger
62cb2069bb mimxrt/machine_pin: Change pin drive constants to DRIVE_x naming.
Updated DRIVE_x constants representing pin drive strength.

Signed-off-by: Philipp Ebensberger
2022-03-08 22:30:33 +11:00
Jonathan Hogg
3ebc370344 docs/library/machine.Pin: Update to use preferred DRIVE_x constants.
Update documents with new common names for the drive strength constants.
2022-03-07 23:47:45 +11:00
Jonathan Hogg
4c7c80d626 docs/esp32/quickref: Document GPIO drive strength.
Add brief documentation of the new `drive` keyword argument.
2022-03-07 23:41:29 +11:00
Jonathan Hogg
33083bf527 esp32/machine_pin: Add support for pin drive strength.
Add support for configuring drive strength of output pins with `drive` 
keyword argument and `DRIVE_*` constants.
2022-03-07 23:41:29 +11:00
Damien George
3440201e2e tests/micropython: Switch from set.pop to raise-0 to test exc strings.
To not rely on sets, which are an optional feature.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-07 16:48:35 +11:00
Damien George
9a8ee6a5df tests/run-tests.py: Include test files ending in _set as set tests.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-07 16:48:35 +11:00
Damien George
cced9a0128 zephyr/prj.conf: Enable CONFIG_BUILD_OUTPUT_HEX to generate .hex output.
The .hex file contains more information than .bin, useful for flashing.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-07 16:48:35 +11:00
Maureen Helm
474d288e55 zephyr: Upgrade to Zephyr v3.0.0.
Updates the Zephyr port build instructions and CI to use the latest
Zephyr release tag.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-03-07 16:48:35 +11:00
Maureen Helm
86a4a52670 zephyr: Update include path to disk_access.h.
The disk_access header was moved to a different path in Zephyr v2.6.0.
The old path was deprecated for two releases (v2.6.0 and v2.7.0) and
will no longer be supported after Zephyr v2.7.0.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-03-07 16:48:35 +11:00
Damien George
bf01671a96 tools/mpremote: Bump version to 0.2.0.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-07 16:02:55 +11:00
Damien George
7cd166ff92 tests/basics: Add test for creating small-ints in nan-box builds.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-07 15:25:11 +11:00
Damien George
bb2bd071f7 docs/library/esp32.rst: Mark esp32.Partition as not taking kw args.
Fixes issue #8380.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-07 15:15:45 +11:00
David Lechner
eadc927baf docs/differences/python_35: Mark PEP 486 as not applicable.
This adds the "Not relevant" designation to PEP 486 since it has to do with
the Python Launcher for Windows and not the Python language itself.

Also fix a typo while we are touching this line.

Signed-off-by: David Lechner <david@pybricks.com>
2022-03-07 14:15:21 +11:00
Jan
5d9171b5cc docs/library/machine.UART.rst: Add details for invert parameter. 2022-03-07 14:12:50 +11:00
robert-hh
d696d9141e esp32/machine_uart: Make UART.init preserve unspecified parameters.
Most of the settings behaved that way, except for baudate, timeout,
timout_char, invert and flow.
2022-03-07 13:45:50 +11:00
robert-hh
55a0125a15 esp32/machine_pwm: Always set the duty cycle when setting the frequency.
If setting the frequency to a value used already by an existing timer, this
timer will be used.  But still, the duty cycle for that channel may have to
be changed.

Fixes issues #8306 and #8345.
2022-03-07 13:37:23 +11:00
Daniël van de Giessen
665f0e2a68 esp32: Sleep one tick in MICROPY_EVENT_POLL_HOOK.
If MicroPython threads are enabled, loops waiting for an incoming event
should release the GIL and suspend, allowing other tasks to run while they
wait.

Prior to this commit, the problem can easily be observed by running a
thread that is both busy and regularly releases the GIL (for example a loop
doing something then sleeping a few ms after each iteration).  When the
main task is at the REPL, the thread is significantly stalled.  If the main
task is manually made to release the GIL (for example, by calling
utime.sleep_ms(500)) the other thread can be seen immediately working at
the expected speed again.

Additionally, there are various instances in where blocking functions run
MICROPY_EVENT_POLL_HOOK in a loop while they wait for a certain event/
condition.  For example the uselect methods poll objects to determine
whether data is available, but uses 100% of CPU while it does, constantly
calling MICROPY_EVENT_POLL_HOOK in the process.

The MICROPY_EVENT_POLL_HOOK macro is only ever used in waiting loops, where
(if threads are enabled) it makes sense to yield for a single tick so that
these loops do not consume all CPU cycles but instead other threads may
execute.  (In fact, the thing these loops wait for may even indirectly or
directly depend on another task being able to run.)

This change moves the sleep that was inside the REPL input function to
inside the MICROPY_EVENT_POLL_HOOK macro, where the GIL is already being
released, solving both the blocking REPL issue and the 100% CPU use issue
at the same time.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2022-03-02 12:57:43 +11:00