Commit Graph

6568 Commits (hacking-on-plane)

Author SHA1 Message Date
Damien George eeb9d99333 docs/library/machine: Update description of disable/enable IRQ funcs. 2016-09-23 13:15:58 +10:00
Damien George 7df9291b6c py: Update opcode format table because 3 opcodes were removed, 1 added.
LIST_APPEND, MAP_ADD and SET_ADD have been removed, and STORE_COMP has
been added in adaf0d865c.
2016-09-23 12:48:57 +10:00
Damien George e97df97600 py: Shrink mp_arg_t struct by using reduced-size integer members.
qstrs ids are restricted to fit within 2 bytes already (eg in persistent
bytecode) so it's safe to use a uint16_t to store them in mp_arg_t.  And
the flags member only needs a maximum of 2 bytes so can also use uint16_t.

Savings in code size can be significant when many mp_arg_t structs are
used for argument parsing.  Eg, this patch reduces stmhal by 480 bytes.
2016-09-23 12:13:51 +10:00
Paul Sokolovsky 46ab042230 extmod/modussl_mbedtls: Add server_hostname param for wrap_socket().
In CPython, module-level .wrap_socket() function actually doesn't accept
(or document) this param, only SSLContext.wrap_socket() has.
2016-09-23 01:44:23 +03:00
Radomir Dopieralski ec078af985 extmod/machine_i2c: Add clock stretching support.
When the clock is too fast for the i2c slave, it can temporarily hold
down the scl line to signal to the master that it needs to wait. The
master should check the scl line when it is releasing it after
transmitting data, and wait for it to be released.

This change has been tested with a logic analyzer and an i2c slace
implemented on an atmega328p using its twi peripheral, clocked at 8Mhz.
Without the change, the i2c communication works up to aboy 150kHz
frequency, and above that results in the slave stuck in an unresponsive
state. With this change, communication has been tested to work up to
400kHz.
2016-09-22 14:10:02 +10:00
Krzysztof Blazewicz 1f69b16d3f stmhal: Remove STM32CubeF2 HAL files, they are unused/unsupported. 2016-09-22 12:11:01 +10:00
Krzysztof Blazewicz 9310dad15d stmhal: Put common definitions from linker files to common.ld. 2016-09-22 12:03:12 +10:00
Damien George c4a69c75a5 unix: Enable btree module for coverage build. 2016-09-22 11:10:11 +10:00
Damien George 6c79980b0e py/py.mk: Suppress some compiler warnings when building berkeley-db. 2016-09-22 11:09:21 +10:00
Damien George 79ec869f95 py/stream: Remove unnecessary check for NULL return from vstr_extend.
vstr_extend will now only return NULL if the vstr is a fixed buffer, which
in this case it is not.
2016-09-22 10:50:47 +10:00
Damien George c528489eee README: Remove issue-stats badges, the service is no longer available.
The issue-stats service is not well maintained and likely the situation
won't improve in the future.  See:
https://github.com/hstove/issue_stats/issues/41
https://github.com/hstove/issue_stats/issues/46
2016-09-22 10:38:49 +10:00
Paul Sokolovsky 080e4d44f3 extmod/modussl_mbedtls: Use 2-component include paths.
This is required to use mbedTLS versions from various sources, e.g.
mainline vs embedded into Zephyr RTOS.
2016-09-22 01:30:48 +03:00
Paul Sokolovsky 5f0ecb72c2 extmod/modussl_mbedtls: Implement key= and cert= args to wrap_socket().
Unlike standard keyfile= and certfile=, these accept byte buffer objects
(to not depend on FS implementation).
2016-09-22 00:17:44 +03:00
Pavol Rusnak 7f5a541b84 extmod/modubinascii: Fix crc32() function on 32-bit platforms. 2016-09-21 21:40:18 +03:00
Stefan Agner b84e1231c9 extmod/uctypes: Allow full 32-bit address range.
Use mp_obj_int_get_truncated to allow the full 32-bit address range
as first parameter.
2016-09-21 21:37:08 +03:00
Paul Sokolovsky 9ea2882317 extmod/modussl_mbedtls: Initial implementation of mbedTLS ussl module. 2016-09-21 21:25:33 +03:00
Damien George 93c4a6a3f7 all: Remove 'name' member from mp_obj_module_t struct.
One can instead lookup __name__ in the modules dict to get the value.
2016-09-22 00:23:16 +10:00
Stefan Agner b0a46900de stmhal: Use attribute to avoid inlining.
Use MP_NOINLINE macro to avoid inlining of init_flash_fs. This helps
to keep stack usage of main() low.
2016-09-20 20:41:11 -07:00
Paul Sokolovsky 7ea3fa2641 py/builtinimport: Fix nanbox build after change to better handle -m modules. 2016-09-20 17:55:42 +03:00
Delio Brignoli 21c719bd0a builtinimport: add the module specified by -m to sys.modules as '__main__' 2016-09-20 14:01:31 +03:00
Damien George 34e0198436 esp8266: Extend system microsecond counter to 64-bits; use in ticks_ms.
So now ticks_ms can count up to the full 30 bits.  Fixes issue #2412.
2016-09-20 14:28:17 +10:00
Damien George cc7c311b5e travis: Run feature and coverage test for precompiled mpy files. 2016-09-20 12:21:53 +10:00
Damien George 3f5fe6269e tests/run-tests: Add --via-mpy option to run test from precompiled code.
With mpy-cross built, tests can now be run by first compiling them to .mpy
files, and then executing the .mpy file.  Usage: ./run-tests --via-mpy
2016-09-20 12:19:35 +10:00
Damien George bb954d80a4 tests: Get cmdline verbose tests running again.
The showbc function now no longer uses the system printf so works
correctly.
2016-09-20 11:33:19 +10:00
Damien George fbddea929d py/showbc: Make printf's go to the platform print stream.
The system printf is no longer used by the core uPy code.  Instead, the
platform print stream or DEBUG_printf is used.  Using DEBUG_printf in the
showbc functions would mean that the code can't be tested by the test
suite, so use the normal output instead.

