Skip to content

Merge MicroPython v1.9.2 #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 254 commits into from
Aug 28, 2017
Merged

Merge MicroPython v1.9.2 #208

merged 254 commits into from
Aug 28, 2017

Conversation

dhalbert
Copy link
Collaborator

Some notes on MicroPython v1.9.2 changes. There are many fixes, and also many stylistic changes. I'll put this in the commit message or a pull request comment as well:

Micro Python -> MicroPython everywhere.

#include guard #define's lose their leading and trailing double underscores

(The above two affect many files and account for the majority of changes in the merge. I've edited our own code to include those stylistic changes going forward.)

nlr_raise_whatever -> mp_raise_whatever (higher level exception raising).

Double precision added, including libm_dbl double precision math library added.

Many tests improved.

For STATIC dicts, mp_map_elem_t replaced by mp_rom_map_elem_t, and the macros defining the entries changed from OBJ_NEW_whatever to MP_ROM_whatever. I made pass over our own code to do this as well.

mp_uint_t -> size_t where appropriate.

.. -> $(TOP) in makefiles.

Some changes and additions to rst documentation markup. See CODECONVENTIONS.md for details. In particular, argument names are asterisk'd, not backquoted. Addition of docs/templates/replace.inc; it includes boilerplate text that can be inserted by inserting a small |something| marker.

pfalcon and others added 30 commits June 13, 2017 17:39
axTLS 2.1.3 brings support for TLS 1.2 and SNI. With MicroPython patchset
on top of it, the code size growth (x86) is ~2K.
ssl_client_new() accepts new SSL_EXTENSIONS* argument.
The latest fashion is pushing certificate sub-chains, instead of a single
certificate, during TLS handshake. These are pushed via single TLS record
and effectively put minimum size limit on TLS record buffer. Recently,
these commonly grew over 4K, so we have little choice but to adjust.
The default for the GIL is to enable it if threading is enabled, and this
is the recommended way to use threading with the stmhal port.
These implementations are incorrect (eg f2d and d2f don't handle special
values like 0.0) and proper versions can be provided by libgcc (or
equivalent depending on the toolchain).

libgcc is now linked with the stmhal port so that library will provide
these functions from now on.
Following how extmod/modlwip.c does it.
In CPython 3.4 this raises a SyntaxError.  In CPython 3.5+ having a
positional after * is allowed but uPy has the wrong semantics and passes
the arguments in the incorrect order.  To prevent incorrect use of a
function going unnoticed it is important to raise the SyntaxError in uPy,
until the behaviour is fixed to follow CPython 3.5+.
This method follows the new HW API and allows to set a hard or soft IRQ
callback when a Pin has a level change.  It still remains to make this
method return a IRQ object.
It provides sys.stdin, sys.stdout, sys.stderr for bare-metal targets based
on mp_hal functions.
Also, add ipoll() documentation and markup changes to comply with CPython
usage.
In particular, require the real name and email address.
The CC3100 only allows to set a timeout for receiving data, not for accept,
connect or send.  But it can set non-blocking for all these operations and
this patch uses that feature to implement socket timeout in terms of non-
blocking behaviour combined with a loop.
This attempts to bootstrap network tests for MicroPython. This commits
sets test/net_inet/ as place for tests which require access to wide
Internet. They aren't intended to be run as part of the main testsuite,
instead to be run manually on demand.

test_tls_sites.py in particular check that it's possible to establish
SSL/TLS connection to select sites on the Internet: few references ones,
plus those for which problems were reported, and resolved.
Some of these tests don't require an Internet connection, but here is a
good place to put them for now.
This patch fixes a bug whereby the Python stack was not correctly reset if
there was a break/continue statement in the else black of an optimised
for-range loop.

For example, in the following code the "j" variable from the inner for loop
was not being popped off the Python stack:

    for i in range(4):
        for j in range(4):
            pass
        else:
            continue

This is now fixed with this patch.
pfalcon and others added 17 commits August 20, 2017 10:44
Too big positive, or too big negative offset values could lead to overflow
and address space wraparound and thus access to unrelated areas of memory
(a security issue).
For SEEK_SET, offset should be treated as unsigned, to allow full-width
stream sizes (e.g. 32-bit instead of 31-bit). This is now fully documented
in stream.h. Also, seek symbolic constants are added.
Per POSIX, this is EINVAL, so raises OSError(EINVAL).
This allows the command to succeed without error even if there is no
$(BUILD)/build directory, which is the case for mpy-cross.
This prevents large files (eg larger than 2gb on a 32-bit arch) from
showing up as having a negative size.  Fixes issue #3227.
As per the "ESP8266 Technical Reference".
This macro is provided by stmhal/mphalport.h and makes sure the addr and
size arguments are correctly aligned.
…lopment) master.

cpx build compiles and loads and works in repl; test suite not run yet
esp8266 not tested yet
@dhalbert dhalbert requested a review from tannewt August 27, 2017 19:31
@dhalbert dhalbert self-assigned this Aug 27, 2017
@willingc
Copy link

@dhalbert @tannewt This a big PR. I'm wondering if it would make sense to break this into 4 PRs: Jun 14, Jun23, Jul 24, Jul 29. It might make the review, tests, and git bisect easier if any regressions are introduced with 1.9.2.

@tannewt
Copy link
Member

tannewt commented Aug 28, 2017

I'm ok with just pulling it all in. I'd prefer to get it in so we have people using it sooner.

@willingc
Copy link

@tannewt What's rosie-ci? A custom ci machine of yours?

@dhalbert
Copy link
Collaborator Author

dhalbert commented Aug 28, 2017

[started writing this before @tannewt's comment above] I looked at the original diffs of nearly all the files, which took a couple of hours. I only skipped over files in implementations we don't cover (cc3200, etc.). What I would say is that if we need to debug a regression, we could do that in micropython instead of circuitpython. I don't mind importing new bugs if they are the same bugs in MicroPython.

We don't make very many changes in the py/ and similar parts of the tree. Most of our work is in atmel-samd/.

@tannewt
Copy link
Member

tannewt commented Aug 28, 2017

@willingc Yup it runs tests on actual hardware. https://github.com/adafruit/rosie-ci The Feagther M0 Express isn't happy now though so I'll need to poke it tomorrow.

@willingc
Copy link

@dhalbert Nice work going through each module. I would say merge and correct the Feather M0 Express in a separate PR 🍰

@dhalbert
Copy link
Collaborator Author

Hi @willingc - rosie is an RPi with one of each different CPy-compatible board attached (except ESP8266, I think). It loads up the appropriate firmware and then runs a set of Python tests. I think @tannewt meant that the attached Feather M0 Express board doesn't seem to be working. I did see a test failure on one of the working boards, but that might be a red herring. Once Scott gets it up again, I'll take a look at the rosie results and do another push if necessary.

@willingc
Copy link

Great @dhalbert. Thanks for the more detailed explanation.

@tannewt tannewt merged commit 447a4b1 into master Aug 28, 2017
@tannewt
Copy link
Member

tannewt commented Aug 28, 2017

Thanks a bunch @dhalbert! It looks really good.

@willingc willingc deleted the merge-v1.9.2 branch August 28, 2017 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.