Commit Graph

5444 Commits

Author SHA1 Message Date
Dan Halbert 0dca530b70 wip; Trinket M0 compiles 2023-08-09 15:20:10 -04:00
Dan Halbert 2ff8667e75 wip; remove long-lived functionality; remove PR#2614
Trinket M0 compile has no compilation errors, but has link errors to fix.
2023-08-08 20:41:17 -04:00
Dan Halbert 0d2c3c3f08 wip: continuing compilation fixes; mp_obj_alloc everywhere 2023-08-07 20:45:57 -04:00
Jeff Epler 46db0366b8
OrderedDict.move_to_end: alternate implementation of #8234
this implementation is hoped to be smaller. (feather_m4_express/fr fits
unlike the other PR; approximate savings ~600 bytes)

Minor difference to standard Python: A `dict` object has a
`move_to_end` method. However, calling this method always results in
TypeError.

Implementing it this way means that the method table can still be shared
between OrderedDict and builtin dict.

Closes #4408.
2023-08-04 09:26:26 -05:00
Dan Halbert 465d1c673e wip 2023-08-03 23:29:00 -04:00
Dan Halbert 0d4bc8c163 initial v1.19.1 merge; not compiled yet 2023-08-01 13:50:05 -04:00
Jeff Epler 272a2dcdb0
Merge pull request #8218 from jepler/esp32-camera
Update the camera board to use ESP32-S3 microcontroller
2023-07-31 14:48:50 -05:00
Jeff Epler cd181eb5b4
expand on the 0/1 requirement 2023-07-31 10:44:06 -05:00
Jeff Epler e8307a4c02
enable-if-any/all deserve some commentary. 2023-07-31 10:21:53 -05:00
Dan Halbert f466a4373e
Merge pull request #8222 from tannewt/fat_window_align
Align fatfs window buffer for tinyusb
2023-07-27 20:35:23 -04:00
Scott Shawcroft e45a61f57e
Align fatfs window buffer for tinyusb
Also, update tinyusb.
2023-07-27 09:15:58 -07:00
Dan Halbert 5cc42d5041
Merge pull request #8126 from jepler/update-ulab-6.3.2
update ulab to 6.3.2
2023-07-26 11:54:42 -04:00
Jeff Epler c026704fd2
gifio does require displayio 2023-07-26 08:54:02 -05:00
Jeff Epler d83b8db678
restore fontio define 2023-07-25 21:34:57 -05:00
Jeff Epler 9a18524c30
simplify circuitpy_mpconfig with enable-if-any, -all
and make corresponding simplifications in shared-bindings-matrix,
but directly using the final defines from CFLAGS instead of the
status quo.

The net changes are to disable audiocore & audiomixer on some espressif
devices that have no audio output at all. Other than that, the
shared-bindings-matrix seems to be identical.
2023-07-25 19:56:08 -05:00
Jeff Epler fd60cccb06
Re-enable ulab at the expense of some other modules
.. and gate audiomixer based on audiocore (should be no net change)

.. and get rid of now-redundant enables in the espressif mpconfigport
2023-07-25 16:01:11 -05:00
Jeff Epler 8579766ede
Optimize ulab for size on samd51/same51 2023-07-25 09:35:49 -05:00
Scott Shawcroft 525dad71c3
Add RuntimeError_varg and fix imx capitalization 2023-07-20 16:00:43 -07:00
Scott Shawcroft d7fa7380b8
Move some find_qstr wrappers to tcm next to it 2023-07-20 11:20:32 -07:00
KB Sriram 03e93f8e6c py/objdict: Fix fromkeys to return the right type.
Fixes https://github.com/adafruit/circuitpython/issues/8173

It looks like a small fix, and mostly independent of upstream
plans around https://github.com/micropython/micropython/pull/6173

I also filed an issue upstream
https://github.com/micropython/micropython/issues/12011
2023-07-14 22:03:06 -07:00
Scott Shawcroft 2686beab36
Basic USB host support and keyboard workflow
Connects up read, write and ctrl_transfer to TinyUSB. USB Host
support is available on iMX RT and RP2040.

