Commit Graph

8421 Commits

Author SHA1 Message Date
Damien George
c64eb4f8ce extmod/vfs: Replace VLA in proxy func with small, static sized array.
VLAs can be expensive on stack usage due to stack alignment requirements,
and also the fact that extra local variables are needed to track the
dynamic size of the stack.  So using fixed-size arrays when possible can
help to reduce code size and stack usage.

In this particular case, the maximum value of n_args in the VLA is 2 and so
it's more efficient to just allocate this array with a fixed size.  This
reduces code size by around 30 bytes on Thumb2 and Xtensa archs.  It also
reduces total stack usage of the function: on Thumb2 the usage with VLA is
between 40 and 48 bytes, which is reduced to 32; on Xtensa, VLA usage is
between 64 and 80 bytes, reduced to 32; on x86-64 it's at least 88 bytes
reduced to 80.
2017-10-27 18:01:25 +11:00
Paul Sokolovsky
a33fca99a1 docs/usocket: Document inet_ntop(), inet_pton(). 2017-10-27 00:27:27 +03:00
Paul Sokolovsky
d1cd533134 docs/usocket: Elaborate descriptions.
Use the "usocket" module name everywhere. Use "MicroPython port"
terminology. Suggest to avoid using IPPROTO_* constants in socket()
call.
2017-10-26 14:20:37 +03:00
Damien George
f36975b679 tests/net_inet: Update tls test to work with CPython and incl new site.
CPython only supports the server_hostname keyword arg via the SSLContext
object, so use that instead of the top-level ssl.wrap_socket.  This allows
the test to run on CPython the same as uPy.

Also add the "Host:" header to correctly make a GET request (for URLs that
are hosted on other servers).  This is not strictly needed to test the SSL
connection but helps to debug things when printing the response.
2017-10-26 12:29:24 +11:00
Paul Sokolovsky
328c1e78be docs/uselect: Document one-shot polling mode. 2017-10-26 00:30:07 +03:00
Paul Sokolovsky
9a7e3469b2 unix/modusocket: Remove #if MICROPY_SOCKET_EXTRA code blocks.
These defined couple of functions added during initial experimentation,
which aren't part of MicroPython API and no longer used or needed.
2017-10-24 23:13:19 +03:00
Damien George
f4059dcc0c all: Use NULL instead of "" when calling mp_raise exception helpers.
This is the established way of doing it and reduces code size by a little
bit.
2017-10-24 22:39:36 +11:00
Paul Sokolovsky
cfff12612f unix: Rename modsocket.c to modusocket.c.
Unix naming is historical, before current conventions were established.
All other ports however have it as "modusocket.c", so rename for
consistency and to avoid confusion.
2017-10-23 12:09:37 +03:00
Paul Sokolovsky
9956fd0710 py/objtype: Fit qstrs for special methods in byte type.
Update makeqstrdata.py to sort strings starting with "__" to the beginning
of qstr list, so they get low qstr id's, guaranteedly fitting in 8 bits.
Then use this property to further compact op_id => qstr mapping arrays.
2017-10-21 11:06:32 +03:00
Paul Sokolovsky
f2baa9ec24 py/objtype: Use CPython compatible method name for sizeof.
Per https://docs.python.org/3/library/sys.html#sys.getsizeof:

