Commit Graph

9835 Commits

Author SHA1 Message Date
Paul Sokolovsky c15be989ee tools/pyboard: Update docstring for additional device support. 2017-10-08 00:04:57 +03:00
Paul Sokolovsky 4514f073c1 zephyr: Switch to interrupt-driven pull-style console.
While this console API improves handling on real hardware boards
(e.g. clipboard paste is much more reliable, as well as programmatic
communication), it vice-versa poses problems under QEMU, apparently
because it doesn't emulate UART interrupt handling faithfully. That
leads to inability to run the testsuite on QEMU at all. To work that
around, we have to suuport both old and new console routines, and use
the old ones under QEMU.
2017-10-07 17:36:16 +03:00
Paul Sokolovsky 71c1a05d88 tests/run-tests: Close device under test using "finally".
We want to close communication object even if there were exceptions
somewhere in the code. This is important for --device exec:/execpty:
which may otherwise leave processing running in the background.
2017-10-07 15:49:58 +03:00
Paul Sokolovsky 58ea239510 zephyr: Use CONFIG_NET_APP_SETTINGS to setup initial network addresses.
Ideally, these should be configurable from Python (using network module),
but as that doesn't exist, we better off using Zephyr's native bootstrap
configuration facility.
2017-10-07 14:08:50 +03:00
Damien George 6f1a615427 stm32/boards: Fix typos in stm32f767_af.csv table. 2017-10-06 14:32:42 +11:00
Damien George ca2427c313 drivers/display/ssd1306: Make poweron() work the same with SSD1306_SPI.
The poweroff() and poweron() methods are used to do soft power control of
the display, and this patch makes these methods work the same for both I2C
and SPI interfaces.
2017-10-06 12:48:44 +11:00
Tiago Queiroz 7df4083ac6 drivers/display/ssd1306: Implement SSD1306_I2C poweron method.
After a poweroff(), the poweron() method does a soft power-on and any
previous state of the display persists.
2017-10-06 12:47:22 +11:00
Paul Sokolovsky ea6692a83e tools/pyboard: Use repr() when quoting data in error messages.
As it may contain newlines, etc.
2017-10-05 23:40:19 +03:00
Damien George 98dd126e98 tests/extmod: Add test for '-' in character class in regex. 2017-10-05 11:33:49 +11:00
Li Weiwei 8c7db42ee3 stm32/modnwwiznet5k: Get the IP address of an established socket.
When wiznet5k_socket_accept is called, if a socket is established, get the
IP address of the socket.
2017-10-05 11:09:07 +11:00
Damien George ff93fd4f50 py/persistentcode: Bump .mpy version number to version 3.
The binary and unary ops have changed bytecode encoding.
2017-10-05 10:49:44 +11:00
Damien George 36f7952f76 py/objtype: Clean up unary- and binary-op enum-to-qstr mapping tables. 2017-10-05 10:49:44 +11:00
Damien George 0864a6957f py: Clean up unary and binary enum list to keep groups together.
2 non-bytecode binary ops (NOT_IN and IN_NOT) are moved out of the
bytecode group, so this change will change the bytecode format.
2017-10-05 10:49:44 +11:00
Glenn Ruben Bakke a414199793 ports/nrf: Update Makefile and README.md after moving port to new directory 2017-10-04 21:54:01 +02:00
Glenn Ruben Bakke 831759faaa ports/nrf: Align help.c builtin help text to use correct type after upmerge with upstream master. 2017-10-04 21:52:08 +02:00
Glenn Ruben Bakke 44e2cb415f ports/nrf: Moving nrf51/52 port to new ports directory 2017-10-04 21:46:48 +02:00
Glenn Ruben Bakke bcab2ba0a8 ports/nrf: Upmerging port with upstream master 2017-10-04 21:45:04 +02:00
Glenn Ruben Bakke 4468731e3d nrf: Aligning with upstream the use of nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, ...) 2017-10-04 20:49:49 +02:00
glennrub 795116b432 nrf/modules/random: Backport of microbit random number generator module
Backport of micro:bit random module.
Plugged into the port as a general random module for all nrf51/nrf52 targets. Works both with and without Bluetooth LE stack enabled.

Behavioral change: seed() method has been removed, as the use of RNG peripheral generates true random sequences and not pseudo-random sequences.
2017-10-04 20:49:03 +02:00
glennrub f49b202e7d nrf/hal/rng: Adding HAL driver for accessing RNG peripheral
The driver also takes care of calling the Bluetooth LE stack for random values if the stack is enabled. The reason for this is that the Bluetooth LE stack take ownership of the NRF_RNG when enabled. Tolerate to enable/disable on the fly, and will choose to use direct access to the peripheral if Bluetooth LE stack is disabled or not compiled in at all.

