Commit Graph

4655 Commits

Author SHA1 Message Date
Damien George 1446107b4d py/objarray: Use mp_obj_memoryview_init helper in mp_obj_new_memoryview.
Signed-off-by: Damien George <damien@micropython.org>
2021-05-18 00:22:53 +10:00
Limor "Ladyada" Fried 9752162508
Merge pull request #4765 from dhalbert/rotary-trinkey-rev-c-pins
Update various Trinkey pins and add _pixelbuf
2021-05-15 11:52:33 -04:00
Dan Halbert 1e2a945782 Make busio.SPI be NotImplementedError on proxlight to save space 2021-05-14 21:52:54 -04:00
Scott Shawcroft 689ec86225
Merge pull request #4754 from dhalbert/fix-endpoint-checking
Fix endpoint checking; Clean up safe mode printing
2021-05-14 11:25:01 -07:00
Dan Halbert fa6c06fb38 count in/out endpoints; allow more usb modules on low-endpoint boards 2021-05-13 21:59:02 -04:00
stijn 09be0c083c py/objarray: Implement more/less comparisons for array. 2021-05-13 22:16:14 +10:00
stijn 57365d8557 py/objarray: Prohibit comparison of mismatching types.
Array equality is defined as each element being equal but to keep
code size down MicroPython implements a binary comparison.  This
can only be used correctly for elements with the same binary layout
though so turn it into an NotImplementedError when comparing types
for which the binary comparison yielded incorrect results: types
with different sizes, and floating point numbers because nan != nan.
2021-05-13 22:16:14 +10:00
Jeff Epler 47947dc23c
Merge pull request #4749 from tannewt/merge_1.15
Merge in MicroPython 1.15
2021-05-12 20:52:11 -05:00
Scott Shawcroft 966d25c6a5
Merge MicroPython v1.15 into CircuitPython 2021-05-12 17:51:42 -07:00
Dan Halbert 0651ef17dd Fix endpoint checking; Clean up safe mode printing. 2021-05-12 15:53:52 -04:00
Damien George 300fc842ce py/mkenv.mk: Don't emit info about BUILD_VERBOSE if it's set.
If the user sets V or BUILD_VERBOSE then they don't need to see this
message.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-12 13:22:13 +10:00
Jeff Epler 45dc0953a5 makeqstrdata.py: Remove a problematic print
.. it contained non-ASCII characters, even when building the standard
English translation.

This may help resolve the build problems reported at #4750.
2021-05-11 21:48:21 -05:00
Scott Shawcroft e02a26453c
Merge MicroPython 1.14 into CircuitPython 2021-05-11 15:07:40 -07:00
Scott Shawcroft 80f9f51297
Merge pull request #4732 from jepler/fix-natmod-1.13
Fix all "natmod" (native module) examples
2021-05-10 12:37:44 -07:00
Jeff Epler ca74f282fd modmath: Remove stray "pragma GCC diagnostic pop"
This caused an error when building on macos:

```
../../py/modmath.c:247:36: error: pragma diagnostic pop could not pop, no matching push [-Werror,-Wunknown-pragmas]
            #pragma GCC diagnostic pop
                                   ^
1 error generated.
```

The pragma was half-removed during the merge of micropython.
2021-05-10 11:05:10 -05:00
Damien George b6b39bff47 py/gc: Make gc_lock_depth have a count per thread.
This commit makes gc_lock_depth have one counter per thread, instead of one
global counter.  This makes threads properly independent with respect to
the GC, in particular threads can now independently lock the GC for
themselves without locking it for other threads.  It also means a given
thread can run a hard IRQ without temporarily locking the GC for all other
threads and potentially making them have MemoryError exceptions at random
locations (this really only occurs on MCUs with multiple cores and no GIL,
eg on the rp2 port).

The commit also removes protection of the GC lock/unlock functions, which
is no longer needed when the counter is per thread (and this also fixes the
cas where a hard IRQ calling gc_lock() may stall waiting for the mutex).

It also puts the check for `gc_lock_depth > 0` outside the GC mutex in
gc_alloc, gc_realloc and gc_free, to potentially prevent a hard IRQ from
waiting on a mutex if it does attempt to allocate heap memory (and putting
the check outside the GC mutex is now safe now that there is a
gc_lock_depth per thread).