This patch also fixes parsing of bytecode-line-number mappings.
2016-09-20 11:30:54 +10:00
Paul Sokolovsky 60592fd23c tests/array1: Add tests for "l", "L" array types to improve coverage. 2016-09-19 17:20:41 +03:00
Paul Sokolovsky b85bcd671c tests/struct1: Test "l" specifier to improve coverage. 2016-09-19 17:01:02 +03:00
Damien George e60835bac5 py/qstr: Remove a comment.
qstrs are always null terminated so qstr_str will stay as part of the API.
2016-09-19 13:18:54 +10:00
Damien George 4874bde104 stmhal/boards: For OLIMEX_E407, enable UART1 and fix I2C1 mapping.
UART1 can be used even if the switch is enabled.  The schematics for this
board make I2C1 available on PB8/PB9, even though it can also be mapped
to PB6/PB7.

See #2396 and #2427.
2016-09-19 13:00:15 +10:00
Damien George 8dd5960ac0 py/objnone: Use mp_generic_unary_op instead of custom one. 2016-09-19 12:28:55 +10:00
Damien George 5da0d29d3c py/vstr: Remove vstr.had_error flag and inline basic vstr functions.
The vstr.had_error flag was a relic from the very early days which assumed
that the malloc functions (eg m_new, m_renew) returned NULL if they failed
to allocate.  But that's no longer the case: these functions will raise an
exception if they fail.

Since it was impossible for had_error to be set, this patch introduces no
change in behaviour.

An alternative option would be to change the malloc calls to the _maybe
variants, which return NULL instead of raising, but then a lot of code
will need to explicitly check if the vstr had an error and raise if it
did.