Fixes #6527 (imx) and fixes #5986 (rp2).
2023-07-10 14:22:21 -07:00
Dan Halbert 4c55dc2445
Merge pull request #8096 from jepler/lto-parallel
Speed LTO builds by using multiple threads
2023-06-20 13:32:47 -04:00
Jeff Epler cae02f1cdf
Speed LTO builds by using multiple threads
On my i5-1235U laptop this speeds LTO "partition=balanced" builds
substantially, because each "partition" can be run on a separate
CPU thread. I used "pygamer" as my test build with a parallelism of
`-j4`, and took the best elapsed time reported over 4 builds.

The improvement was from 34.6s to 24.0s (-30%).

A link-only build (rm build-pygamer/firmware.elf; make -j...) improved
from1 17.4s to 5.1s (-70%)

The size of the resulting firmware is unchanged.

Boards that are nearly full use "-flto-partition=one" to improve code
size optimization. When LTO partition is "one", this feature doesn't help
but it doesn't seem to negatively affect anything either (tested
building trinket_m0)
2023-06-20 11:01:46 -05:00
Jeff Epler 666fb94ca3
Merge pull request #8056 from jepler/matrixportal-s3
Add Adafruit MatrixPortal S3 board def & update protomatter
2023-06-13 19:34:08 -05:00
Jeff Epler d4913b04e0 rgbmatrix: update protomatter
and re-organize so that esp32 s2/s3 don't do as much at reset

.. it's not necessary (because most data is in esp-idf managed memory)
and doing this saves me from having to debug why reconstruct isn't working
properly on that platform.

This needs to be tested on other platforms again before being merged!
2023-06-08 10:43:32 -05:00
Jeff Epler c408193ffe
Merge pull request #8048 from jepler/synthio-biquad
Synthio: switch to per-note biquad filtering
2023-06-07 14:48:31 -05:00
Scott Shawcroft b71f394127
Merge pull request #8071 from tannewt/cpx_stack_size
Slim down stack frames
2023-06-07 09:25:28 -07:00
Scott Shawcroft dd71ae10b9
Slim down stack frames
This reduces the stack frame size of mp_builtin___import__ by
limiting the support path length of files from 256 to 96. This
function can be called recursively for nested imports so it adds up.

Also reduce mp_execute_bytecode (vm.c) from 206 a bc call to 124.
This too is recursive and adds up. It is reduced by preventing
some inlining. It may decrease performance slightly when importing
and unpacking.

Adds two new scripts for debugging. One is used from gdb to print
frame sizes in a backtrace. The other prints what pcs use a
particular stack offset. This helps find infrequently used stack
space.

Fixes #8053.
2023-06-06 16:20:47 -07:00
Dan Halbert 46c5be07ff remove debugging print 2023-06-06 11:04:27 -04:00
Dan Halbert b576ec21b3 add tools to common submodules to fetch 2023-06-05 19:04:32 -04:00
Dan Halbert a7da1c4ad4 fix ports path arg to fetch-submodules.sh 2023-06-05 19:01:51 -04:00
Dan Halbert 38f6fa27e3 fetch-port-submodules; fetch-all-submodules 2023-06-05 17:23:34 -04:00
Jeff Epler fed8d5825b
synthio: add biquad filter type & basic filter calculations
the filter cannot be applied as yet.
2023-05-29 09:50:18 -05:00
Jeff Epler 76101c035e
core: Allow `enum` types to specify additional fields in the object
this will be used to make MathOperation enum values callable to
construct a Math object with that function
2023-05-21 13:22:48 -05:00
Jeff Epler 4da32a7b86
Merge remote-tracking branch 'origin/main' into synthio-lfo-dag 2023-05-19 11:56:13 -05:00
Scott Shawcroft 9d11bda9e8
Fix memoryview.cast over sliced memoryview
Fixes #4758
2023-05-18 13:26:50 -07:00
Jeff Epler 391438102b
synthio: Finish implementing Math blocks 2023-05-17 16:32:20 -05:00
Jeff Epler f83212314e
synthio: Add LFOs 2023-05-15 21:15:39 -05:00
Phil Underwood 0f96711ccd Fix for #2204 2023-05-15 21:35:16 +01:00
Jeff Epler a7da245ad0
synthio: Add synthio.Note
This class allows much more expressive sound synthesis:
 * tremolo & vibrato
 * arbitrary frequency
 * different evelope & waveform per note
 * all properties dynamically settable from Python code
