Commit Graph

9724 Commits

Author SHA1 Message Date
Paul Sokolovsky 6d4cac088e py/objtype: Make sure mp_binary_op_method_name has full size again.
After recent refactorings to mp_binary_op_t, and make it future refactoring
proof for now, at the cost of extra element in the array.
2017-09-07 12:54:58 +03:00
Paul Sokolovsky 50b9329eba py/runtime0.h: Move MP_BINARY_OP_DIVMOD to the end of mp_binary_op_t.
It starts a dichotomy of mp_binary_op_t values which can't appear in the
bytecode. Another reason to move it is to VALUES of OP_* and OP_INPLACE_*
nicely adjacent. This also will be needed for OP_REVERSE_*, to be soon
introduced.
2017-09-07 11:26:42 +03:00
Paul Sokolovsky d4d1c45a55 py/runtime0.h: Move relational ops to the beginning of mp_binary_op_t.
This is to allow to encode arithmetic operations more efficiently, in
preparation to introduction of __rOP__ method support.
2017-09-07 10:55:43 +03:00
KurticusMaximus ca1f3e5fb7 Added DotStar to line 72 2017-09-06 14:53:31 -07:00
Dan Halbert e0ddd528c8 Add Processor to microcontroller documentation TOC (#237) 2017-09-06 17:50:00 -04:00
Scott Shawcroft 6467e3d40b shared-bindings: Prevent check_lock from being optimized away. (#240)
Fixes #229
2017-09-06 17:49:30 -04:00
Dan Halbert acbca44512 Ctrl-C was causing a soft-reset in REPL.
Also allow an immediate ctrl-c in `input()`.
2017-09-06 14:47:23 -07:00
Paul Sokolovsky 5c603bd0fd py/objlist: Properly implement comparison with incompatible types.
Should raise TypeError, unless it's (in)equality comparison.
2017-09-07 00:10:10 +03:00
Scott Shawcroft c0159c5e80 atmel-samd: Ensure MTB is off in case we ran a debug build before
a non-debug build.
2017-09-06 11:56:41 -07:00
Damien George beeb7483d8 extmod/modussl_mbedtls: Allow to compile with MBEDTLS_DEBUG_C disabled.
With MBEDTLS_DEBUG_C disabled the function mbedtls_debug_set_threshold()
doesn't exist.  There's also no need to call mbedtls_ssl_conf_dbg() so a
few bytes can be saved on disabling that and not needing the mbedtls_debug
callback.
2017-09-06 17:34:45 +10:00
tll 68c28174d0 py/objstr: Add check for valid UTF-8 when making a str from bytes.
This patch adds a function utf8_check() to check for a valid UTF-8 encoded
string, and calls it when constructing a str from raw bytes.  The feature
is selectable at compile time via MICROPY_PY_BUILTINS_STR_UNICODE_CHECK and
is enabled if unicode is enabled.  It costs about 110 bytes on Thumb-2, 150
bytes on Xtensa and 170 bytes on x86-64.
2017-09-06 16:43:09 +10:00
Damien George 069fc48bf6 stm32/boards: Fix I2C1 pin mapping on NUCLEO_F401RE/F411RE boards.
This patch makes it consistent with the STM document describing the Arduino
layout.

Thanks to @shaoziyang for the original patch.
2017-09-06 15:41:12 +10:00
Damien George 21c889baeb stm32/boards: Change linker scripts to use "K" instead of hex byte size. 2017-09-06 15:24:08 +10:00
Damien George 81375eb470 stm32/boards: Change remaining stm32f4xx_hal_conf.h to unix line ending. 2017-09-06 15:02:21 +10:00
Damien George 3101a8fe32 stm32: Replace stray tabs with spaces. 2017-09-06 14:53:17 +10:00
Damien George f1dd0fd7df stm32: Remove unused usbd_msc.c file. 2017-09-06 14:50:08 +10:00
Damien George 4a93801c12 all: Update Makefiles and others to build with new ports/ dir layout.
Also renames "stmhal" to "stm32" in documentation and everywhere else.
2017-09-06 14:09:13 +10:00
Damien George 01dd7804b8 ports: Make new ports/ sub-directory and move all ports there.
This is to keep the top-level directory clean, to make it clear what is
core and what is a port, and to allow the repository to grow with new ports
in a sustainable way.
2017-09-06 13:40:51 +10:00
Damien George a9862b3006 .gitattributes: Add entries for files that will move to ports/ dir. 2017-09-06 13:37:57 +10:00
Scott Shawcroft 6baacf46b7 py: Only load frozen modules when the filename has the prefix. (#235)
* py: Only load frozen modules when the filename has the prefix.

This allows one to override a built-in module by loading a newer
version onto the file system.

* Unbreak mpys
2017-09-05 22:01:17 -04:00
Carol Willing f9c54665f7 Reduce depth in toc 2017-09-05 16:57:53 -07:00
Carol Willing 5c742e0058 rename some captions 2017-09-05 16:57:53 -07:00
Carol Willing 9df090f66b collapse board listings 2017-09-05 16:57:53 -07:00
Carol Willing 1f71851d3a Add a micropython section and edit drivers doc 2017-09-05 16:57:53 -07:00
Carol Willing 676a5b399e Structure contents to be user facing 2017-09-05 16:57:53 -07:00
Scott Shawcroft 6d9d683443 atmel-samd: Enable 8-bit audio recording support even though it'll be
quiet. Also update the examples.

Fixes #226
2017-09-05 16:37:02 -07:00
Paul Sokolovsky 1aaba5cabe py/objtuple: Properly implement comparison with incompatible types.
Should raise TypeError, unless it's (in)equality comparison.
2017-09-06 00:23:41 +03:00
Damien George e354b0a0cb stmhal/timer: Remove unnecessary include of USB header files. 2017-09-05 14:30:53 +10:00
Paul Sokolovsky 376618cd8a tests/class_inplace_op: Test for inplace op fallback to normal one. 2017-09-04 16:44:38 +03:00
Paul Sokolovsky 60749e57f2 py/objtype: Implement fallback for instance inplace special methods.
If __iop__ is not defined, call __op__ instead. This is desired behavior
for immutable types, __iop__ needs to be defined only for mutable types.
2017-09-04 16:44:21 +03:00
Damien George 77a48e8cd4 py/obj: Remove declaration for mp_obj_new_none(), it's never defined. 2017-09-04 23:35:46 +10:00
Tobias Badertscher 98da3cf407 stmhal: Fix clock initialisation of L4 MCUs.
There are 2 changes:
- remove early initialisation of LSE and replaced it by LSEDRIVE config
  (there is no reason to call HAL_RCC_OscConfig twice).
- add initialisation of the variables PLLSAI1Source and PLLSAI1M as they
  are needed in Cube HAL 1.8.1.
2017-09-04 17:45:08 +10:00
Damien George 689dae1211 cc3200: Use standard implementation of keyboard interrupt. 2017-09-04 17:32:14 +10:00
Robert HH ab9d7619fc cc3200: Enable micropython.kbd_intr() method 2017-09-04 17:19:59 +10:00
Damien George d4b75f6b68 py/obj: Fix comparison of float/complex NaN with itself.
IEEE floating point is specified such that a comparison of NaN with itself
returns false, and Python respects these semantics.  This patch makes uPy
also have these semantics.  The fix has a minor impact on the speed of the
object-equality fast-path, but that seems to be unavoidable and it's much
more important to have correct behaviour (especially in this case where
the wrong answer for nan==nan is silently returned).
2017-09-04 14:16:27 +10:00
Dan Halbert e1eb1802a6 esp8266: restore machine module 2017-09-02 18:54:27 -07:00
Paul Sokolovsky 9950865c39 py/objfloat: Fix binary ops with incompatible objects.
These are now returned as "operation not supported" instead of raising
TypeError. In particular, this fixes equality for float vs incompatible
types, which now properly results in False instead of exception. This
also paves the road to support reverse operation (e.g. __radd__) with
float objects.

This is achieved by introducing mp_obj_get_float_maybe(), similar to
existing mp_obj_get_int_maybe().
2017-09-02 23:05:24 +03:00
Scott Shawcroft 7932df02ab Style tweaks based on @willingc's feedback. 2017-09-01 13:54:29 -07:00
Scott Shawcroft 544f5c3fa4 docs: Add beginnings of troubleshooting doc.
Fixes #172. Related to #214.
2017-09-01 13:54:29 -07:00
Dan Halbert a0d0b27faf Fix issue #207, esp8266 file operations problems (#222)
The frozen module `_boot.py` was not being loaded on restart
because `pyexec_frozen_module()` did not know about the new `.frozen`
pseudo-directory. Updated lower-level routine to look in the right place.
Also made ".frozen" and related values be `#define`s.
2017-09-01 16:12:26 -04:00
Radomir Dopieralski c01bf678fd Merge pull request #223 from tannewt/baudrate_fix
atmel-samd: Remember SPI baudrate.
2017-09-01 21:56:44 +02:00
Scott Shawcroft e2f39a8d93 atmel-samd: Remember SPI baudrate.
This prevents the SERCOM from blipping the data line on each
transaction and therefore fixes #219.
2017-09-01 12:44:52 -07:00
Damien George dd376a239d py/nlrthumb: Get working again on standard Thumb arch (ie not Thumb2).
"b" on Thumb might not be long enough for the jump to nlr_push_tail so it
must be done indirectly.
2017-09-01 15:25:29 +10:00
Damien George 860eeeea9b py/qstrdefs: Remove unused qstrs.
They are not used by any component and take up valuable flash space.
2017-09-01 15:22:25 +10:00
Damien George 1ee6c3771f .gitattributes: Remove obsolete entries for stmhal/hal, stmhal/cmsis. 2017-09-01 11:32:58 +10:00
Damien George bebff0dab0 pic16bit: Add definition of SEEK_SET to unistd.h. 2017-09-01 11:23:09 +10:00
Damien George 2daacc5cee py/modstruct: Check and prevent buffer-write overflow in struct packing.
Prior to this patch, the size of the buffer given to pack_into() was checked
for being too small by using the count of the arguments, not their actual
size.  For example, a format spec of '4I' would only check that there was 4
bytes available, not 16; and 'I' would check for 1 byte, not 4.

The pack() function is ok because its buffer is created to be exactly the
correct size.

The fix in this patch calculates the total size of the format spec at the
start of pack_into() and verifies that the buffer is large enough.  This
adds some computational overhead, to iterate through the whole format spec.
The alternative is to check during the packing, but that requires extra
code to handle alignment, and the check is anyway not needed for pack().
So to maintain minimal code size the check is done using struct_calcsize.
2017-09-01 11:11:09 +10:00
Damien George 79d5acbd01 py/modstruct: Check and prevent buffer-read overflow in struct unpacking
Prior to this patch, the size of the buffer given to unpack/unpack_from was
checked for being too small by using the count of the arguments, not their
actual size.  For example, a format spec of '4I' would only check that
there was 4 bytes available, not 16; and 'I' would check for 1 byte, not 4.

This bug is fixed in this patch by calculating the total size of the format
spec at the start of the unpacking function.  This function anyway needs to
calculate the number of items at the start, so calculating the total size
can be done at the same time.
2017-09-01 10:53:29 +10:00
Damien George 793d826d9d py/modstruct: In struct.pack, stop converting if there are no args left.
This patch makes a repeat counter behave the same as repeating the
typecode, when there are not enough args.  For example:
struct.pack('2I', 1) now behave the same as struct.pack('II', 1).
2017-09-01 10:10:51 +10:00
Paul Sokolovsky b349479a49 tests/class_new: Add another testcase for __new__/__init__ interaction.
Similar to the existing testcase, but test that returning both value of
native type and instance of another user class from __new__ lead to
__init__ not being called, for better coverage.
2017-09-01 00:43:52 +03:00