Commit Graph

4581 Commits

Author SHA1 Message Date
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
Jeff Epler dc9daba906 update ulab to 2.1.5 2021-04-02 13:09:23 -05:00
Phil Howard 0cf12dd59c rp2: Add support for USER_C_MODULES to CMake build system.
The parts that are generic are added to py/ so they can be used by other
ports that use CMake.

py/usermod.cmake:

* Creates a usermod target to hang user C/CXX modules from.
* Gathers sources from user C/CXX modules and libs for QSTR scan.

ports/rp2/CMakeLists.txt:

* Includes py/usermod.cmake.
* Links the resulting usermod library to the MicroPython target.

py/mkrules.cmake:

Add cxxflags to qstr.i.last custom command for CXX modules:

* MICROPY_CPP_FLAGS so CXX modules will find includes.
* -DNO_QSTR to fix fatal error missing "genhdr/qstrdefs.generated.h".

Usage:

The rp2 port can be linked against user C modules by running:

make USER_C_MODULES=/path/to/module/micropython.cmake

CMake will print a list of included modules.

Co-authored-by: Graham Sanderson <graham.sanderson@raspberrypi.org>
Co-authored-by: Michael O'Cleirigh <michael.ocleirigh@rivulet.ca>
Signed-off-by: Phil Howard <phil@pimoroni.com>
2021-03-31 00:26:01 +11:00
Artyom Skrobov 8056af8648 [synthio] add a simple MidiTrack implementation 2021-03-26 16:38:10 -04:00
Artyom Skrobov d7dc3801ab [ure] to save space, disable debug dumps by default
Has to stay enabled in unix port for the sake of tests/extmod/ure_debug.py
2021-03-26 13:24:20 -04:00
Damien George 9fef1c0bde py: Rename remaining object types to be of the form mp_type_xxx.
For consistency with all other object types in the core.

Signed-off-by: Damien George <damien@micropython.org>
2021-03-26 13:48:34 +11:00
Damien George 42cf77f48b py/vm: For tracing use mp_printf, and print state when thread enabled.
mp_printf should be used to print the prefix because it's also used in
mp_bytecode_print2 (otherwise, depending on the system, different output
streams may be used).

Also print the current thread state when threading is enabled to easily see
which thread executes what opcode.

Signed-off-by: Damien George <damien@micropython.org>
2021-03-17 12:13:53 +11:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Dan Halbert 5ace7af933 disable default usb_cdc 2021-03-11 11:20:29 -05:00
Yonatan Goldschmidt e196cb762e py/nlrx64: Fix typo in comment. 2021-03-11 12:51:10 +11:00
Yonatan Goldschmidt 2d5cece5ac py/nlr: Implement NLR for AArch64. 2021-03-11 12:51:10 +11:00
Jeff Epler 1e5ffe1a53 Revert "circuitpy_mpconfig: Disable flash multi-partition"
This reverts commit 156ee4833a.
2021-03-09 11:08:36 -06:00
Scott Shawcroft b5a955a168
Merge pull request #4354 from jepler/disable-fat-partition
circuitpy_mpconfig: Disable flash multi-partition
2021-03-08 15:25:58 -08:00
Jeff Epler 156ee4833a circuitpy_mpconfig: Disable flash multi-partition
This adds some additional code in mkfs which doesn't seem necessary, and
Disabling it saves 172 bytes flash.

Testing performed: Using a Feather M0 Adalogger, checked that
 * an sdcard could still be mounted (using adafruit_sdcard)
 * os.listdir() of "/" and "/sd" worked
 * CIRCUITPY still mounted
2021-03-07 09:37:18 -06:00
Jeff Epler 4f040af481 vm: Make the speed-size trade-off compile time settable
.. and enable for all samd21 boards
2021-03-05 18:29:27 -06:00
Jeff Epler 7b359d7a8a vm: Consolodate all dispatch instructions
Flash savings: 1268 bytes
Performance: 10,000 iteration loop .665 -> .676s (+1.7%)
2021-03-05 16:52:35 -06:00
Jeff Epler 28638df589 vm: cut vmentrytable size
This also adds a bit of code everywhere we DISPATCH(), but the net is
+232 bytes free on Feather M0 Adalogger.