Signed-off-by: Damien George <damien@micropython.org>
2021-05-10 13:07:16 +10:00
Jeff Epler aca9d5bc40 Fix up all natmod examples
* modframebuf: _mp_framebuf_p_t is not "really" a protocol, but the
   QSTR assignment caused problems when building as a dynamic module
 * modure: str_index_to_ptr is not in the natmod API, disable URE match
   spans when dynamic.  mp_obj_len() is a bugfix, we should throw here
   if the object is not string-like
 * moduzlib: Correct paths to uzlib headers & sources.  this relative
   path (from moduzlib.c to the referenced file) works in all cases,
   the other only worked from ports/PORTNAME.
 * dynruntime: Handle 2-arg m_malloc, assert_native_inited, add a
   micropythonish mp_arg_check_num_mp, fix mp_raise_msg to use dumb
   strings, add mp_raise_arg1
 * nativeglue: ad assert_native_inited
 * translate: MP_ERROR_TEXT evaluates to its argument for DYNRUNTIME
 * mpy-tool: A straggling magic number change
 * mpy_ld: Have to renumber manually after dynruntime change
 * import_mpy_native_gc.py: Update copy of features0 baked into this test
2021-05-08 20:17:16 -05:00
Scott Shawcroft cebb10ddae
Fixes from review 2021-05-07 09:31:59 -07:00
Scott Shawcroft 42f4065c8a
Merge remote-tracking branch 'adafruit/main' into merge_1.13 2021-05-06 11:17:53 -07:00
Dan Halbert ebf9dcb47a
Merge pull request #4689 from dhalbert/dynamic-usb-descriptors
Dynamic USB descriptors
2021-05-06 13:51:38 -04:00
Scott Shawcroft 71d2536725
Build fixes thanks to jepler 2021-05-06 09:04:56 -07:00
Scott Shawcroft 3fda0c0a1b
Fix board builds and use MP_ERROR_TEXT in py and extmod 2021-05-05 17:51:52 -07:00
Jeff Epler ef3ec93c8b Change the first byte of CircuitPython 'mpy' files to "C"
.. and also distinguish CircuitPython better in `mpy-cross --version`
2021-05-05 18:06:06 -05:00
Dan Halbert 579cdf30f1 fix more build errors 2021-05-05 16:49:29 -04:00
Jeff Epler 716a82ba67 set the coroutine generator for native generators 2021-05-05 11:36:40 -05:00
Dan Halbert fc8e1c4c2e address review comments 2021-05-05 12:35:12 -04:00
Jeff Epler 68d4682298 compile: Reserve labels for native await 2021-05-05 11:00:39 -05:00
Jeff Epler 8fae7d2e30 runtime.c: Fix reading properties
.. this fixes the vfs_fat_ramdisk failure.
2021-05-05 11:00:39 -05:00
Jeff Epler c3ce2bacde runtime: Remove unneeded includes
objtype.h got included twice, and vfs.h is unneeded.
2021-05-05 11:00:39 -05:00
Jeff Epler 14e0bdbae3 Move mp_get_stream non-inline
This caused a build error with external native code, as
MP_QSTR_protocol_stream was not available.
2021-05-05 11:00:35 -05:00
Jeff Epler 2c0664ea3f slice: restore ability to construct a slice 2021-05-05 08:47:15 -05:00
Artyom Skrobov 269d5bc80a qstr: One more cast could be avoided. 2021-05-05 09:01:47 +03:00
Scott Shawcroft f0bb26d70f
Merge MicroPython 1.13 into CircuitPython 2021-05-04 18:06:33 -07:00
Dan Halbert 8bb3c6fd79 handle := defs in shared_bindings_matrix.py; update adafruit_hid 2021-05-04 18:07:01 -04:00
Artyom Skrobov 2d73ba2186 qstr: Use `const` consistently to avoid a cast. 2021-05-04 12:53:35 -04:00
Dan Halbert adc3d7d55e update Python API according to review comments 2021-05-03 22:29:02 -04:00
Dan Halbert d2b558993e merge from main, including MicroPython 1.12 merge 2021-05-03 20:56:04 -04:00
Scott Shawcroft b35fa44c8a
Merge MicroPython 1.12 into CircuitPython 2021-05-03 14:01:18 -07:00
Dan Halbert 94ed5e0048
Merge pull request #4696 from dhalbert/no-pulseio-on-small-boards
Include pulseio only on CIRCUITPY_FULL_BUILD
2021-05-03 09:35:29 -04:00
Artyom Skrobov ca35c0059c py/repl: Autocomplete builtin modules.
Doing "import <tab>" will now complete/list built-in modules.