The code-size savings for this patch are, in bytes: bare-arm:188,
minimal:456, unix(NDEBUG,x86-64):368, stmhal:228, esp8266:360.
2016-09-19 12:28:55 +10:00
Damien George adaf0d865c py: Combine 3 comprehension opcodes (list/dict/set) into 1.
With the previous patch combining 3 emit functions into 1, it now makes
sense to also combine the corresponding VM opcodes, which is what this
patch does.  This eliminates 2 opcodes which simplifies the VM and reduces
code size, in bytes: bare-arm:44, minimal:64, unix(NDEBUG,x86-64):272,
stmhal:92, esp8266:200.  Profiling (with a simple script that creates many
list/dict/set comprehensions) shows no measurable change in performance.
2016-09-19 12:28:03 +10:00
Damien George a5624bf381 py: Combine 3 comprehension emit functions (list/dict/set) into 1.
The 3 kinds of comprehensions are similar enough that merging their emit
functions reduces code size.  Decreases in code size in bytes are:
bare-arm:24, minimal:96, unix(NDEBUG,x86-64):328, stmhal:80, esp8266:76.
2016-09-19 12:23:31 +10:00
Paul Sokolovsky 4b3f1d712b esp8266/esp_mphal: Add tentative change to mp_hal_stdin_rx_chr() to wait IRQ.
Instead of busy-looping waiting for UART input. Not enabled by default,
needs more testing.
2016-09-19 00:23:38 +03:00
Paul Sokolovsky 3fe047f08f esp8266/ets_alt_task: ets_post: Should return 0 on success, !0 - failure. 2016-09-18 23:01:58 +03:00
Paul Sokolovsky 4ab3eef8d7 docs/library/pyb.SPI: init(): Describe "bits" argument.
Based on https://github.com/micropython/micropython/pull/2210 .
2016-09-18 21:41:21 +03:00
juhasch a2391b5a74 Small WiPy doc fixes 2016-09-18 21:38:29 +03:00
Paul Sokolovsky 5bf1b4e9d9 unix/modjni: array(): Support creation of object arrays. 2016-09-18 13:37:40 +03:00
Dave Hylands d08c9d342f Updated FROZEN_DIR support as per f28efa1971 2016-09-17 12:55:11 -07:00
Paul Sokolovsky f28efa1971 py: Move frozen modules rules from esp8266 port for reuse across ports.
A port now just needs to define FROZEN_DIR var and add $(BUILD)/frozen.c
to SRC_C to support frozen modules.
2016-09-17 21:00:40 +03:00
Paul Sokolovsky 8ae885a0c6 esp8266/Makefile: Rename SCRIPTDIR to FROZEN_DIR for consistency.
With FROZEN_MPY_DIR.
2016-09-17 21:00:04 +03:00
Paul Sokolovsky ee324c501e unix/modjni: Add array() top-level function to create Java array.
Takes element primitive type encoded as a char per standard JNI encoding,
and array size. TODO: Support object arrays.
2016-09-17 16:14:02 +03:00
Damien George b9672bcbe8 tests/extmod: Add test for machine.time_pulse_us(). 2016-09-16 23:31:02 +10:00
Damien George 2b7c4a1878 tests/basics: Add errno1 test, to check basics of uerrno module. 2016-09-16 15:33:51 +10:00
Damien George 67a4813601 tests/extmod/urandom: Add urandom tests for error cases. 2016-09-16 12:49:15 +10:00
Damien George f84b341618 py/objnone: Remove unnecessary handling of MP_UNARY_OP_BOOL.
bool(None) has a fast path in mp_obj_is_true so doesn't need to be
handled in none_unary_op.  The only caveat is that subclassing may
bypass the mp_obj_is_true function, but actually you aren't allowed to
subclass classes that have singleton instances like NoneType (see
https://mail.python.org/pipermail/python-dev/2002-March/020822.html for
reference on this point).
2016-09-16 12:30:09 +10:00
Paul Sokolovsky 3fea1f014c unix/modjni: Implement subscription for object arrays. 2016-09-16 00:59:48 +03:00
Damien George 0fd3d8d19f stmhal/boards: Add pllvalues.py script to compute PLL values for sysclk.
The algorithm here should mirror that in the machine.freq() function.
2016-09-14 13:00:27 +10:00
Renato Aguiar 081c0648ec unix: Fix build for when MICROPY_PY_SOCKET=0. 2016-09-12 16:43:56 +10:00
stijn dd0e6ddfeb travis: Abandon mingw32 in favour of mingw-w64
This is actually long overdue: the README in the windows directory has been
updated once to indicate mingw32 is abandoned and not ok to use with uPy,
but we forgot travis builds were still using it.
As a bonus the travis build will succeed again since moduerrno.c now compiles.
(see https://github.com/micropython/micropython/pull/2399)
2016-09-10 10:15:30 +10:00