2023-05-04 07:23:49 -05:00
Jeff Epler c22fd2a18e
runtime: Add mp_arg_validate_float_range 2023-05-04 07:23:48 -05:00
Jeff Epler bd9aca2526
Merge pull request #7862 from jepler/synthio-envelope
Synthio envelope
2023-05-03 12:42:56 -05:00
Scott Shawcroft 18207cd547
Guard GCC13 pragma 2023-04-28 11:28:48 -07:00
Scott Shawcroft a9dc31a881
Add additional iMX RT support
This adds a script to generate the peripherals files (except clock).

It adds support for the 1015, 1020, 1040, and 1050 EVKs.

Some work was started on 1176 but it isn't working. So, the board
def is in a separate branch.

Fixes #3521. Fixes #2477.
2023-04-28 11:01:13 -07:00
Damien George 294baf52b3 all: Bump version to 1.20.0.
Signed-off-by: Damien George <damien@micropython.org>
2023-04-26 15:42:28 +10:00
Jim Mussared 256f47e2f8 extmod/btstack: Fix indicate/notify queuing.
This adds a mechanism to track a pending notify/indicate operation that
is deferred due to the send buffer being full. This uses a tracked alloc
that is passed as the content arg to the callback.

This replaces the previous mechanism that did this via the global pending
op queue, shared with client read/write ops.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-04-26 11:37:20 +10:00
Marco Sirabella 863042dfd0 Move git command to update necessary tags to submodule
I ran into this one since I did an initial shallow clone due to slow
pycon 2023 wifi.
2023-04-25 16:05:20 -06:00
Marco Sirabella 6c85034952 Bump recommended shallow-since 1.5 years forward 2023-04-25 15:42:01 -06:00
Jeff Epler ca6ea83ff5
Fix `non_negative` validator to allow 0.0 2023-04-24 22:19:38 -05:00
Jeff Epler c4104898ce
add additional float validators 2023-04-24 22:19:38 -05:00
Jeff Epler 8e3c28e97d
Fix `memoryview.cast` in micropython-coverage
`locals_dict` and `attr` are incompatible, so just use circuitpython-style
properties so that a property and a method are both available.

this makes no difference in circuitpython, where
`MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE` is never enabled
2023-04-23 09:41:26 -05:00
Scott Shawcroft 66edcf5d03
Add PicoDVI support
PicoDVI in CP support 640x480 and 800x480 on Feather DVI, Pico and
Pico W. 1 and 2 bit grayscale are full resolution. 8 and 16 bit
color are half resolution.

Memory layout is modified to give the top most 4k of ram to the
second core. Its MPU is used to prevent flash access after startup.

The port saved word is moved to a watchdog scratch register so that
it doesn't get overwritten by other things in RAM.

Right align status bar and scroll area. This normally gives a few
pixels of padding on the left hand side and improves the odds it is
readable in a case. Fixes #7562

Fixes c stack checking. The length was correct but the top was being
set to the current stack pointer instead of the correct top.
Fixes #7643

This makes Bitmap subscr raise IndexError instead of ValueError
when the index arguments are wrong.
2023-04-19 15:14:02 -07:00
Alex Riesen a22136a732 py/makeqstrdefs.py: Fix handling GreenHills C/C++ preprocessor output.
The GreenHills preprocessor produces #line directives without a file name,
which the regular expression used to distiguish between
"# <number> file..." (GCC and similar) and "#line <number> file..."
(Microsoft C and similar) does not match, aborting processing.

Besides, the regular expression was unnecessarily wide, matching lines
containing a "#", followed by any  number of 'l','i','n', and 'e'
characters.

Signed-off-by: Alex Riesen <alexander.riesen@cetitec.com>
2023-04-11 16:41:10 +10:00
Scott Shawcroft 097af804cd
Fix ticks
In #7497 port_background_task was renamed to port_background_tick
but the actual call site wasn't changed. This meant that it was
no longer called!