Originally at adafruit#4548 and adafruit#4608

Signed-off-by: Artyom Skrobov <tyomitch@gmail.com>
2021-05-02 23:11:14 +10:00
Artyom Skrobov 7556e01f14 py/repl: Refactor autocomplete, extracting reusable parts.
Originally at adafruit#4548

Signed-off-by: Artyom Skrobov <tyomitch@gmail.com>
2021-05-02 23:11:12 +10:00
Artyom Skrobov f85ea8d4fe py/repl: Refactor autocomplete to reduce nesting.
Originally at adafruit#4548

Signed-off-by: Artyom Skrobov <tyomitch@gmail.com>
2021-05-02 23:11:10 +10:00
scottbelden befbff31b7 py/repl: Enter four spaces when there are no matches.
Originally at adafruit#1859

Signed-off-by: scottbelden <scottabelden@gmail.com>
2021-05-02 23:11:07 +10:00
Kathryn Lingel 1f1a54d0b1 py/repl: Filter private methods from tab completion.
Anything beginning with "_" will now only be tab-completed if there is
already a partial match for such an entry.  In other words, entering
foo.<tab> will no longer complete/list anything beginning with "_".

Originally at adafruit#1850

Signed-off-by: Kathryn Lingel <kathryn@lingel.net>
2021-05-02 23:11:03 +10:00
Damien George aa061ae391 py/scheduler: Add missing MICROPY_WRAP_MP_SCHED_EXCEPTION usage.
This was missed in commit 7cbf826a95.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-01 23:10:26 +10:00
Dan Halbert 96101016ec Include pulseio only on CIRCUITPY_FULL_BUILD 2021-04-30 23:13:32 -04:00
Jeff Epler da19e8e2d7 Merge remote-tracking branch 'origin/main' into fix-codeformat-subdirs 2021-04-30 15:31:08 -05:00
Jeff Epler dfa7c3d32d codeformat: Fix handling of `**`
After discussing with danh, I noticed that `a/**/b` would not match `a/b`.

After correcting this and re-running "pre-commit run --all", additional
files were reindented, including the codeformat script itself.
2021-04-30 15:30:13 -05:00
Scott Shawcroft 0573c17d70
Merge pull request #4690 from jepler/fix-vm-dispatch
py/vm.c: Restore lost bits of MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE
2021-04-30 10:40:07 -07:00
Dan Halbert 353e55d710
Merge pull request #4688 from jepler/fix-pixelbuf-subscr
objtype: Restore our customized behavior of instance_subscr
2021-04-30 10:45:44 -04:00
Jeff Epler 41b273e0c1 py/vm.c: Restore lost bits of MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE
This fixes a problem where boards that enabled this (most SAM D21s)
would crash on the first bytecode instruction.

Closes: #4686
2021-04-30 09:17:40 -05:00
Damien George 6b7c8d3e72 py/runtime: Remove commented-out code from mp_deinit().
These commented-out lines of code have been unused for a long time, so
remove them to avoid confusion as to why they are there.

mp_obj_dict_free() never existed, this line was converted from
mp_map_deinit() and commented out as soon as it was added.  The call to
mp_map_deinit(mp_loaded_modules_map) was commented in
1a1d11fa32.

