Commit Graph

12004 Commits

Author SHA1 Message Date
Scott Shawcroft
769788d3c7 Turn off USB pin objects since they are always used for USB. 2018-06-08 12:56:32 -07:00
Scott Shawcroft
383bf9a59e Wait for the DFLL to be stable. 2018-06-08 12:56:32 -07:00
Scott Shawcroft
07a8899c72 Support M4 2018-06-08 12:56:32 -07:00
Scott Shawcroft
2fbab8067a Prevent freezing USB during high frequency PulseIn.
We now track the last time the background task ran and bail on the
PulseIn if it starves the background work. In practice, this
happens after the numbers from pulsein are no longer accurate.

This also adjusts interrupt priorities so most are the lowest level
except for the tick and USB interrupts.

Fixes #516 and #876
2018-06-08 12:56:32 -07:00
Dan Halbert
218930d18b Check for PDMIn DMA getting stuck. 2018-06-08 08:23:52 -04:00
hathach
418e28c7dc update nrf52840 bootloader hex and target 2018-06-08 16:10:49 +07:00
hathach
2b3436e87c add feather nrf52 uart rts, cts support 2018-06-08 15:59:38 +07:00
hathach
c10899d13f allow to flash feather52 and feather52840 with jlink
add crc bypass magic to bootloader settting
2018-06-08 15:11:17 +07:00
Nick Moore
6af1fbacc9 Work on pulseio.PulseOut for #716 ESP8266
Switch to ets_delay_us but the PWM is still way too slow to be useful.
2018-06-08 16:41:42 +10:00
Damien George
8fb95d6520 tools/pydfu.py: Increase download packet size to full 2048 bytes.
The ST DFU bootloader supports a transfer size up to 2048 bytes, so send
that much data on each download (to device) packet.  This almost halves
total download time.
2018-06-08 15:32:49 +10:00
Nick Moore
011edf2472 Clean up interrupt handling for pulseio.PulseIn implementation for #716 ESP8266 2018-06-08 15:31:16 +10:00
Damien George
24c416cc66 stm32/mboot: Increase USB rx_buf and DFU buf sizes to full 2048 bytes.
The DFU USB config descriptor returns 0x0800=2048 for the supported
transfer size, and this applies to both TX (IN) and RX (OUT).  So increase
the rx_buf to support this size without having a buffer overflow on
received data.

With this patch mboot in USB DFU mode now works with dfu-util.
2018-06-08 15:29:52 +10:00
Nick Moore
c4cf1c5221 Initial pulseio.PulseOut implementation for #716 ESP8266 2018-06-08 15:28:05 +10:00
Nick Moore
7adc69baf9 Initial pulseio.PulseIn implmentation for #716 ESP8266 2018-06-08 15:27:59 +10:00
Glenn Moloney
039f196c56 esp32/modnetwork: Fix isconnected() when using static IP config.
Currently <WLAN>.isconnected() always returns True if a static IP is set,
regardless of the state of the connection.

This patch introduces a new flag 'wifi_sta_connected' which is set in
event_handler() when GOT_IP event is received and reset when DISCONNECTED
event is received (unless re-connect is successful).  isconnected() now
simply returns the status of this flag (for STA_IF).

The pre-existing flag misleadingly named 'wifi_sta_connected" is also
renamed to 'wifi_sta_connect_requested'.

Fixes issue #3837
2018-06-08 13:13:21 +10:00
Damien George
a12d046c42 tests/pyb: Make i2c and pyb1 pyboard tests run again.
For i2c.py: the accelerometer now uses the new I2C driver so need to
explicitly init the legacy i2c object to get the test working.

For pyb1.py: the legacy pyb.hid() call will crash if the USB_HID object is
not initialised.
2018-06-08 13:00:27 +10:00
Damien George
190c7dba89 stm32/mpconfigport.h: Enable DELATTR_SETATTR and BUILTINS_NOTIMPLEMENTED
MICROPY_PY_DELATTR_SETATTR can now be enabled without a performance hit for
classes that don't use this feature.

MICROPY_PY_BUILTINS_NOTIMPLEMENTED is a minor addition that improves
compatibility with CPython.
2018-06-08 12:55:18 +10:00
Damien George
93150a0d40 ports: Enable descriptors on stm32, esp8266, esp32 ports.
They are now efficient (in runtime performance) and provide a useful
feature that's hard to obtain without them enabled.

See issue #3644 and PR #3826 for background.
2018-06-08 12:23:08 +10:00
Damien George
36c1052183 py/objtype: Optimise instance get/set/del by skipping special accessors.
This patch is a code optimisation, trading text bytes for speed.  On
pyboard it's an increase of 0.06% in code size for a gain (in pystone
performance) of roughly 6.5%.