Rename more functions from task to tick to make it clearer which is
which.
2023-04-07 09:49:51 -07:00
Jeff Epler b011468251
Add synthio.Synthesizer
In contrast to MidiTrack, this can be controlled from Python code,
turning notes on/off as desired.

Not tested on real HW yet, just the acceptance test based on checking
which notes it thinks are held internally.
2023-04-02 20:37:23 -05:00
Jeff Epler 05cf5213e2
Allow disabling each class in keypad
.. for boards like pewpewm4 which need a specific kind. And need
some space.
2023-04-01 19:22:52 -05:00
Jeff Epler 13e17e6dcd
Make synthio debuggable in unix coverage port 2023-04-01 11:46:36 -05:00
Jeff Epler 02f8a45dfa
synthio: allow increasing number of channels
12 channels works well on metro m7
2023-04-01 11:46:27 -05:00
David Lechner 283c1ba07e py/obj: Fix spelling of staticmethod.
Signed-off-by: David Lechner <david@pybricks.com>
2023-03-28 10:02:05 -05:00
hathach 8c1095b268
Merge branch 'main' into add-codespell 2023-03-23 14:09:57 +07:00
hathach a8abe8e705
remove lib from exludes, fix all remaining typos 2023-03-23 13:59:08 +07:00
Scott Shawcroft 67e0a49a1f
Merge pull request #7724 from tannewt/get_perfbench_running
Improve iMX RT performance
2023-03-21 09:00:48 -07:00
MicroDev ccd417cd8b
add esp specific modules to src patterns 2023-03-21 16:01:13 +05:30
Damien George d54208a2ff py/scheduler: Implement VM abort flag and mp_sched_vm_abort().
This is intended to be used by the very outer caller of the VM/runtime.  It
allows setting a top-level NLR handler that can be jumped to directly, in
order to forcefully abort the VM/runtime.

Enable using:

    #define MICROPY_ENABLE_VM_ABORT (1)

Set up the handler at the top level using:

    nlr_buf_t nlr;
    nlr.ret_val = NULL;
    if (nlr_push(&nlr) == 0) {
        nlr_set_abort(&nlr);
        // call into the VM/runtime
        ...
        nlr_pop();
    } else {
        if (nlr.ret_val == NULL) {
            // handle abort
            ...
        } else {
            // handle other exception that propagated to the top level
            ...
        }
    }
    nlr_set_abort(NULL);

Schedule an abort, eg from an interrupt handler, using:

    mp_sched_vm_abort();

Signed-off-by: Damien George <damien@micropython.org>
2023-03-21 18:08:57 +11:00
Damien George 5d4bfce034 py/mpstate: Add mp_thread_is_main_thread() helper macro.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-21 18:01:01 +11:00
hathach fecc1bdedb
fix typos (partial) detected by codepell 2023-03-18 22:17:02 +07:00
David Lechner fa8ebb1390 py/obj: Add MP_NOINLINE to mp_obj_malloc_helper.
As the comment in py/obj.h says:

> Implementing this as a call rather than inline saves 8 bytes per usage.

So in order to get this savings, we need to tell the compiler to never
inline the function.

Signed-off-by: David Lechner <david@pybricks.com>
2023-03-17 13:16:06 -05:00
Jeff Epler 6ff58fd94a
re-enable mkfs for >4GB filesystems whenver FULL_BUILD 2023-03-17 09:37:15 -05:00
Scott Shawcroft 5bb8a7a7c6
Improve iMX RT performance
* Enable dcache for OCRAM where the VM heap lives.
* Add CIRCUITPY_SWO_TRACE for pushing program counters out over the
  SWO pin via the ITM module in the CPU. Exempt some functions from
  instrumentation to reduce traffic and allow inlining.
* Place more functions in ITCM to handle errors using code in RAM-only
  and speed up CP.
* Use SET and CLEAR registers for digitalio. The SDK does read, mask
  and write.
