Commit Graph

4342 Commits

Author SHA1 Message Date
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
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
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 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
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
Damien George d29b709642 stm32/timer: Enable ARPE so that timer freq can be changed smoothly.
The timer prescaler is buffered by default, and this patch enables ARPE
which buffers the auto-reload register.  With both of these registers
buffered it's now possible to smoothly change the timer's frequency and
have a smoothly varying PWM output.
2017-09-25 15:25:08 +10:00
Damien George f7f4bf0321 stm32/usbdev: Move all the USB device descriptor state into its struct. 2017-09-22 10:57:21 +10:00
Damien George db7f4aa2cb stm32/usbdev: Make device descriptor callbacks take a state pointer. 2017-09-22 10:28:56 +10:00
Damien George dbff0164b3 stm32/usbdev: Merge all global USB device state into a single struct.
This is the final piece of USB device refactoring to support multiple
USB device instances.
2017-09-21 21:51:15 +10:00
Damien George 0ea73d2da7 stm32/usbdev: Simplify pointers to MSC state and block dev operations. 2017-09-21 21:51:12 +10:00
Damien George f8f17f48c5 stm32/usbdev: Put all state for the USB device driver in a struct. 2017-09-21 21:51:04 +10:00
Damien George 35e3435f6e stm32/usbdev/core: Add state parameter to all callback functions. 2017-09-21 21:51:02 +10:00
Damien George b3b922f177 stm32/usbdev: Simplify HID tx/rx buffer passing. 2017-09-21 21:50:56 +10:00
Damien George e04b478050 stm32/usbdev: Simplify CDC tx/rx buffer passing. 2017-09-21 21:50:48 +10:00
Damien George 77e1da40e2 stm32/usbdev: Put all HID state in a struct. 2017-09-21 21:50:37 +10:00
Damien George 980b33177b stm32/usbdev: Put all CDC state in a struct. 2017-09-21 21:48:28 +10:00
Damien George ede8a0235b py/vstr: Raise a RuntimeError if fixed vstr buffer overflows.
Current users of fixed vstr buffers (building file paths) assume that there
is no overflow and do not check for overflow after building the vstr.  This
has the potential to lead to NULL pointer dereferences
(when vstr_null_terminated_str returns NULL because it can't allocate RAM
for the terminating byte) and stat'ing and loading invalid path names (due
to the path being truncated).  The safest and simplest thing to do in these
cases is just raise an exception if a write goes beyond the end of a fixed
vstr buffer, which is what this patch does.  It also simplifies the vstr
code.
2017-09-21 20:29:41 +10:00
Damien George 347de3e218 stm32/usbdev: Change static function variable to non-static.
It's written straight away in the function on every call so it doesn't need
to be static.
2017-09-20 17:45:21 +10:00
Damien George 78602a217f stm32/usbdev: Make the USBD callback struct const so it can go in ROM. 2017-09-20 17:44:16 +10:00
Damien George aca498c2b0 stm32/mpconfigport.h: Add configuration for max periphs on L4 series. 2017-09-13 17:03:57 +10:00
Damien George d7cd1d2027 stm32/timer: Make pyb.Timer() instances persistent.
Prior to this patch calling pyb.Timer(id) would always create a new timer
instance, even if there was an existing one.  This patch fixes this
behaviour to match other peripherals, like UART, such that constructing a
timer with just the id will retrieve any existing instances.

The patch also refactors the way timers are validated on construction to
simplify and reduce code size.
2017-09-13 16:20:42 +10:00
Damien George da8c4c2653 py/builtinhelp: Change signature of help text var from pointer to array.
As a pointer (const char *) it takes up an extra word of storage which is
in RAM.
2017-09-12 16:03:52 +10:00
Damien George eea5fcc442 stm32/make-stmconst.py: Make sure mpz const data lives in ROM. 2017-09-12 15:31:43 +10:00
Paul Sokolovsky c46d480adc zephyr/Makefile: Revamp "test" target after ports were moved to ports/. 2017-09-10 22:25:43 +03:00
Paul Sokolovsky d6f9d64d97 tests/class_reverse_op: Test for reverse arith ops special methods.
This test should be run only if support for reverse ops is enabled, so
the corresponding feature_check is added to run-tests.
2017-09-10 17:05:57 +03:00
Paul Sokolovsky eb84a830df py/runtime: Implement dispatch for "reverse op" special methods.
If, for class X, X.__add__(Y) doesn't exist (or returns NotImplemented),
try Y.__radd__(X) instead.

This patch could be simpler, but requires undoing operand swap and
operation switch to get non-confusing error message in case __radd__
doesn't exist.
2017-09-10 17:05:57 +03:00
Paul Sokolovsky 9355cca610 esp8266: Set DEFPSIZE=1024, MINCACHE=3 for "btree" module.
Defaults of 4096 and 5 respectively are too high to esp8266, causing
out of memory with a database beyond couple of pages.
2017-09-10 13:54:00 +03:00
Paul Sokolovsky 9b4666dad5 esp8266/posix_helpers: Set ENOMEM on memory alloc failure.
POSIX requires malloc(), etc. to set ENOMEM on the failure, and e.g.
BerkeleyDB relies on this:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/malloc.html

This should fix confusing OSError exceptions with 0 error code when
working with btree module.
2017-09-10 09:55:18 +03:00
Paul Sokolovsky 5671a11b81 esp8266: Rename axtls_helpers.c to posix_helpers.c.
As it's used by BerkeleyDB, etc.
2017-09-10 09:47:20 +03:00
Tobias Badertscher bd71b3252a stm32/boards: Add new board B_L475E_IOT01A based on STM32L475. 2017-09-10 16:02:39 +10:00
Damien George cc7fece309 stm32/modnwwiznet5k: Release the GIL on blocking network operations.
connect, send, recv, sendto and recvfrom now release the GIL.  accept
already releases the GIL because it calls mp_hal_delay_ms() within its
busy-wait loop.
2017-09-08 12:23:33 +10:00
Damien George 19f1b39d6f stm32/i2c: When scanning for I2C devices only do 1 probe per address.
Previous to this patch the i2c.scan() method would do up to 100 probes per
I2C address, to detect the devices on the bus.  This repeated probing was a
relic from when the code was copied from the accelerometer initialisation,
which requires to do repeated probes while waiting for the accelerometer
chip to turn on.

But I2C devices shouldn't need more than 1 probe to detect their presence,
and the generic software I2C implementation uses 1 probe successfully.  So
this patch changes the implementation to use 1 probe per address, which
significantly speeds up the scan operation.
2017-09-08 11:19:40 +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