Fixes issue #3507.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 16:35:14 +10:00
Damien George 916c3fd23f py/scheduler: Add optional port hook for when something is scheduled.
So that a port can "wake up" when there is work to do.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:32:16 +10:00
Damien George e9e9c76ddf all: Rename mp_keyboard_interrupt to mp_sched_keyboard_interrupt.
To match mp_sched_exception() and mp_sched_schedule().

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:13:43 +10:00
Damien George 7cbf826a95 py/scheduler: Add mp_sched_exception() to schedule a pending exception.
This helper is added to properly set a pending exception, to mirror
mp_sched_schedule(), which schedules a function.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:13:43 +10:00
Damien George 7e549b6718 py/profile: Use mp_handle_pending() to raise pending exception.
If MICROPY_ENABLE_SCHEDULER is enabled then MP_STATE_VM(sched_state) must
be updated after handling the pending exception, which is done by the
mp_handle_pending() function.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:13:43 +10:00
Jeff Epler d1e17fdccc objtype: Restore our customized behavior of instance_subscr
For pixelbuf's [] to be able to call _transmit on the Python subclass,
we need to do the subscripting operation specially.
2021-04-29 11:59:11 -05:00
microDev 1b972c51c3
add authmode class 2021-04-29 18:42:36 +05:30
Dan Halbert f06d54524d merge from adafruit 2021-04-28 23:48:26 -04:00
Dan Halbert 8500e846c6 partially working 2021-04-27 23:53:23 -04:00
Dan Halbert f98a54628b wip: compiles 2021-04-27 14:37:36 -04:00
Scott Shawcroft 17fcd499b2
Merge pull request #4649 from tannewt/merge_1.11_2
Merge MicroPython v1.11 into CircuitPython
2021-04-27 11:02:02 -07:00
Damien George c5cbfd545a py/dynruntime.h: Add mp_obj_get_array() function.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-28 00:06:46 +10:00
Damien George d4b706c4d0 py: Add option to compile without any error messages at all.
This introduces a new option, MICROPY_ERROR_REPORTING_NONE, which
completely disables all error messages.  To be used in cases where
MicroPython needs to fit in very limited systems.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-27 23:51:52 +10:00
Dan Halbert 7a40b4daec very much WIP 2021-04-26 23:54:01 -04:00
Scott Shawcroft 76033d5115
Merge MicroPython v1.11 into CircuitPython 2021-04-26 15:47:41 -07:00
Dan Halbert c26e49c2e6 wip: starting to try to compile 2021-04-25 23:17:41 -04:00
Dan Halbert 9d1fcc3b14 merge from main 2021-04-25 10:27:52 -04:00
Dan Halbert 2ba2574ebf
Merge pull request #4619 from tyomitch/microbit
[build] Allow USB to be set to 0
2021-04-24 10:31:29 -04:00
Scott Shawcroft 80e8b4ac14
Merge pull request #4635 from jepler/pcc
WIP: Implement 'ParallelImageCapture' for samd51
2021-04-23 13:31:53 -07:00
Artyom Skrobov 4e3c1d4a4c [build] Allow USB to be set to 0
Unify USB-related makefile var and C def as CIRCUITPY_USB.

Always define it as 0 or 1, same as all other settings.

USB_AVAILABLE was conditionally defined in supervisor.mk,
but never actually used to #ifdef USB-related code.

Loosely related to #4546
2021-04-23 11:13:34 -04:00
Damien George 3c4bfd1dec py/objexcept: Support errno attribute on OSError exceptions.
This commit adds the errno attribute to exceptions, so code can retrieve
errno codes from an OSError using exc.errno.

The implementation here simply lets `errno` (and the existing `value`)
attributes work on any exception instance (they both alias args[0]).  This
is for efficiency and to keep code size down.  The pros and cons of this
are:

Pros:
- more compatible with CPython, less difference to document and learn
- OSError().errno will correctly return None, whereas the current way of
  doing it via OSError().args[0] will raise an IndexError
- it reduces code size on most bare-metal ports (because they already have
  the errno qstr)
- for Python code that uses exc.errno the generated bytecode is 2 bytes
  smaller and more efficient to execute (compared with exc.args[0]); so
  bytecode loaded to RAM saves 2 bytes RAM for each use of this attribute,
  and bytecode that is frozen saves 2 bytes flash/ROM for each use
- it's easier/shorter to type, and saves 2 bytes of space in .py files that
  use it (for each use)

Cons:
- increases code size by 4-8 bytes on minimal ports that don't already have
  the `errno` qstr
- all exceptions now have .errno and .value attributes (a cpydiff test is
  added to address this)