Key assumption: All of the offsets in mp_execute_bytecode fit in 16 bits;
it is not clear whether the compiler will verify this assumption (e.g.,
by warning that a constant will be truncated)
2021-03-05 16:52:35 -06:00
Scott Shawcroft e4f0e47d9f
Merge pull request #4233 from pewpew-game/displayio-group-list
displayio: make Group use a python list internally
2021-03-02 09:59:58 -08:00
Scott Shawcroft d0eab5c561
Merge pull request #4256 from kmatch98/bt_cleanup
Add `bitmaptools` module
2021-03-01 18:24:12 -08:00
Radomir Dopieralski 24473b7983 Separate out mp_obj_list_insert for use in display.Group
Note that for some reason this makes the binary 500 bytes larger!
2021-02-27 21:13:55 +01:00
Radomir Dopieralski e505c59ed8 Separate mp_obj_list_pop so it can be used outside of objlist.c 2021-02-27 20:52:38 +01:00
Scott Shawcroft 3f08cb47b8
Merge remote-tracking branch 'adafruit/main' into busio-uart-rp 2021-02-25 16:59:15 -08:00
Scott Shawcroft 52bc935fa7
A few minor fixes for corner cases
* Always clear the peripheral interrupt so we don't hang when full
* Store the ringbuf in the object so it gets collected when we're alive
* Make UART objects have a finaliser so they are deinit when their
  memory is freed
* Copy bytes into the ringbuf from the FIFO after we read to ensure
  the interrupt is enabled ASAP
* Copy bytes into the ringbuf from the FIFO before measuring our
  rx available because the interrupt is based on a threshold (not
  > 0). For example, a single byte won't trigger an interrupt.
2021-02-25 16:50:57 -08:00
Kevin Matocha a7a4f93ff8 Updated build configs to turn off BITMAPTOOLS for smaller builds 2021-02-25 15:44:32 -06:00
Kevin Matocha b720028642 Add bitmaptools module 2021-02-23 23:23:14 -06:00
Dan Halbert 7a4198885e Fix typos for CIRCUITPY_USB_HID_SYS_CONTROL 2021-02-23 09:22:20 -05:00
Dan Halbert 93bf269c0d Avoid pulling in extra float-uint64 routines 2021-02-21 12:05:03 -05:00
Damien George 2adf20c5f2 py/mkrules.cmake: Add MICROPY_QSTRDEFS_PORT to qstr build process.
This allows a port to specify a custom qstrdefsport.h file, the same as the
QSTR_DEFS variable in a Makefile.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-21 15:56:54 +11:00
Damien George d867d20d9a py/mkrules.cmake: Rename QSTR_DEFS variables to QSTRDEFS.
And also MICROPY_PY_QSTRDEFS to MICROPY_QSTRDEFS_PY.  These variables are
all related.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-21 15:56:54 +11:00
Jeff Epler a04369e0f5 add ifdef-guard 2021-02-20 17:41:08 -06:00
Jeff Epler 646eb9a7db py: memoryview: implement memoryview.cast if CPYTHON_COMPAT 2021-02-20 10:35:36 -06:00
Dan Halbert 076a7b7161 CIRCUITPY_BITOPS merge error 2021-02-19 15:30:27 -05:00
Dan Halbert 67406488d1 merge from upstream; re-alphabetize 2021-02-19 14:22:50 -05:00
Jeff Epler 72e8fb085c remove debug print during build 2021-02-18 16:01:23 -06:00
Jeff Epler 7fd4567893 bitops: rename from _bit_transpose, describe the algorithm 2021-02-18 15:41:23 -06:00
Jeff Epler 9cf7d73c6c core: add bit_transpose function
.. this version can only handle exactly 8 bits "across".  The restriction
may be relaxed in a future revision.
2021-02-18 11:32:47 -06:00
Dan Halbert ed49c02feb add timeout; finish up for PR 2021-02-17 23:24:11 -05:00
Maureen Helm dff6fc64d2 py: Expand lists in core cmake custom commands.
The core cmake rules use custom commands to invoke qstr processing
scripts. For the zephyr port, it's possible that list arguments to these
commands may contain generator expressions, therefore we need to expand
them properly.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2021-02-16 18:38:13 +11:00
Dan Halbert 93d788543c Merge remote-tracking branch 'adafruit/main' into secondary-cdc 2021-02-15 20:03:53 -05:00
Bernhard Boser f8f59598c7 memoryview is valid argument to exec 2021-02-15 10:05:57 -08:00
Damien George 66098c0985 py,extmod: Add core cmake rule files.
These allow a port to use cmake natively instead of make.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-15 12:48:18 +11:00
Dan Halbert d54b5861a3 wip 2021-02-12 19:01:14 -05:00
Dan Halbert f0564b4986 merge from upstream; complicated webusb merge 2021-02-11 18:50:02 -05:00
Damien George 0a59938574 py/mpz: Fix overflow of borrow in mpn_div.
For certain operands to mpn_div, the existing code path for
`DIG_SIZE == MPZ_DBL_DIG_SIZE / 2` had a bug in it where borrow could still
overflow in the `(x >= *n || *n - x <= borrow)` branch, ie
`borrow + x - (mpz_dbl_dig_t)*n` overflows the borrow variable.  In such
cases the subsequent right-shift of borrow would not bring in the overflow
bit, leading to an error in the result.  An example division that had
overflow when MPZ_DIG_SIZE = 16 is `(2 ** 48 - 1) ** 2 // (2 ** 48 - 1)`.