getsizeof() calls the object’s __sizeof__ method. Previously, "getsizeof"
was used mostly to save on new qstr, as we don't really support calling
this method on arbitrary objects (so it was used only for reporting).
However, normalize it all now.
2017-10-19 12:44:53 +03:00
Damien George
93ce125abe py/argcheck: Remove #if guard around terse error message helper func.
Not all compilers/analysers are smart enough to realise that this function
is never called if MICROPY_ERROR_REPORTING is not TERSE, because the logic
in the code uses if statements rather than #if to select whether to call
this function or not (MSC in debug mode is an example of this, but there
are others).  So just unconditionally compile this helper function.  The
code-base anyway relies on the linker to remove unused functions.
2017-10-19 18:57:26 +11:00
Damien George
d6bf3658f4 stm32: Make uos.dupterm() conform to specs by using extmod version.
The legacy function pyb.repl_uart() is still provided and retains its
original behaviour (it only accepts a UART object).  uos.dupterm() will now
accept any object with write/readinto methods.  At the moment there is just
1 dupterm slot.
2017-10-19 14:16:42 +11:00
Damien George
0eb333e3cf stm32/mphalport: Improve efficiency of mp_hal_stdout_tx_strn_cooked.
Also simplifies the code by removing the specialised (and inefficient)
cooked functions from UART and USB_VCP.
2017-10-19 14:15:32 +11:00
Damien George
9725a654bd extmod/uos_dupterm: Swallow any errors from dupterm closing the stream.
Without this the board will crash when deactivating a stream that doesn't
have a close() method (eg UART) or that raises an exception within the
method (eg user-defined function).
2017-10-19 14:10:17 +11:00
Damien George
c53ca32561 README: Add gcc and arm-none-eabi-newlib to list of required components.
gcc is required for mpy-cross, and arm-none-eabi-newlib for ports using
arm-none-eabi-gcc.
2017-10-19 12:38:28 +11:00
Damien George
8fa3d2996c stm32/modnwwiznet5k: Implement stream ioctl for the Wiznet driver.
Now supports polling for read and write ability.
2017-10-17 16:34:10 +11:00
Damien George
285ac58532 stm32/modnwwiznet5k: Increase SPI bus speed to 42MHz.
The W5200 and W5500 can support up to 80MHz so 42MHz (the maximum the
pyboard can do in its standard configuration) should be safe.

Tested to give around 1050000 kbytes/sec TCP download speed on a W5500,
which is about 10% more than with the previous SPI speed of 21MHz.
2017-10-17 16:31:12 +11:00
Damien George
d90ade5e3e docs/library/network: Update docs to state that W5500 is supported. 2017-10-16 15:51:56 +11:00
Damien George
06f2fdbe61 travis: Update build command now that stm32 Wiznet config has changed. 2017-10-16 15:51:32 +11:00
Damien George
e36821a766 stm32/modnwwiznet5k: Add support for W5500 Ethernet chip.
Which Wiznet chip to use is a compile-time option: MICROPY_PY_WIZNET5K
should be set to either 5200 or 5500 to support either one of these
Ethernet chips.  The driver is called network.WIZNET5K in both cases.

Note that this commit introduces a breaking-change at the build level
because previously the valid values for MICROPY_PY_WIZNET5K were 0 and 1
but now they are 0, 5200 and 5500.
2017-10-16 15:36:57 +11:00
Damien George
c0ea91bc89 drivers/wiznet5k: Get low-level W5500 driver working.
This patch implements the basic SPI read/write functions for the W5500
chip.  It also allows _WIZCHIP_ to be configured externally to select the
specific Wiznet chip.
2017-10-16 15:34:08 +11:00
Li Weiwei
73e387cff6 drivers/wiznet5k: Improve the performance of socket ops with threading.
Use MICROPY_THREAD_YIELD() instead of HAL_Delay in busy waiting to improve
the performance of connect, send, recv, sento and recvfrom.
2017-10-16 13:32:34 +11:00
Li Weiwei
5c437963d7 stm32/mpconfigport.h: Add MICROPY_THREAD_YIELD() macro. 2017-10-16 13:32:26 +11:00
Damien George
0a30ad96c8 stm32/modusocket: Return OSError(-2) if getaddrinfo fails.
This matches the behaviour of getaddrinfo in extmod/modlwip.c.
2017-10-16 13:19:11 +11:00
Damien George
5d7b0b237b stm32/modusocket: Make getaddrinfo() work when passed an IP address. 2017-10-16 13:17:15 +11:00
Damien George
65ba481cb0 stm32/modnwwiznet5k: Implement WIZNET5K.isconnected() method. 2017-10-16 13:16:00 +11:00
Paul Sokolovsky
829c329daf README: Add explicit section on contributing.
To increase visibility of Contributors' Guidelines and Code Conventions
docs.
2017-10-15 10:17:24 +03:00
Damien George
37282f8fc1 extmod/uos_dupterm: Update uos.dupterm() and helper funcs to have index.
The uos.dupterm() signature and behaviour is updated to reflect the latest
enhancements in the docs.  It has minor backwards incompatibility in that
it no longer accepts zero arguments.

The dupterm_rx helper function is moved from esp8266 to extmod and
generalised to support multiple dupterm slots.