Driver has been included in the top Makefile, and will not be compiled in unless nrf51_hal_conf.h/nrf52_hal_conf.h defines HAL_RNG_MODULE_ENABLED (1).
2017-10-04 20:45:40 +02:00
glennrub 8c0bbb983b nrf/boards: Adding Arduino Primo board support (#88)
* nrf: Adding Arduino Primo board support

* nrf: Adding arduino_primo to target boards table in readme.md

* nrf/boards: Activating pyb.LED module for arduino_primo board.

* nrf/boards: Removing define not needed for arduino_primo

Updating arduino_primo board mpconfigboard.h. Removing a define
that was wrongly named. Instead of renaming it, it was removed as
it was never used.
2017-10-04 20:44:11 +02:00
Glenn Ruben Bakke 863a5c1734 nrf: Add support for floating point on nrf52 targets.
Duplicating pattern for detecting location of libm, libc and libgcc
from teensy port. Activating MICROPY_FLOAT_IMPL (FLOAT) for nrf52 targets
and adding libs into the compile. For nrf51 targets it is still set to
NONE as code grows to much (about 30k).

Some numbers on flash use if MICROPY_FLOAT_IMPL is set to
MICROPY_FLOAT_IMPL_FLOAT and math libraries are enabled (lgcc, lc, lm).

nrf51:
======

without float support:
   text	   data	    bss	    dec	    hex	filename
 144088	    260	  30020	 174368	  2a920	build-pca10028/firmware.elf

with float support:
   text	   data	    bss	    dec	    hex	filename
 176228	   1336	  30020	 207584	  32ae0	build-pca10028/firmware.elf

nrf52:
======

without float support:
   text	   data	    bss	    dec	    hex	filename
 142040	    356	  36236	 178632	  2b9c8	build-pca10040/firmware.elf

with float support:
   text	   data	    bss	    dec	    hex	filename
 165068	   1436	  36236	 202740	  317f4	build-pca10040/firmware.elf
2017-10-04 20:42:27 +02:00
Damien George f869d6b2e3 lib/libm: Fix tanhf so that it correctly handles +/- infinity args. 2017-10-04 21:14:00 +11:00
Damien George 23faf88cab py/mpprint: Only check for null string printing when NDEBUG not defined.
Printing "(null)" when a NULL string pointer is passed to %s is a debugging
feature and not a feature that's relied upon by the code.  So it only needs
to be compiled in when debugging (such as assert) is enabled, and saves
roughy 30 bytes of code when disabled.

This patch also fixes this NULL check to not do the check if the precision
is specified as zero.
2017-10-04 18:07:32 +11:00
Damien George dfa563c71f py/objstr: Make empty bytes object have a null-terminating byte.
Because a lot of string processing functions assume there is a null
terminating byte, so they can work in an efficient way.

Fixes issue #3334.
2017-10-04 17:59:22 +11:00
Damien George a3dc1b1957 all: Remove inclusion of internal py header files.
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-04 12:37:50 +11:00
Damien George 6c82cfc089 py/objtype: Change type of enum-to-qstr table to uint16_t to save space.
Qstr values fit in 16-bits (and this fact is used elsewhere in the code) so
no need to use more than that for the large lookup tables.  The compiler
will anyway give a warning if the qstr values don't fit in 16 bits.  Saves
around 80 bytes of code space for Thumb2 archs.
2017-10-04 11:31:05 +11:00
Gabe 9e0cdb22f1 docs/esp8266/tutorial: Update neopixel with example of using 4 bbp. 2017-10-04 10:35:22 +11:00
Radomir Dopieralski f4981677b0 Add a `gamepad` module for handling buttons in the background. (#295)
The `GamePad` singleton monitors buttons in the background to make sure a button press is never missed and debouncing happens consistently.
2017-10-03 13:35:57 -07:00
Dan Halbert c478c10923 Do not allow a *io object to be used after deinit().
Fixes #278, #277, #276, #275.
2017-10-03 12:07:17 -07:00
Radomir Dopieralski c2bb9e2eb5 Add board file for the hacked Trinket M0 Haxpress (#303)
Add a hacked Tinket M0 Haxpress board definition

Based on https://daveastels.com/2017/09/01/trinket-m0-express-hack/
2017-10-03 11:24:48 -07:00
chrismas9 3289b9b7a7 py/{mkenv.mk,mkrules.mk}: Append .exe for Windows executable files.
Building mpy-cross: this patch adds .exe to the PROG name when building
executables for host (eg mpy-cross) on Windows.  make clean now removes
mpy-cross.exe under Windows.

Building MicroPython: this patch sets MPY_CROSS to mpy-cross.exe or
mpy-cross so they can coexist and use cygwin or WSL without rebuilding
mpy-cross.  The dependency in the mpy rule now uses mpy-cross.exe for
Windows and mpy-cross for Linux.
2017-10-04 00:21:05 +11:00
Damien George b00040c43c esp8266/esp_mphal: Send data in chunks to mp_uos_dupterm_tx_strn.
Sending byte-by-byte is inefficient and leads to errors in the WebSocket
protocol when sending utf-8 encoded characters.
2017-10-03 23:24:24 +11:00
Damien George 54acd0b0f0 drivers/nrf24l01: Make nRF24L01 test script more portable. 2017-10-03 20:00:31 +11:00
Damien George 1394258f37 py/objset: Include the failed key in a KeyError raised from set.remove. 2017-10-03 18:03:06 +11:00
Damien George 2ac1364688 py/objset: Check that RHS of a binary op is a set/frozenset.
CPython docs explicitly state that the RHS of a set/frozenset binary op
must be a set to prevent user errors.  It also preserves commutativity of
the ops, eg: "abc" & set() is a TypeError, and so should be set() & "abc".

This change actually decreases unix (x64) code by 160 bytes; it increases
stm32 by 4 bytes and esp8266 by 28 bytes (but previous patch already
introduced a much large saving).
2017-10-03 17:56:27 +11:00
Damien George 01978648fd py/objset: Simplify set and frozenset by separating their locals dicts.
A lot of set's methods (the mutable ones) are not allowed to operate on a
frozenset, and giving frozenset a separate locals dict with only the
methods that it supports allows to simplify the logic that verifies if
args are a set or a frozenset.  Even though the new frozenset locals dict
is relatively large (88 bytes on 32-bit archs) there is a much bigger
saving coming from the removal of a const string for an error message,
along with the removal of some checks for set or frozenset type.

Changes in code size due to this patch are (for ports that changed at all):

   unix x64:   -56
unix nanbox:  -304
      stm32:   -64
    esp8266:  -124
     cc3200:   -40

Apart from the reduced code, frozenset now has better tab-completion
because it only lists the valid methods.  And the error message for
accessing an invalid method is now more detailed (it includes the
method name that wasn't found).
2017-10-03 17:55:53 +11:00
Paul Sokolovsky 8e0b9f495b tests/extmod: Add test for ure regexes leading to infinite recursion.
These now should be caught properly and lead to RuntimeError instead of
crash.
2017-10-03 00:24:32 +03:00
Paul Sokolovsky aba1f9167a extmod/modure: Add stack overflow checking when executing a regex. 2017-10-03 00:20:10 +03:00
Paul Sokolovsky c9a0b2a818 extmod/re1.5: Upgrade to v0.8.2, adds hook for stack overflow checking. 2017-10-02 21:20:47 +03:00
Dan Halbert 7f74412882 Make touch more sensitive. Add .raw_value and .threshold attributes. 2017-10-02 11:15:51 -07:00
Paul Sokolovsky 2f7827ba8f tools/upip: Upgrade to 1.2.2.
TLS SNI support, fixes after making str.rstrip() behavior compliant.
2017-09-29 18:24:11 -07:00
Scott Shawcroft 211b44e630 Update `time` to use SysTick (#274)
* atmel-samd: Add time back using the SysTick counter in the core. Fixes #261

* Switch to SysTick_Config
2017-09-29 16:58:13 -04:00
Scott Shawcroft bac841df61 atmel-samd: Fix CDC by making sure we define (#294)
CONF_USB_COMPOSITE_CDC_ACM_EN before including ASF4 files.
2017-09-29 16:03:05 -04:00
Dan Halbert b2dcc5bb6c reset pins on PDMIn deinit(). Fixes #275. 2017-09-29 08:54:05 -07:00
Scott Shawcroft 0bbb7a8199 Add support for patching newer ASF4 code. (#292)
* atmel-samd: Support patching after updating ASF4.

This makes it possible to automatically fix newer code.

* atmel-samd: Update ASF4 to include flash APIs for SAMD51.

This is the first automatic update that has caused a few deletions
where code was previously copied instead of moved.

This is a prerequisite for #260.
2017-09-28 23:33:44 -04:00
Scott Shawcroft 8466d760f9 atmel-samd: Port baudrate reset to asf4 so we no longer hose Rosie.
We still won't be able to run tests but we will be reset into the
bootloader to test other stuff.
2017-09-27 21:58:54 -04:00
Damien George bdc6e86e07 py/objfloat: Support raising a negative number to a fractional power.
This returns a complex number, following CPython behaviour.  For ports that
don't have complex numbers enabled this will raise a ValueError which gives
a fail-safe for scripts that were written assuming complex numbers exist.
2017-09-26 12:57:51 +10:00
David Lechner 62849b7010 py: Add config option to print warnings/errors to stderr.
This adds a new configuration option to print runtime warnings and errors to
stderr. On Unix, CPython prints warnings and unhandled exceptions to stderr,
so the unix port here is configured to use this option.

The unix port already printed unhandled exceptions on the main thread to
stderr. This patch fixes unhandled exceptions on other threads and warnings
(issue #2838) not printing on stderr.

Additionally, a couple tests needed to be fixed to handle this new behavior.
This is done by also capturing stderr when running tests.
2017-09-26 11:59:11 +10:00
Paul Sokolovsky 9d836fedbd py: Clarify which mp_unary_op_t's may appear in the bytecode.
Not all can, so we don't need to reserve bytecodes for them, and can
use free slots for something else later.
2017-09-25 16:35:19 -07:00