* Switch to 2MiB reserved for CircuitPython code. Up from 1MiB.
* Run USB interrupts during flash erase and write.
* Allow storage writes from CP if the USB drive is disabled.
* Get perf bench tests running on CircuitPython and increase timeouts
  so it works when instrumentation is active.
2023-03-14 12:30:58 -07:00
Dan Halbert b6a7613350
Merge pull request #7470 from microdev1/espnow
Add ESP-NOW Support
2023-03-10 12:21:56 -05:00
Damien George 668a7bd28a py/makeversionhdr.py: Always add micro to version string even if it's 0.
Moving forward, tags in this repository will always have three components.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-10 18:39:14 +11:00
Laurens Valk f3a596db7d py/builtinimport: Fix unix port build with external imports disabled.
Without this, building the unix port variants gives:
ports/unix/main.c:667: undefined reference to `mp_obj_is_package',
when MICROPY_ENABLE_EXTERNAL_IMPORT is 0.

Signed-off-by: Laurens Valk <laurens@pybricks.com>
2023-03-10 13:29:54 +11:00
Damien George 78dc2db2ba py/mpconfig: Provide config option for internal printf printer.
The C-level printf is usually used for internal debugging prints, and a
port/board may want to redirect this somewhere other than stdout.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-10 11:19:15 +11:00
Damien George b3c8ab37ec py/gc: Make gc_dump_info/gc_dump_alloc_table take a printer as argument.
So that callers can redirect the output if needed.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-10 10:58:10 +11:00
Damien George 7c1584aef1 py/compile: Fix scope of assignment expression target in comprehensions.
When := is used in a comprehension the target variable is bound to the
parent scope, so it's either a global or a nonlocal.  Prior to this commit
that was handled by simply using the parent scope's id_info for the
target variable.  That's completely wrong because it uses the slot number
for the parent's Python stack to store the variable, rather than the slot
number for the comprehension.  This will in most cases lead to incorrect
behaviour or memory faults.

This commit fixes the scoping of the target variable by explicitly
declaring it a global or nonlocal, depending on whether the parent is the
global scope or not.  Then the id_info of the comprehension can be used to
access the target variable.  This fixes a lot of cases of using := in a
comprehension.

Code size change for this commit:

       bare-arm:    +0 +0.000%
    minimal x86:    +0 +0.000%
       unix x64:  +152 +0.019% standard
          stm32:   +96 +0.024% PYBV10
         cc3200:   +96 +0.052%
        esp8266:  +196 +0.028% GENERIC
          esp32:  +156 +0.010% GENERIC[incl +8(data)]
         mimxrt:   +96 +0.027% TEENSY40
     renesas-ra:   +88 +0.014% RA6M2_EK
            nrf:   +88 +0.048% pca10040
            rp2:  +104 +0.020% PICO
           samd:   +88 +0.033% ADAFRUIT_ITSYBITSY_M4_EXPRESS

Fixes issue #10895.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-09 12:13:12 +11:00
David Grayson 2bcd88d556 py/makeversionhdr.py: Optionally get git tag and git hash from env vars.
This is handy when you are doing builds outside of the Git repository but
still want to record that information.

Signed-off-by: David Grayson <davidegrayson@gmail.com>
2023-03-02 23:19:30 +11:00
Pepijn de Vos 72e9318325 py/emitnative: Explicitly compare comparison ops in binary_op emitter.
Without this it's possible to get a compiler error about the comparison
always being true, because MP_BINARY_OP_LESS is 0.  And it seems that gcc
optimises these 6 equality comparisons into the same size machine code as
before.
2023-02-27 10:25:39 +11:00
Dan Halbert f9831b3bbc
Merge pull request #7639 from adafruit/8.0.x
Merge 8.0.x up to main
2023-02-24 19:32:09 -05:00
Scott Shawcroft 144aed40e3
Rename flag. Turn on UTF-8 and flag on unix
Also added label portion to the test.
2023-02-24 12:23:59 -08:00
Damien George 2e4dda3c20 py/modmath: Fix two-argument math function domain check.
Prior to this fix, pow(1.5, inf) and pow(0.5, -inf) (among other things)
would incorrectly raise a ValueError, because the result is inf with the
first argument being finite.  This commit fixes this by allowing the result
to be infinite if the first or second (or both) argument is infinite.

This fix doesn't affect the other three math functions that have two
arguments:
- atan2 never returns inf, so always fails isinf(ans)
- copysign returns inf only if the first argument x is inf, so will never
  reach the isinf(y) check
- fmod never returns inf, so always fails isinf(ans)

Signed-off-by: Damien George <damien@micropython.org>
2023-02-24 15:55:12 +11:00
Scott Shawcroft f832386cda
Merge remote-tracking branch 'adafruit/main' into banglejs2 2023-02-23 14:43:38 -08:00
Scott Shawcroft b79661d631
Alphabetize, fix typo and remove incorrect comment 2023-02-23 14:34:54 -08:00
Scott Shawcroft 1a3358d036
Limit FatFs' ability to upper case paths
Only uppercase ASCII letters a-z. This saves ~900 bytes. Previously
written files with other unicode letters will only be accessible
from their upper cased path.
2023-02-23 14:28:58 -08:00
Scott Shawcroft b67c0b7949
Merge pull request #7585 from bill88t/settings-toml-pystack
Settings.toml-configurable pystack
2023-02-22 10:13:31 -08:00
Scott Shawcroft a8b34bd067
Merge pull request #7549 from gamblor21/gif_displayio_support
Animated GIF support
2023-02-21 11:39:29 -08:00
Jeff Epler d249af2a24 don't explicitly register ulab here
.. it is registered by MP_REGISTER_MODULE in ulab.

Closes: #7600
2023-02-17 09:21:50 -06:00
Bill Sideris 5a9264261e
Merge branch 'adafruit:main' into settings-toml-pystack 2023-02-17 00:50:27 +02:00
Bill Sideris a37dad61fb
CIRCUITPY_SETTABLE_PYSTACK 2023-02-16 23:10:30 +02:00
Dan Halbert bbadc00599
Merge pull request #7577 from dhalbert/safemode-py
Implement safemode.py
2023-02-16 14:15:20 -05:00
MicroDev 32d86c3ea3
Merge pull request #7580 from adafruit/8.0.x
Merge 8.0.x up to main
2023-02-15 09:16:51 +05:30
Dan Halbert d46d9d5c21 shorten safe mode messages; improve message printing; fix CIRCUITPY_SAFEMODE_PY=0 2023-02-13 21:29:57 -05:00
Mark fa435468fa
Merge branch 'main' into gif_displayio_support 2023-02-13 18:30:51 -06:00
Dan Halbert d8231f1588 Implement safemode.py 2023-02-13 18:26:38 -05:00
MicroDev 65e9d937ac
use python based msgfmt 2023-02-13 11:22:35 +05:30
gamblor21 0c95e6a08e Moving to gifio module 2023-02-12 11:17:34 -06:00
gamblor21 da9b6fb0e2 Moving library to /lib 2023-02-10 18:31:59 -06:00
Jeff Epler 0d957fe15c
Fix several places where an exception could be chained wrongly
If an exception's chain or context can refer to a pointer from a different
VM, a crash would typically result.

This couldn't turn up on UNIX testing because the VM is never torn
down and rebuilt like it is on hardware.

Because in the 'static' case the GeneratorObject is now fully initialized
whenever it's raised, the initialization can be dropped, which reduces
the flash size slightly.
Closes: #7565
2023-02-10 09:06:47 -06:00
Jim Mussared 9848b0685f py/mkrules.cmake: Force build mpversion.h and frozen_content.c.
This ensures that all builds unconditionally run makeversionhdr.py and
makemanifest.py to generate mpversion.h and frozen_content.c respectively.
This now matches the Makefile behavior, and in particular this fixes the
issue on ESP32 builds that changes in code-to-be-frozen will cause the
build to update. Both these already tools know not to touch their output
if there is no change.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-02-08 12:24:15 +11:00
Gregory Neverov abc5eb30d7 add support for array.extend(iterable) 2023-02-06 15:07:26 -08:00
gamblor21 6a9b7199ec Initial gif proof of concept 2023-02-04 16:44:29 -06:00