A port can specify multiple slots by defining the MICROPY_PY_OS_DUPTERM
config macro to an integer, being the number of slots it wants to have;
0 means to disable the dupterm feature altogether.

The unix and esp8266 ports are updated to work with the new interface and
are otherwise unchanged with respect to functionality.
2017-10-13 20:01:57 +11:00
Li Weiwei
e39fcda8eb stm32/usbd_cdc_interface.h: Fix code comments after recent refactor. 2017-10-13 12:45:16 +11:00
Damien George
7c7c7b161d stm32/usbd_cdc_interface: Don't reset CDC output buf on initialisation.
So that characters can be buffered before the USB device is connected
(restoring behviour of the driver before recent state refactoring).
2017-10-13 12:00:47 +11:00
Damien George
c59fc1419d py/emitnative: Simplify binary op emitter, no need to check inplace ops. 2017-10-12 12:26:49 +11:00
Damien George
a3afa8cfc4 py/emitnative: Implement floor-division and modulo for viper emitter. 2017-10-11 18:54:34 +11:00
Vitor Massaru Iha
1b7d6a7951 esp8266/modules/webrepl_setup: Add info about allowed password length.
This patch also makes the code more concise by combining the checks for the
password length.
2017-10-11 11:37:01 +11:00
Mike Causer
b1457db002 docs/library: Add missing cross-ref links for classes in pyb module. 2017-10-11 11:30:16 +11:00
Damien George
69da74e538 py/modbuiltins: Use existing utf8_get_char helper in builtin ord func. 2017-10-11 11:25:20 +11:00
Damien George
dc948e4d54 py/formatfloat: Use standard isinf, isnan funcs instead of custom ones.
Reduces code size by a tiny bit.
2017-10-10 16:27:54 +11:00
Damien George
08a196697c py/formatfloat: Don't print the negative sign of a NaN value.
NaN may have the sign bit set but it has no meaning, so don't print it out.
2017-10-10 16:01:13 +11:00
Damien George
81a06d2c9c lib/libm: Remove implementation of log2f, use MP_NEED_LOG2 instead. 2017-10-10 16:01:13 +11:00
Damien George
d8d4e4dfbe py/modmath: Convert log2 macro into a function.
So that a pointer to it can be passed as a pointer to math_generic_1.  This
patch also makes the function work for single and double precision floating
point.
2017-10-10 16:01:04 +11:00
Damien George
25e140652b py/modmath: Add full checks for math domain errors.
This patch changes how most of the plain math functions are implemented:
there are now two generic math wrapper functions that take a pointer to a
math function (like sin, cos) and perform the necessary conversion to and
from MicroPython types.  This helps to reduce code size.  The generic
functions can also check for math domain errors in a generic way, by
testing if the result is NaN or infinity combined with finite inputs.

The result is that, with this patch, all math functions now have full
domain error checking (even gamma and lgamma) and code size has decreased
for most ports.  Code size changes in bytes for those with the math module
are:

   unix x64:  -432
unix nanbox:  -792
      stm32:   -88
    esp8266:   +12

Tests are also added to check domain errors are handled correctly.
2017-10-10 15:57:45 +11:00
Mike Causer
f599a38059 docs/esp8266/quickref: Add quickref info for RTC class. 2017-10-10 15:22:23 +11:00
Mike Causer
dc92f1c4ee docs/pyboard/tutorial: Update now that yellow LED also supports PWM. 2017-10-10 15:22:11 +11:00
Mike Causer
d236d0c415 docs/pyboard/quickref: Add info for Switch, RTC, CAN, Accel classes. 2017-10-10 15:22:11 +11:00
Damien George
933eab46fc py/bc: Update opcode_format_table to match the bytecode. 2017-10-10 10:37:38 +11:00
Damien George
add933feaf docs/library/network: Clarify usage of "bssid" arg in connect() method. 2017-10-09 23:11:25 +11:00
Damien George
6db132e130 esp8266/modnetwork: Add "bssid" keyword arg to WLAN.connect() method. 2017-10-09 23:09:06 +11:00
Paul Sokolovsky
53966fd9a8 examples: hwconfig_console: Add .on()/.off() methods.
Add these methods to this "GPIO output emulated with console prints"
config.
2017-10-09 00:22:30 +03:00
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