This is fixed in this commit by simplifying the code and handling the low
digits of borrow first, and then the upper bits (to shift down) separately.
There is no longer a distinction between `DIG_SIZE < MPZ_DBL_DIG_SIZE / 2`
and `DIG_SIZE == MPZ_DBL_DIG_SIZE / 2`.

This commit also simplifies the second part of the calculation so that
borrow does not need to be negated (instead the code just works knowing
that borrow is negative and using + instead of - in calculations involving
borrow).

Fixes #6777.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-08 11:50:05 +11:00
Damien George 9dedcf122d py/gc: Change include of stdint.h to stddef.h.
No std-int types are used in gc.h, but size_t is which needs stddef.h.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-05 15:46:56 +11:00
Dan Halbert 0802b22ed6 usb descriptors all set; rework of enabling for USB devices 2021-02-04 19:23:40 -05:00
Damien George c891190c69 py: Rename WORD_MSBIT_HIGH to MP_OBJ_WORD_MSBIT_HIGH.
To make it clear it is for mp_obj_t/mp_uint_t "word" types, and to prefix
this macro with MP_.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-04 22:46:42 +11:00
Damien George ad4656b861 all: Rename BYTES_PER_WORD to MP_BYTES_PER_OBJ_WORD.
The "word" referred to by BYTES_PER_WORD is actually the size of mp_obj_t
which is not always the same as the size of a pointer on the target
architecture.  So rename this config value to better reflect what it
measures, and also prefix it with MP_.

For uses of BYTES_PER_WORD in setting the stack limit this has been
changed to sizeof(void *), because the stack usually grows with
machine-word sized values (eg an nlr_buf_t has many machine words in it).

Signed-off-by: Damien George <damien@micropython.org>
2021-02-04 22:46:42 +11:00
Damien George 7e956fae28 py: Rename BITS_PER_BYTE to MP_BITS_PER_BYTE.
To give this macro a standard MP_ prefix.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-04 22:46:42 +11:00
Damien George 8a41ee19c2 py: Remove BITS_PER_WORD definition.
It's only used in one location, to test if << or >> will overflow when
shifting mp_uint_t.  For such a test it's clearer to use sizeof(lhs_val),
which will be valid even if the type of lhs_val changes.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-04 22:46:42 +11:00
Xiang Xiao 5fdf351178 py/gc: Don't include mpconfig.h and misc.h in gc.h.
Because gc.h doesn't reference any symbol from these header files.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-02-04 22:37:26 +11:00
Kevin Banks 215a56c920 Merge branch 'main' into webusb (trying to get CI back online) 2021-02-03 16:48:28 -06:00
Damien George 78b23c3a1f all: Bump version to 1.14.
Signed-off-by: Damien George <damien@micropython.org>
2021-02-03 00:59:07 +11:00
Lucian Copeland 66639b237f Merge remote-tracking branch 'upstream/main' into sslsocket 2021-02-01 11:43:01 -05:00
iTitou 4fb5f012c3 py/makeversionhdr: Honor SOURCE_DATE_EPOCH if present.
This environment variable, if defined during the build process,
indicates a fixed time that should be used in place of "now" when
such a time is explicitely referenced.

This allows for reproducible builds of micropython.
See https://reproducible-builds.org/specs/source-date-epoch/

Signed-off-by: iTitou <moiandme@gmail.com>
2021-01-31 17:48:59 +01:00
David CARLIER cb30928ac8 py/persistentcode: Introduce MICROPY_PERSISTENT_CODE_SAVE_FILE option.
This should be enabled when the mp_raw_code_save_file function is needed.

