aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-05-21extmod/modlwip: Allow to compile with MICROPY_PY_LWIP disabled.Damien George
2018-05-21stm32/rtc: Don't try to set SubSeconds value on RTC.Damien George
The hardware doesn't allow it, instead the value is reset to 255 upon setting the other calendar/time values.
2018-05-21py/gc: When GC threshold is hit don't unnecessarily collect twice.Damien George
Without this, if GC threshold is hit and there is not enough memory left to satisfy the request, gc_collect() will run a second time and the search for memory will happen again and will fail again. Thanks to @adritium for pointing out this issue, see #3786.
2018-05-21minimal/main: Allow to compile without GC enabled.Daniel Shaulov
2018-05-21tests: Add some tests for bigint hash, float hash and float parsing.Damien George
Following outcome of recent fuzz testing and sanitizing by @jepler.
2018-05-21py/objfloat: Fix undefined integer behavior hashing negative zero.Jeff Epler
Under ubsan, when evaluating hash(-0.) the following diagnostic occurs: ../../py/objfloat.c:102:15: runtime error: negation of -9223372036854775808 cannot be represented in type 'mp_int_t' (aka 'long'); cast to an unsigned type to negate this value to itself So do just that, to tell the compiler that we want to perform this operation using modulo arithmetic rules.
2018-05-21py/mpz: Avoid undefined behavior at integer overflow in mpz_hash.Jeff Epler
Before this, ubsan would detect a problem when executing hash(006699999999999999999999999999999999999999999999999999999999999999999999) ../../py/mpz.c:1539:20: runtime error: left shift of 1067371580458 by 32 places cannot be represented in type 'mp_int_t' (aka 'long') When the overflow does occur it now happens as defined by the rules of unsigned arithmetic.
2018-05-21py/objfloat: Fix undefined shifting behavior in high-quality float hash.Jeff Epler
When computing e.g. hash(0.4e3) with ubsan enabled, a diagnostic like the following would occur: ../../py/objfloat.c:91:30: runtime error: shift exponent 44 is too large for 32-bit type 'int' By casting constant "1" to the right type the intended value is preserved.
2018-05-21py/parsenum: Avoid undefined behavior parsing floats with large exponents.Jeff Epler
Fuzz testing combined with the undefined behavior sanitizer found that parsing unreasonable float literals like 1e+9999999999999 resulted in undefined behavior due to overflow in signed integer arithmetic, and a wrong result being returned.
2018-05-21py/parsenum: Use int instead of mp_int_t for parsing float exponent.Damien George
There is no need to use the mp_int_t type which may be 64-bits wide, there is enough bit-width in a normal int to parse reasonable exponents. Using int helps to reduce code size for 64-bit ports, especially nan-boxing builds. (Similarly for the "dig" variable which is now an unsigned int.)
2018-05-21py/emitbc: Avoid undefined behavior calling memset() with NULL 1st arg.Jeff Epler
Calling memset(NULL, value, 0) is not standards compliant so we must add an explicit check that emit->label_offsets is indeed not NULL before calling memset (this pointer will be NULL on the first pass of the parse tree and it's more logical / safer to check this pointer rather than check that the pass is not the first one). Code sanitizers will warn if NULL is passed as the first value to memset, and compilers may optimise the code based on the knowledge that any pointer passed to memset is guaranteed not to be NULL.
2018-05-21esp8266: Change UART(0) to attach to REPL via uos.dupterm interface.Damien George
This patch makes it so that UART(0) can by dynamically attached to and detached from the REPL by using the uos.dupterm function. Since WebREPL uses dupterm slot 0 the UART uses dupterm slot 1 (a slot which is newly introduced by this patch). UART(0) must now be attached manually in boot.py (or otherwise) and inisetup.py is changed to provide code to do this. For example, to attach use: import uos, machine uart = machine.UART(0, 115200) uos.dupterm(uart, 1) and to detach use: uos.dupterm(None, 1) When attached, all incoming chars on UART(0) go straight to stdin so uart.read() will always return None. Use sys.stdin.read() if it's needed to read characters from the UART(0) while it's also used for the REPL (or detach, read, then reattach). When detached the UART(0) can be used for other purposes. If there are no objects in any of the dupterm slots when the REPL is started (on hard or soft reset) then UART(0) is automatically attached. Without this, the only way to recover a board without a REPL would be to completely erase and reflash (which would install the default boot.py which attaches the REPL).
2018-05-21esp32/Makefile: Update to latest ESP IDF version.Damien George
2018-05-21zephyr/Makefile: Add kobj_types_h_target to Z_EXPORTS.Paul Sokolovsky
New generated Zephyr header file, without it build breaks.
2018-05-21zephyr: Add prj_disco_l475_iot1.conf with sensor drivers.Paul Sokolovsky
2018-05-21zephyr/prj_base.conf: Enable DHCP and group static IPs together.Paul Sokolovsky
Add CONFIG_NET_DHCPV4, which, after https://github.com/zephyrproject-rtos/zephyr/pull/5750 works as follows: static addresses are configured after boot, and DHCP requests are sent at the same time. If valid DHCP reply is received, it overrides static addresses. This setup works out of the box for both direct connection to a workstation (DHCP server usually is not available) and for connection to a router (DHCP is available and required).
2018-05-21zephyr/modzsensor: Zephyr sensor subsystem bindings.Paul Sokolovsky
2018-05-21zephyr/mpconfigport.h: Enable uhashlib and ubinascii modules.Paul Sokolovsky
To be able to use data integrity checks in various tests.
2018-05-21zephyr/main: After builtin testsuite, drop to REPL.Paul Sokolovsky
It makes sense to make even testsuite-enabled builds be suitable for interactive use.
2018-05-21zephyr/README: Hint about existence of qemu_x86_nommu.Paul Sokolovsky
2018-05-18tools/pydfu.py: Fix typo in comments.Keith Wiley
2018-05-18py/compile: Change comment about ITER_BUF_NSLOTS to a static assertion.Damien George
2018-05-18py/misc.h: Add MP_STATIC_ASSERT macro to do static assertions.Damien George
2018-05-18stm32/boards: Add config files for new board, STM32L496GDISC.Tobias Badertscher
2018-05-18stm32/boards: Add board ld and af.csv files for STM32L496 MCU.Tobias Badertscher
2018-05-18stm32: Add support for STM32L496 MCU.Tobias Badertscher
2018-05-18py/repl: Fix handling of unmatched brackets and unfinished quotes.Li Weiwei
Before this patch: >>> print(') ... ') Traceback (most recent call last): File "<stdin>", line 1 SyntaxError: invalid syntax After this patch: >>> print(') Traceback (most recent call last): File "<stdin>", line 1 SyntaxError: invalid syntax This matches CPython and prevents getting stuck in REPL continuation when a 1-quote is unmatched.
2018-05-18py/vm: Improve performance of opcode dispatch when using switch stmt.Damien George
Before this patch, when using the switch statement for dispatch in the VM (not computed goto) a pending exception check was done after each opcode. This is not necessary and this patch makes the pending exception check only happen when explicitly requested by certain opcodes, like jump. This improves performance of the VM by about 2.5% when using the switch.
2018-05-18py/vm: Use enum names instead of magic numbers in multi-opcode dispatch.Damien George
2018-05-17esp8266/modmachine: Allow I2C and SPI to be configured out of the build.Damien George
I2C costs about 3000 bytes of code, and SPI costs about 4400 bytes.
2018-05-17extmod/modlwip: Set POLLHUP flag for sockets that are new.Damien George
This matches CPython behaviour on Linux: a socket that is new and not listening or connected is considered "hung up". Thanks to @rkojedzinszky for the initial patch, PR #3457.
2018-05-17esp8266/modnetwork: Raise ValueError when getting invalid WLAN id.Damien George
Instead of crashing due to out-of-bounds array access. Fixes #3348.
2018-05-17esp8266/modnetwork: Return empty str for hostname if STA is inactive.Damien George
Instead of crashing due to NULL pointer dereference. Fixes issue #3341.
2018-05-17esp8266/mpconfigport.h: Add some weak links to common Python modules.Damien George
To make it easier/simpler to write code that can run under both CPython and on an ESP8266 board.
2018-05-17lib/lwip: Update lwIP to v2.0.3, tag STABLE-2_0_3_RELEASE.Damien George
2018-05-17extmod/modlwip: Update to work with lwIP v2.0.Damien George
lwIP v2.0.3 has been tested with this lwip module and it works very well.
2018-05-17py/objfun: Fix variable name in DECODE_CODESTATE_SIZE() macro.Tom Collins
This patch fixes the macro so you can pass any name in, and the macro will make more sense if you're reading it on its own. It worked previously because n_state is always passed in as n_state_out_var.
2018-05-16py/vm: Adjust #if logic for gil_divisor so braces are balanced.Damien George
Having balanced braces { and } makes it easier to navigate the function.
2018-05-16stm32: Enable UART7/8 on F4 series that have these peripherals.Ryan Shaw
2018-05-15esp32/modnetwork: Fix STA/AP activate/deactivate for new IDF API.Damien George
WIFI_MODE_NULL is no longer supported by the ESP IDF, instead one must use esp_wifi_start/esp_wifi_stop.
2018-05-15py/nlrx86: Use naked attribute on nlr_push for gcc 8.0 and higher.Damien George
gcc 8.0 supports the naked attribute for x86 systems so it can now be used here. And in fact it is necessary to use this for nlr_push because gcc 8.0 no longer generates a prelude for this function (even without the naked attribute).
2018-05-15stm32/usb: Initialise cdc variable to prevent compiler warnings.Damien George
Some compilers cannot deduce that cdc will always be written before being used.
2018-05-14stm32/usb: Add ability to have 2x VCP interfaces on the one USB device.Damien George
This patch adds the configuration MICROPY_HW_USB_ENABLE_CDC2 which enables a new USB device configuration at runtime: VCP+VCP+MSC. It will give two independent VCP interfaces available via pyb.USB_VCP(0) and pyb.USB_VCP(1). The first one is the usual one and has the REPL on it. The second one is available for general use. This configuration is disabled by default because if the mode is not used then it takes up about 2200 bytes of RAM. Also, F4 MCUs can't support this mode on their USB FS peripheral (eg PYBv1.x) because they don't have enough endpoints. The USB HS peripheral of an F4 supports it, as well as both the USB FS and USB HS peripherals of F7 MCUs.
2018-05-14stm32/usb: Change HID report funcs to take HID state, not usbdev state.Damien George
2018-05-14stm32/usb: Change CDC tx/rx funcs to take CDC state, not usbdev state.Damien George
2018-05-14stm32/usb: Make CDC endpoint definitions private to core usbdev driver.Damien George
2018-05-14stm32/usb: Combine HID lower-layer and interface state into one struct.Damien George
2018-05-14stm32/usb: Combine CDC lower-layer and interface state into one struct.Damien George
2018-05-14stm32/usb: Use usbd_cdc_itf_t pointer directly in USB_VCP class.Damien George
2018-05-14stm32/modpyb: Remove unused includes and clean up comments.Damien George
The documentation (including the examples) for elapsed_millis and elapsed_micros can be found in docs/library/pyb.rst so doesn't need to be written in full in the source code.