See also #2407.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-23 22:03:46 +10:00
Scott Shawcroft 09f7b43c64
Merge MicroPython 1.10 into CircuitPython 2021-04-21 15:59:17 -07:00
Scott Shawcroft b057fb8a4b
codeformat 2021-04-19 22:22:44 -07:00
Dan Halbert 51ccf8dc30 wip: revert usb_descriptor changes; use raw descriptors instead 2021-04-19 23:24:18 -04:00
Jeff Epler 18548fc5d2
Merge pull request #4620 from tannewt/fix_struct_pack
Fix struct.pack with padding bytes
2021-04-19 20:43:20 -05:00
Scott Shawcroft 6620ac8bec
Fix py version of struct too. 2021-04-19 14:59:40 -07:00
Scott Shawcroft e54e5e3575
Merge pull request #4564 from tyomitch/patch-1
[build] simplify makeqstrdata heuristic
2021-04-19 14:50:42 -07:00
Jeff Epler 76d68f21ac displayio: Add RGB555/565/_SWAPPED format support
This is helpful when displaying frames from an OV7670 camera, which
uses the RGB565_SWAPPED format internally.
2021-04-19 10:23:47 -05:00
Damien George 321d1897c3 all: Bump version to 1.15.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-19 00:11:51 +10:00
Jeff Epler fc4538f845 WIP: Implement 'ParallelImageCapture' for samd51 2021-04-16 17:18:59 -05:00
Scott Shawcroft 5ccd5dc08b
Fix struct.pack with padding bytes
It used to validate the following arg could fit in a single byte.
Now, it always uses zero to pad.
2021-04-16 12:39:23 -07:00
Artyom Skrobov d9e15adb01 [repl] Don't autocomplete globals after "import " 2021-04-14 12:16:28 -04:00
Dan Halbert 4a7e129287 wip: latent usb device enabling/disabling 2021-04-13 23:33:44 -04:00
Artyom Skrobov c6ee471b52 Merge branch 'main' of https://github.com/adafruit/circuitpython into patch-3 2021-04-13 00:32:19 -04:00
Scott Shawcroft bd5a3a3ba4
Merge pull request #4583 from tyomitch/patch-2
[qstr] Separate hash and len from string data
2021-04-12 15:06:40 -07:00
matejcik 1a2ffda175 py/runtime: Make sys.modules preallocate to a configurable size.
This allows configuring the pre-allocated size of sys.modules dict, in
order to prevent unwanted reallocations at run-time (3 sys-modules is
really not quite enough for a larger project).
2021-04-12 22:36:16 +10:00
matejcik b26def0644 py/profile: Resolve name collision with STATIC unset.
When building with STATIC undefined (e.g., -DSTATIC=), there are two
instances of mp_type_code that collide at link time: in profile.c and in
builtinevex.c.  This patch resolves the collision by renaming one of them.
2021-04-12 22:31:42 +10:00
Dan Halbert c333acdbad
Merge pull request #4589 from hugodahl/feature/Remove-MicroPython-mention-in-error-messages
Make error messages platform agnostic
2021-04-10 21:30:17 -04:00
Hugo Dahl 36f3897fe3 Make error messages platform agnostic
Remove mentions of 'MicroPython' in error messages as they could lead to confusion in lesser-experienced users
2021-04-10 18:36:53 -05:00
Artyom Skrobov dcee89ade7 build: simplify compute_huffman_coding()
No functional change.
2021-04-09 08:36:26 -04:00
Artyom Skrobov 68920682b6 [build] simplify makeqstrdata heuristic
The simpler one saves, on average, 51 more bytes per translation;
the biggest translation per board is reduced, on average, by 85 bytes.
2021-04-09 07:18:40 -04:00
Damien George 5dcc9b3b16 py/py.cmake: Introduce MICROPY_INC_CORE as a list with core includes.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-09 13:08:35 +10:00
Damien George 0fabda31de py/py.cmake: Move qstr helper code to micropy_gather_target_properties.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-09 13:08:35 +10:00
Jeff Epler 3ce0b512f8 rasberrypi: IncrementalEncoder: factor out state machine 2021-04-08 16:25:47 -05:00
Artyom Skrobov c3e40d50ab [qstr] Separate hash and len from string data
This allows the compiler to merge strings: e.g. "update",
"difference_update" and "symmetric_difference_update"
will all point to the same memory.

Shaves ~1KB off the image size, and potentially allows
bigger savings if qstr attrs are initialized in qstr_init(),
and not stored in the image.
2021-04-06 12:58:42 -04:00
Artyom Skrobov 59fa9b01ad [repl] Autocomplete builtin modules 2021-04-03 16:56:02 -04:00
Artyom Skrobov 1d55dee15b [repl] Refactor autocomplete, extracting reusable parts 2021-04-03 16:54:34 -04:00
Artyom Skrobov 6e17db3286 [repl] Refactor autocomplete to reduce nesting 2021-04-03 15:54:36 -04:00
Jeff Epler fb7b968b10 py.mk: locate ulab sources with shell-find. 2021-04-02 13:09:23 -05:00