It is enabled for mpy-cross, and a check for defined(__APPLE__) is added to
cover Mac M1 systems.
2021-01-30 15:13:24 +11:00
stijn cb8e2f02ab py/gc: Fix debug printing of pointer.
When DEBUG_printf is the standard printf, compilers require the value for
%p to be an actual pointer instead of an integer.
2021-01-30 14:41:29 +11:00
stijn b9a35bebf7 py/qstr.h: Remove QSTR_FROM_STR_STATIC macro.
It practically does the same as qstr_from_str and was only used in one
place, which should actually use the compile-time MP_QSTR_XXX form for
consistency; qstr_from_str is for runtime strings only.
2021-01-30 13:40:48 +11:00
graham sanderson 794df0f1d5 py/emitnative: Support binary ops on ARMv6M without use of ite instr. 2021-01-29 23:57:10 +11:00
Damien George 75fea330bf py/emitinlinethumb: Exclude code using #if when ARMV7M disabled.
So there are no references to undeclared asm_thumb_mov_reg_i16().

Signed-off-by: Damien George <damien@micropython.org>
2021-01-29 23:57:10 +11:00
Damien George c9f4c5acd6 py/emitnative: Ensure encoding to load prelude_offset doesn't change sz.
Based on change made by Graham Sanderson.

Signed-off-by: Damien George <damien@micropython.org>
2021-01-29 23:57:10 +11:00
graham sanderson 40d2010882 py/asmthumb: Add support for ARMv6M in native emitter.
Adds a new compile-time option MICROPY_EMIT_THUMB_ARMV7M which is enabled
by default (to get existing behaviour) and which should be disabled (set to
0) when building native emitter support (@micropython.native) on ARMv6M
targets.
2021-01-29 23:57:10 +11:00
Damien George 925bd67cfb py/objfun: Support fun.__globals__ attribute.
This returns a reference to the globals dict associated with the function,
ie the global scope that the function was defined in.  This attribute is
read-only but the dict itself is modifiable, per CPython behaviour.

Signed-off-by: Damien George <damien@micropython.org>
2021-01-29 23:57:10 +11:00
Kevin Banks b152c658e2 Making WebUSB default to off (build unbreakage, caught by CI) 2021-01-26 18:18:39 -06:00
Dan Halbert 13812a788f
Merge pull request #4060 from dhalbert/regularize-extmod-modules
CIRCUITPY_* switches for JSON, RE, etc. Doc cleanup
2021-01-26 12:54:21 -05:00
Dan Halbert da6869dbd5 Set MICROPY_PY_UERRNO_ERRORCODE correctly 2021-01-26 08:37:05 -05:00
Dan Halbert a9f339b461 typo in circuitpy_mpconfig.h; forgot cxd56 port 2021-01-25 22:40:31 -05:00
Kevin Banks fbfb7b68cc Most of the code we need has been pulled in from the tinyusb webusb_serial demo. Still LOTS to do regarding descriptors. 2021-01-25 20:37:58 -06:00
Scott Shawcroft a2ac2da7cc
Merge pull request #3936 from gamblor21/busdevice_fixes
Changing adafruit_bus_device to duck typing
2021-01-25 14:41:53 -08:00
Lucian Copeland 9f34ec78c4 Separate Socket and SSLSocket, add LWIP connect 2021-01-25 17:07:25 -05:00
Dan Halbert 69869e1439 CIRCUITPY_* switches for JSON, RE, etc. Doc cleanup 2021-01-24 23:10:20 -05:00
Dan Halbert e3275be8b1
Merge pull request #3911 from hugodahl/add-translation-for-builtin-object-help
Update built-in help output for localization (Issue #3907)
2021-01-22 03:49:19 -05:00
Scott Shawcroft b7a63dc498
Alphabetical 2021-01-21 10:18:04 -08:00
Scott Shawcroft 733094aead
Add initial RP2040 support
The RP2040 is new microcontroller from Raspberry Pi that features
two Cortex M0s and eight PIO state machines that are good for
crunching lots of data. It has 264k RAM and a built in UF2
bootloader too.

Datasheet: https://pico.raspberrypi.org/files/rp2040_datasheet.pdf
2021-01-20 19:16:56 -08:00
gamblor21 f50c9f4145 Reenabling busdevice in core 2021-01-16 14:21:57 -06:00