The patch optimises load/store/delete of attributes in user defined classes
by not looking up special accessors (@property, __get__, __delete__,
__set__, __setattr__ and __getattr_) if they are guaranteed not to exist in
the class.

Currently, if you do my_obj.foo() then the runtime has to do a few checks
to see if foo is a property or has __get__, and if so delegate the call.
And for stores things like my_obj.foo = 1 has to first check if foo is a
property or has __set__ defined on it.

Doing all those checks each and every time the attribute is accessed has a
performance penalty.  This patch eliminates all those checks for cases when
it's guaranteed that the checks will always fail, ie no attributes are
properties nor have any special accessor methods defined on them.

To make this guarantee it checks all attributes of a user-defined class
when it is first created.  If any of the attributes of the user class are
properties or have special accessors, or any of the base classes of the
user class have them, then it sets a flag in the class to indicate that
special accessors must be checked for.  Then in the load/store/delete code
it checks this flag to see if it can take the shortcut and optimise the
lookup.

It's an optimisation that's pretty widely applicable because it improves
lookup performance for all methods of user defined classes, and stores of
attributes, at least for those that don't have special accessors.  And, it
allows to enable descriptors with minimal additional runtime overhead if
they are not used for a particular user class.

There is one restriction on dynamic class creation that has been introduced
by this patch: a user-defined class cannot go from zero special accessors
to one special accessor (or more) after that class has been subclassed.  If
the script attempts this an AttributeError is raised (see addition to
tests/misc/non_compliant.py for an example of this case).

The cost in code space bytes for the optimisation in this patch is:

   unix x64:  +528
unix nanbox:  +508
      stm32:  +192
     cc3200:  +200
    esp8266:  +332
      esp32:  +244

Performance tests that were done:

- on unix x86-64, pystone improved by about 5%
- on pyboard, pystone improved by about 6.5%, from 1683 up to 1794
- on pyboard, bm_chaos (from CPython benchmark suite) improved by about 5%
- on esp32, pystone improved by about 30% (but there are caching effects)
- on esp32, bm_chaos improved by about 11%
2018-06-08 12:12:08 +10:00
Damien George
bace1a16d0 py/objtype: Don't expose mp_obj_instance_attr().
mp_obj_is_instance_type() can be used instead to check for instance types.
2018-06-08 11:48:25 +10:00
Damien George
db5d8c97f1 py/obj.h: Introduce a "flags" entry in mp_obj_type_t. 2018-06-08 11:48:25 +10:00
Dan Halbert
c01ce175bb
Merge pull request #914 from SConaway/patch-1
Update README.rst
2018-06-07 20:44:19 -04:00
Dan Halbert
0ecfd2923f
Merge pull request #913 from kattni/itsybitsy-name-fix
Itsybitsy name fixes
2018-06-07 18:12:51 -04:00
Steven Conaway
f36fa308e7
Update README.rst 2018-06-07 12:15:15 -07:00
Kattni Rembor
ba7e0e2f86 Add Adafruit to other M4 board name strings 2018-06-07 13:39:04 -04:00
Kattni Rembor
7b2875d54a Add Adafruit to board name string 2018-06-07 13:33:13 -04:00
Kattni Rembor
0ab2a60dcd Update ItsyBitsy board name to one word 2018-06-07 13:12:44 -04:00
hathach
c854e2dc17 Merge branch 'master' into usbboot 2018-06-07 13:51:21 +07:00
hathach
9bb4ded5fa Merge remote-tracking branch 'upstream/master' 2018-06-07 13:50:04 +07:00
Dan Halbert
44721cba3d
Merge pull request #910 from kattni/rotaryio-doc-fix
Fixed documentation formatting for RTD
2018-06-06 20:06:33 -04:00
Kattni Rembor
3a38172627 Fixed documentation formatting for RTD 2018-06-06 18:28:01 -04:00
Kattni
ca24cad60a
Merge pull request #902 from dhalbert/feather_m0x_crickit
Feather M0 Express build with frozen Crickit libraries
2018-06-06 14:41:13 -04:00
Dan Halbert
1079f94fc5
Merge pull request #905 from jepler/main-stack-usage
main: move code pertaining to boot.py out of line
2018-06-06 09:24:51 -04:00
Jeff Epler
654591e11f main: move code pertaining to boot.py out of line
.. this reduces stack usage in main() substantially, because
the 512 byte stack allocation will only exist during the new run_boot_py
function's duration.

