Commit Graph

10813 Commits

Author SHA1 Message Date
Damien George c13f9f209d all: Convert nlr_raise(mp_obj_new_exception_msg(x)) to mp_raise_msg(x).
This helper function was added a while ago and these are the remaining
cases to convert, to save a bit of code size.
2019-11-05 11:35:45 +11:00
Damien George 80df377e95 py/modsys: Report .mpy version in sys.implementation.
This commit adds a sys.implementation.mpy entry when the system supports
importing .mpy files.  This entry is a 16-bit integer which encodes two
bytes of information from the header of .mpy files that are supported by
the system being run: the second and third bytes, .mpy version, and flags
and native architecture.  This allows determining the supported .mpy file
dynamically by code, and also for the user to find it out by inspecting
this value.  It's further possible to dynamically detect if the system
supports importing .mpy files by `hasattr(sys.implementation, 'mpy')`.
2019-11-04 16:00:41 +11:00
Damien George f4601af10a py/persistentcode: Move declarations for .mpy header from .c to .h file. 2019-11-04 16:00:05 +11:00
Jim Mussared 5578182ec9 py/objgenerator: Allow pend_throw to an unstarted generator.
Replace the is_running field with a tri-state variable to indicate
running/not-running/pending-exception.

Update tests to cover the various cases.

This allows cancellation in uasyncio even if the coroutine hasn't been
executed yet.  Fixes #5242
2019-11-04 15:51:16 +11:00
Jim Mussared 576ed89224 py/objgenerator: Remove globals from mp_obj_gen_instance_t.
This wasn't necessary as the wrapped function already has a reference to
its globals.  But it had a dual purpose of tracking whether the function
was currently running, so replace it with a bool.
2019-11-04 15:50:59 +11:00
Damien George 742030945c esp32/Makefile: Add correct arch to MPY_CROSS_FLAGS for native code. 2019-11-04 15:32:20 +11:00
Damien George 36c9be6f60 tools/mpy-tool.py: Use "@progbits #" attribute for native xtensa code. 2019-11-04 15:31:42 +11:00
Damien George f2ecfe8b83 py/nativeglue: Remove unused mp_obj_new_cell from mp_fun_table.
It has been unused since 9988618e0e
2019-11-01 17:26:10 +11:00
Damien George 2ee9e1a4ed extmod/modbtree: Make FILEVTABLE const to put it in ROM. 2019-11-01 17:25:40 +11:00
Damien George 32eae53fbc stm32/boards: Enable support for bluetooth on WB55 boards. 2019-11-01 14:58:24 +11:00
Damien George 6a64b280d0 stm32: Add support for RF coprocessor on WB55 MCUs.
This requires a BLE wireless stack firmware to be already programmed in the
secure flash area of the device.
2019-11-01 14:52:17 +11:00
Damien George 40ea1915fc extmod/nimble: Factor out stm32-specific HCI UART RX/TX code. 2019-11-01 12:41:37 +11:00
Damien George 78145b98ef extmod/nimble: Remove unneeded nimble_sprintf wrapper function. 2019-11-01 12:15:07 +11:00
Damien George 48b25a841b stm32: Add machine.Timer with soft timer implementation.
This commit adds an implementation of machine.Timer backed by the soft
timer mechanism.  It allows an arbitrary number of timers with 1ms
resolution, with an associated Python callback.  The Python-level API
matches existing ports that have a soft timer, and is used as:

    from machine import Timer
    t = Timer(freq=10, callback=lambda t:print(t))
    ...
    t = Timer(mode=Timer.ONE_SHOT, period=2000, callback=lambda t:print(t))
    ...
    t.deinit()
2019-10-31 22:12:55 +11:00
Damien George a5d97f1db9 stm32: Add soft timer implementation, using SysTick at 1ms resolution.
This commit adds an implementation of a "software timer" with a 1ms
resolution, using SysTick.  It allows unlimited number of concurrent
timers (limited only by memory needed for each timer entry).  They can be
one-shot or periodic, and associated with a Python callback.

There is a very small overhead added to the SysTick IRQ, which could be
further optimised in the future, eg by patching SysTick_Handler code
dynamically.
2019-10-31 22:12:55 +11:00
Damien George 43f53a2bbd tests/extmod: Add test for ussl when passing in key/cert params. 2019-10-31 16:38:20 +11:00
Damien George 9dd9f9ff06 extmod/modussl_mbedtls: Check for invalid key/cert data. 2019-10-31 16:22:42 +11:00
Damien George 07ea81fbc5 extmod/modussl_mbedtls: Fix getpeercert to return None if no cert avail. 2019-10-31 13:42:24 +11:00
Damien George 26d8fd2c0a extmod/modlwip: Unconditionally return POLLHUP/POLLERR when polling.
POSIX poll should always return POLLERR and POLLHUP in revents, regardless
of whether they were requested in the input events flags.

See issues #4290 and #5172.
2019-10-31 13:37:51 +11:00
Damien George feaa251674 extmod/modlwip: Make socket poll return POLLNVAL in case of bad file. 2019-10-31 12:54:37 +11:00
Damien George d3c383de79 py/stream.h: Add MP_STREAM_POLL_NVAL constant. 2019-10-31 12:54:37 +11:00
Damien George 71401d5065 extmod/modlwip: Unconditionally return POLLHUP when polling new socket.
POSIX poll should always return POLLERR and POLLHUP in revents, regardless
of whether they were requested in the input events flags.