Closes: #904
2018-06-06 08:01:17 -05:00
Damien George
b789c640f7 travis: Install explicit version of urllib3 for coveralls.
Coveralls requires a "recent" version of urllib3, whereas requests requires
a "not so recent" version, less than 1.23.  So force urllib3 v1.22 to get
it all working.
2018-06-06 20:56:24 +10:00
Scott Shawcroft
aa636841a2
Merge pull request #903 from jepler/stack-overflow-crash
main: Explicitly set the stack top based on _estack
2018-06-05 22:05:13 -07:00
Damien George
a8b9e71ac1 py/mpconfig.h: Add default MICROPY_VFS_FAT config value.
At least to document it's existence.
2018-06-06 14:33:42 +10:00
Damien George
c117effddd extmod/vfs: Introduce a C-level VFS protocol, with fast import_stat.
Following other C-level protocols, this VFS protocol is added to help
abstract away implementation details of the underlying VFS in an efficient
way.  As a starting point, the import_stat function is put into this
protocol so that the VFS sub-system does not need to know about every VFS
implementation in order to do an efficient stat for importing files.

In the future it might be worth adding other functions to this protocol.
2018-06-06 14:33:42 +10:00
Damien George
fadd6bbe43 unix/moduos_vfs: Add missing uos functions from traditional uos module.
Now that the coverage build has fully switched to the VFS sub-system these
functions were no longer available, so add them to the uos_vfs module.

Also, vfs_open is no longer needed, it's available as the built-in open.
2018-06-06 14:28:23 +10:00
Damien George
5ef0d2ab14 tests/extmod: Remove conditional import of uos_vfs, it no longer exists.
This conditional import was only used to get the tests working on the unix
coverage build, which has now switched to use VFS by default so the uos
module alone has the required functionality.
2018-06-06 14:28:23 +10:00
Damien George
6c02da2eec tests/extmod: Add test for importing a script from a user VFS. 2018-06-06 14:28:23 +10:00
Damien George
1d40f12e44 unix: Support MICROPY_VFS_POSIX and enable it in coverage build.
The unix coverage build is now switched fully to the VFS implementation, ie
the uos module is the uos_vfs module.  For example, one can now sandbox uPy
to their home directory via:

    $ ./micropython_coverage

    >>> import uos
    >>> uos.umount('/') # unmount existing root VFS
    >>> vfs = uos.VfsPosix('/home/user') # create new POSIX VFS
    >>> uos.mount(vfs, '/') # mount new POSIX VFS at root

Some filesystem/OS features may no longer work with the coverage build due
to this change, and these need to be gradually fixed.

The standard unix port remains unchanged, it still uses the traditional uos
module which directly accesses the underlying host filesystem.
2018-06-06 14:28:23 +10:00
Damien George
d4ce57e4e3 extmod/vfs: Add fast path for stating VfsPosix filesystem. 2018-06-06 14:28:23 +10:00
Damien George
a93144cb65 py/reader: Allow MICROPY_VFS_POSIX to work with MICROPY_READER_POSIX. 2018-06-06 14:28:23 +10:00
Damien George
8d82b0edbd extmod: Add VfsPosix filesystem component.
This VFS component allows to mount a host POSIX filesystem within the uPy
VFS sub-system.  All traditional POSIX file access then goes through the
VFS, allowing to sandbox a uPy process to a certain sub-dir of the host
system, as well as mount other filesystem types alongside the host
filesystem.
2018-06-06 14:28:23 +10:00
Damien George
f35aae366c extmod/vfs_fat: Rename FileIO/TextIO types to mp_type_vfs_fat_XXX.
So they don't clash with other VFS implementations.
2018-06-06 14:28:23 +10:00
Damien George
172c23fe5d extmod/vfs: Use u_rom_obj properly in argument structures. 2018-06-06 14:28:23 +10:00
Jeff Epler
a4e06bd998 main: Explicitly set the stack top based on _estack
.. setting it based on the ad-hoc stack pointer calculation of
mp_stack_ctrl_init() meant that the stack used above main() counts
against the 1KiB safety factor that the mp_stack_set_limit call tries
to establish.  It turns out, at least on M4, that over half of the
safety factor is used up by stack-above-main()!

In the case of the basics/gen_stack_overflow.py test,
which blows the stack on purpose, it turns out that gc would be called
while handling the "maximum recursion depth exceeded" error, and this
needed more stack than was left.

Closes: #900
2018-06-05 22:04:55 -05:00
Dan Halbert
36a7ebe88e add feather_m0_express_crickit to .travis.yml 2018-06-05 18:24:55 -04:00
Dan Halbert
9ba6990228 Feather M0 Express build with Crickit libraries 2018-06-05 18:21:47 -04:00