See issues #4290 and #5172.
2019-10-31 12:54:37 +11:00
Damien George 9ec73aedb4 stm32/timer: Fix Timer.freq() calc so mult doesn't overflow uint32_t.
Fixes issue #5280.
2019-10-31 12:49:18 +11:00
Damien George 4e1b03d45c lib/libc/string0: Add simple implementations of strspn and strcspn.
They are needed for littlefs.
2019-10-30 12:14:52 +11:00
Damien George 660a61a388 extmod/vfs_lfs: Allow compiling in VfsLfs1 and VfsLfs2 separately.
These classes are enabled via the config options MICROPY_VFS_LFS1 and
MICROPY_VFS_LFS2, which are disabled by default.
2019-10-30 12:08:58 +11:00
Damien George 323d47887f py/runtime: Reorder some binary ops so they don't require conditionals.
runtime0.h is part of the MicroPython ABI so it's simpler if it's
independent of config options, like MICROPY_PY_REVERSE_SPECIAL_METHODS.

What's effectively done here is to move MP_BINARY_OP_DIVMOD and
MP_BINARY_OP_CONTAINS up in the enum, then remove the #if
MICROPY_PY_REVERSE_SPECIAL_METHODS conditional.

Without this change .mpy files would need to have a feature flag for
MICROPY_PY_REVERSE_SPECIAL_METHODS (when embedding native code that uses
this enum).

This commit has no effect when MICROPY_PY_REVERSE_SPECIAL_METHODS is
disabled.  With this option enabled this commit reduces code size by about
60 bytes.
2019-10-29 23:13:51 +11:00
Jim Mussared 25946d1ef4 examples/bluetooth/ble_uart_peripheral: Use append mode for RX char. 2019-10-29 23:11:11 +11:00
Jim Mussared ca3d4c84e4 docs/library/ubluetooth: Add docs for gatts_set_buffer. 2019-10-29 23:11:11 +11:00
Jim Mussared d16a27da51 extmod/modbluetooth: Add gatts_set_buffer.
- Adds an explicit way to set the size of a value's internal buffer,
  replacing `ble.gatts_write(handle, bytes(size))` (although that
  still works).
- Add an "append" mode for values, which means that remote writes
  will append to the buffer.
2019-10-29 23:09:02 +11:00
Kamil Klimek 53f3cbc2c4 zephyr/main: Use mp_stack API instead of local pointer for stack top.
The MP_STATE_THREAD(stack_top) is always available so use it instead of
creating a separate variable.  This also allows gc_collect() to be used as
an independent function, without real_main() being called.
2019-10-29 23:05:07 +11:00
Damien George a8138b75b1 examples/embedding: Replace symlink of mpconfigport.h with real file. 2019-10-29 22:53:34 +11:00
Damien George 162016ad9c travis: Add job to build and test unix minimal port.
To test that unix minimal port builds, and that test-suite can run with
minimal features enabled.
2019-10-29 22:23:00 +11:00
Damien George 943dd33b5f tests/basics: Split sys.exit test to separate file so it can be skipped. 2019-10-29 22:22:37 +11:00
Damien George 1d51115246 tests: Add feature check for uio module and skip corresponding tests. 2019-10-29 22:22:37 +11:00
Damien George eebffb2b5b tests/basics: Automatically skip tests that use str/bytes modulo-format. 2019-10-29 22:22:37 +11:00
Damien George 52299ed3f0 tests/run-tests: Add misc list of tests that use slice, to skip them. 2019-10-29 22:22:37 +11:00
Damien George b5186c9271 tests/basics: Split out specific slice tests to separate files.
So they can be automatically skipped if slice is not enabled.
2019-10-29 22:22:37 +11:00
Damien George ecb77e40e0 tests: Add feature check for slice and skip corresponding tests. 2019-10-29 22:22:37 +11:00
Damien George 9162a87d4d tests/basics: Use bytes not bytearray when checking user buffer proto.
Using bytes will test the same path for the buffer protocol in
py/objtype.c.
2019-10-29 22:22:37 +11:00
Damien George aeea204e98 tests/basics: Split out specific bytearray tests to separate files.
So they can be automatically skipped if bytearray is not enabled.
2019-10-29 22:22:37 +11:00
Damien George 6e9ba1cf4b tests: Add feature check for bytearray and skip corresponding tests. 2019-10-29 22:22:37 +11:00
Damien George 7a49fc387c tests/basics/builtin_dir.py: Look for "version" in dir(sys).
Because "version" will always be there, but "exit" may not.
2019-10-29 22:22:37 +11:00
Damien George 709136e844 tests/basics: Use str.format instead of % for formatting messages.
Only use % formatting when testing % itself, because only str.format is
guaranteed to be available on any port.
2019-10-29 22:22:37 +11:00
Damien George 4847460232 unix/mphalport.h: Define mp_hal_stdio_poll to dummy because it's unused.
And requires uintptr_t to declare the default version in py/mphal.h.
2019-10-29 22:22:37 +11:00
Damien George 7a24b7f091 docs/library: Add documentation for extended block device protocol. 2019-10-29 14:17:29 +11:00
Damien George 4cf054a130 extmod/vfs: Add MP_BLOCKDEV_IOCTL_BLOCK_ERASE constant. 2019-10-29 14:17:29 +11:00
Damien George cfe1c5abf8 extmod/vfs: Rename BP_IOCTL_xxx constants to MP_BLOCKDEV_IOCTL_xxx.
Also rename SEC_COUNT to BLOCK_COUNT and SEC_SIZE to BLOCK_SIZE.
2019-10-29 14:17:29 +11:00
Damien George 7c8fb27f38 tests/extmod: Add test for blockdev with standard and extended protocol. 2019-10-29 14:17:29 +11:00
Damien George 73fddb84e5 tests/extmod: Add littlefs tests. 2019-10-29 14:17:29 +11:00
Damien George 62d5659cdd unix: Enable uos.VfsLfs1, uos.VfsLfs2 on coverage build. 2019-10-29 14:17:29 +11:00