Wykres commitów

11596 Commity (27767aafa21754e6cdbf52a719e7ce395f0fe672)

Autor SHA1 Wiadomość Data
Zoltán Vörös 27767aafa2 lib/libm_dbl: Add round.c source code.
This code is imported from musl, to match existing code in libm_dbl.

The file is also added to the build in stm32/Makefile.  It's not needed by
the core code but, similar to c5cc64175b,
allows round() to be used by user C modules or board extensions.
2020-07-21 11:07:19 +10:00
Damien George a853fff838 py/obj.h: Fix mp_seq_replace_slice_no_grow to use memmove not memcpy.
Because the argument arrays may overlap, as show by the new tests in this
commit.

Also remove the debugging comments for these macros, add a new comment
about overlapping regions, and separate the macros by blank lines to make
them easier to read.

Fixes issue #6244.

Signed-off-by: Damien George <damien@micropython.org>
2020-07-21 01:05:59 +10:00
Damien George 895b1dbdda tests/basics: Split out memoryview slice-assign tests to separate file.
Signed-off-by: Damien George <damien@micropython.org>
2020-07-21 01:05:59 +10:00
Damien George f80b1d8535 lib/stm32lib: Update library for H7 v1.6.0 and WB v1.6.0.
Changes in this new library version are:
- Update H7 HAL to v1.6.0.
- Update WB HAL to v1.6.0.
- Add patches to fix F4 ll_uart clock selection for UART9/UART10.

Signed-off-by: Damien George <damien@micropython.org>
2020-07-21 01:02:58 +10:00
Kenneth Ryerson 76fefad18b esp32/network_lan: Add support for IP101 PHY.
Signed-off-by: Kenneth Ryerson <kenneth.ryerson@gmail.com>
2020-07-21 00:59:47 +10:00
Jonathan Hogg 5f0e9d1bac docs/library: Update documentation of esp32's RMT.
This explains how looping now works, and removes the warning about calling
wait_done().
2020-07-21 00:57:35 +10:00
Jonathan Hogg 7dbef5377c esp32/esp32_rmt: Properly fix looping behaviour of RMT.
A previous commit 3a9d948032 can cause
lock-ups of the RMT driver, so this commit reverses that, adds a loop_en
flag, and explicitly controls the TX interrupt in write_pulses().  This
provides correct looping, non-blocking writes and sensible behaviour for
wait_done().

See also #6167.
2020-07-21 00:57:14 +10:00
Thorsten von Eicken 5264478007 extmod/modussl_mbedtls: Integrate shorter error strings.
The stm32 and esp32 ports now use shorter error strings for mbedtls errors.
Also, MBEDTLS_ERROR_C is enabled on stm32 by default to get these strings.
2020-07-21 00:31:05 +10:00
Thorsten von Eicken 3e758ef235 lib/mbedtls_errors: Add code to patch mbedtls for shortened error strs.
The file `mbedtls_errors/mp_mbedtls_errors.c` can be used instead of
`mbedtls/library/error.c` to give shorter error strings, reducing the build
size of the error strings from about 12-16kB down to about 2-5kB.
2020-07-20 23:53:27 +10:00
Thorsten von Eicken 98e583430f lib/libc: Add implementation of strncpy. 2020-07-20 23:42:04 +10:00
Thorsten von Eicken 9aa214077e extmod/modussl: Improve exception error messages.
This commit adds human readable error messages when mbedtls or axtls raise
an exception.  Currently often just an EIO error is raised so the user is
lost and can't tell whether it's a cert error, buffer overrun, connecting
to a non-ssl port, etc.  The axtls and mbedtls error raising in the ussl
module is modified to raise:

    OSError(-err_num, "error string")

For axtls a small error table of strings is added and used for the second
argument of the OSErrer.  For mbedtls the code uses mbedtls' built-in
strerror function, and if there is an out of memory condition it just
produces OSError(-err_num).  Producing the error string for mbedtls is
conditional on them being included in the mbedtls build, via
MBEDTLS_ERROR_C.
2020-07-20 23:41:45 +10:00
Jim Mussared c7f7c0214c docs/library: For ubluetooth, add docs for _IRQ_GATTS_INDICATE_DONE. 2020-07-20 23:28:31 +10:00
Jim Mussared 9d823a5d9a extmod/modbluetooth: Add event for "indicate acknowledgement".
This commit adds the IRQ_GATTS_INDICATE_DONE BLE event which will be raised
with the status of gatts_indicate (unlike notify, indications require
acknowledgement).

An example of its use is added to ble_temperature.py, and to the multitests
in ble_characteristic.py.

Implemented for btstack and nimble bindings, tested in both directions
between unix/btstack and pybd/nimble.
2020-07-20 23:26:41 +10:00
Jim Mussared 3c7ca2004c extmod/modbluetooth: Fix so it builds in peripheral-only mode. 2020-07-20 23:25:56 +10:00
Jim Mussared 43ceadac55 extmod/modbluetooth: Ignore unused self_in in ble_gatts_indicate. 2020-07-20 23:25:22 +10:00
Jim Mussared b7698841b2 docs/library: Add gatts_indicate() doc to ubluetooth.rst.
Also clarify behavior of `gatts_notify` and add some TODOs about adding an
event for indication acknowledgement.
2020-07-18 14:34:44 +10:00
Jim Mussared 89a95b7c85 examples/bluetooth: Add simple UART demo with central and peripheral. 2020-07-18 14:34:29 +10:00
Jim Mussared e152d0c197 extmod/btstack: Schedule notify/indicate/write ops for bg completion.
The goal of this commit is to allow using ble.gatts_notify() at any time,
even if the stack is not ready to send the notification right now.  It also
addresses the same issue for ble.gatts_indicate() and ble.gattc_write()
(without response).  In addition this commit fixes the case where the
buffer passed to write-with-response wasn't copied, meaning it could be
modified by the caller, affecting the in-progress write.

The changes are:

- gatts_notify/indicate will now run in the background if the ACL buffer is
  currently full, meaning that notify/indicate can be called at any time.

- gattc_write(mode=0) (no response) will now allow for one outstanding
  write.

- gattc_write(mode=1) (with response) will now copy the buffer so that it
  can't be modified by the caller while the write is in progress.

All four paths also now track the buffer while the operation is in
progress, which prevents the GC free'ing the buffer while it's still
needed.
2020-07-18 14:23:47 +10:00
Jim Mussared 07aec4681f examples/bluetooth: In ble_advertising.py, skip appearance if not set. 2020-07-18 14:23:20 +10:00
Jim Mussared 5d0be97bd9 unix: Make the MICROPY_xxx_ATOMIC_SECTION mutex recursive.
This mutex is used to make the unix port behave more like bare metal, i.e.
it allows "IRQ handlers" to run exclusively by making the mutex recursive.
2020-07-18 14:22:06 +10:00
Glenn Ruben Bakke 342800c9a2 travis: Change nrf pca10056 board to build with s140 SoftDevice.
It might compile fine with S132 as SoftDevice for nRF52840.
However, there might be different hardware on the SoC which in
turn could make it fail.

SoftDevice S140 is correct BLE stack for nRF52840 SoC and would
provide a more accurate test build.
2020-07-17 13:07:32 +02:00
Matt Trentini 486cb6dd4a nrf: Add board definition for nRF52840-MDK-USB-Dongle. 2020-07-16 23:47:13 +10:00
Glenn Ruben Bakke d9e8edc8bc travis: Add pca10090 build to nrf job. 2020-07-16 11:51:52 +02:00
Glenn Ruben Bakke 411e1157e7 travis: Install newer toolchain for nrf job.
Update toolchain to GNU Arm Embedded Toolchain.
2020-07-16 11:51:52 +02:00
Glenn Ruben Bakke 95d0d1c486 nrf/boards: Enable RTCounter machine module for nrf9160 boards.
Resolves dependencies for MICROPY_PY_TIME_TICKS which
requires to link against nrfx_rtc.c functions by setting
MICROPY_PY_MACHINE_RTCOUNTER to 1.
2020-07-16 11:48:52 +02:00
Glenn Ruben Bakke b776fe6969 nrf/nrfx_config: Disable RTC2 for nRF9160 targets.
nRF9160 does not have any RTC2. Disable the configuration in
case of NRF9160_XXAA.
2020-07-16 11:44:44 +02:00
Alex Tsamakos f743bd3d25
nrf/boards: Add initial support for Actinius Icarus.
Example make command:

make BOARD=actinius_icarus
2020-07-10 03:48:30 +02:00
Thomas Friebel b6146ca1a1 extmod/nimble: Fix attr NULL ptr dereference in ble_gatt_attr_read_cb.
In case of error, NimBLE calls the read callback with attr = NULL.
2020-07-09 22:41:10 +10:00
iabdalkader c299cc94e3 stm32/pyb_can: Handle timeout arg for FDCAN in pyb_can_send.
Following the documented pyb can_send behavior in pyb.CAN docs.
2020-07-09 00:38:56 +10:00
iabdalkader d07073f4e2 stm32/fdcan: Support maximum timeout of HAL_MAX_DELAY in can_receive. 2020-07-09 00:38:40 +10:00
iabdalkader 63b2eb27d4 stm32/fdcan: Use FDCAN_RXFxS_FxFL instead of hard-coded value. 2020-07-09 00:38:33 +10:00
iabdalkader 8594389fe7 stm32/fdcan: Use the right FIFO to calc element address in can_receive. 2020-07-09 00:37:50 +10:00
Damien George f5dd46b479 unix/variants: Enable VFS and all supported filesystems on dev variant.
So that micropython-dev can be used to test VFS code, and inspect and build
filesystem images that are compatible with bare-metal systems.

Signed-off-by: Damien George <damien@micropython.org>
2020-07-08 23:57:25 +10:00
Martin Fischer 59ed3bdd9f nrf: Enable nrf tick support on all boards by default.
Having time.ticks_ms/us/add/diff is very useful and used by many drivers,
libraries and components.
2020-07-08 23:47:08 +10:00
Martin Fischer 15574cd665 nrf: Add support for time.ticks_xxx functions using RTC1.
This commit adds time.ticks_ms/us support using RTC1 as the timebase.  It
also adds the time.ticks_add/diff helper functions.  This feature can be
enabled using MICROPY_PY_TIME_TICKS.  If disabled the system uses the
legacy sleep methods and does not have any ticks functions.

In addition support for MICROPY_EVENT_POLL_HOOK was added to the
time.sleep_ms(x) function, making this function more power efficient and
allows support for select.poll/asyncio.  To support this, the RTC's CCR0
was used to schedule a ~1msec event to wakeup the CPU.

Some important notes about the RTC timebase:

- Since the granularity of RTC1's ticks are approx 30usec, time.ticks_us is
not perfect, does not have 1us resolution, but is otherwise quite usable.
For tighter measurments the ticker's 1MHz counter should be used.

- time.ticks_ms(x) should *not* be called in an IRQ with higher prio than
the RTC overflow irq (3).  If so it introduces a race condition and
possibly leads to wrong tick calculations.

See #6171 and #6202.
2020-07-08 23:47:02 +10:00
Glenn Ruben Bakke c2317a3a8d nrf/Makefile: Disable ROM text compression when compiling for debug.
When compiling for debug (-O0) the .text segment cannot fit the flash
region when MICROPY_ROM_TEXT_COMPRESSION=1, because the compiler does not
optimise away the large if-else chain used to select the correct compressed
string.

This commit enforces MICROPY_ROM_TEXT_COMPRESSION=0 when compiling for
debug (DEBUG=1).
2020-07-01 22:54:52 +10:00
Glenn Ruben Bakke f22f7b285e nrf/bluetooth/ble_uart: Swap end character on cooked strings.
Changing line ending character of cooked strings makes rshell/pyboard.py
work correctly over Bluetooth socat/pts devices.
2020-07-01 22:51:30 +10:00
Glenn Ruben Bakke 5996bf72f1 nrf/bluetooth/ble_uart: Fix random advertisement name.
The storage space of the advertisement name is not declared static, leading
to a random advertisement name.  This commit fixes the issue by declaring
it static.
2020-07-01 22:50:56 +10:00
Glenn Ruben Bakke ab0c14dba0 nrf/bluetooth/ble_uart: Add mp_hal_stdio_poll function.
This adds support for enabling MICROPY_PY_SYS_STDFILES when running UART
over Bluetooth (NUS).
2020-07-01 22:50:41 +10:00
Glenn Ruben Bakke fc1f22a097 nrf/bluetooth: Handle data length update request.
The Bluetooth link gets disconnected when connecting from a PC after 30-40
seconds.  This commit adds handling of the data length update request.  The
data length parameter pointer is set to NULL in the reply,  letting the
SoftDevice automatically set values and use them in the data length update
procedure.
2020-07-01 22:49:04 +10:00
Glenn Ruben Bakke 9dfb4ae6aa nrf/bluetooth/ble_uart: Fix implicit declaration of function.
mp_keyboard_interrupt() triggers a compiler error because the function is
implicitly declared.  This commit adds "py/runtime.h" to the includes.

Fixes issue #5732.
2020-07-01 22:48:25 +10:00
Jim Mussared 4050281311 unix: Enable uasyncio on dev variant. 2020-07-01 22:44:41 +10:00
Jim Mussared 27abac95d8 unix: Make manifest selection match other ports.
Changes are:
- The default manifest.py is moved to the variants directory (it's in
  "boards" in other ports).
- The coverage variant now uses a custom manifest in its variant directory
  to add frzmpy/frzstr.
- The frzmpy/frzstr tests are moved to variants/coverage/.
2020-07-01 22:42:55 +10:00
Andrew Leech 07f181a216 Revert "tools/pydfu.py: Respect longer timeouts requested by DFU dev..."
This reverts commit 4d6f60d428.

This implementation used the timeout as a maximum amount of time needed for
the operation, when actually the spec and other tools suggest that it's the
minumum delay needed between subsequent USB transfers.
2020-07-01 16:54:03 +10:00
Andrew Leech 494bcad8ab stm32/mboot: Disable polling mode by default and use IRQ mode instead.
Polling mode will cause failures with the mass-erase command due to USB
timeouts, because the USB IRQs are not being serviced.  Swiching from
polling to IRQ mode fixes this because the USB IRQs can be serviced between
page erases.

Note that when the flash is being programmed or erased the MCU is halted
and cannot respond to USB IRQs, because mboot runs from flash, as opposed
to the built-in bootloader which is in system ROM.  But the maximum delay
in responding to an IRQ is the time taken to erase a single page, about
100ms for large pages, and that is short enough that the USB does not
timeout on the host side.

Recent tests have shown that in the current mboot code IRQ mode is pretty
much the same speed as polling mode (within timing error), code size is
slightly reduced in IRQ mode, and IRQ mode idles at about half of the power
consumption as polling mode.
2020-07-01 16:54:03 +10:00
Andrew Leech 95ec0debec stm32/mboot: Remove the use of timeout in DFU_GETSTATUS.
This is treated more like a "delay before continuing" in the spec and
official tools and does not appear to be really needed.  In particular,
downloading firmware is much slower with non-zero timeouts because the host
must pause by the timeout between sending each DFU_GETSTATUS to poll for
download/erase complete.
2020-07-01 16:33:10 +10:00
Damien George 332d83343f py: Rework mp_convert_member_lookup to properly handle built-ins.
This commit fixes lookups of class members to make it so that built-in
functions that are used as methods/functions of a class work correctly.

The mp_convert_member_lookup() function is pretty much completely changed
by this commit, but for the most part it's just reorganised and the
indenting changed.  The functional changes are:

- staticmethod and classmethod checks moved to later in the if-logic,
  because they are less common and so should be checked after the more
  common cases.

- The explicit mp_obj_is_type(member, &mp_type_type) check is removed
  because it's now subsumed by other, more general tests in this function.

- MP_TYPE_FLAG_BINDS_SELF and MP_TYPE_FLAG_BUILTIN_FUN type flags added to
  make the checks in this function much simpler (now they just test this
  bit in type->flags).

- An extra check is made for mp_obj_is_instance_type(type) to fix lookup of
  built-in functions.

Fixes #1326 and #6198.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-30 23:55:32 +10:00
Damien George d06ae1d2b1 py/obj.h: Make existing MP_TYPE_FLAG_xxx macros sequential.
There's no reason to have them non-sequential, this was likely a typo from
commit 9ec1caf42e.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-30 23:55:32 +10:00
Damien George 41b7734c46 zephyr/make-minimal: Disable FAT and LFS2 options to make it build.
Signed-off-by: Damien George <damien@micropython.org>
2020-06-30 22:33:41 +10:00
Damien George f84145bea1 zephyr: Implement machine.Pin.irq() for setting callbacks on pin change.
Supports hard and soft interrupts.  In the current implementation, soft
interrupt callbacks will only be called when the VM is executing, ie they
will not be called during a blocking kernel call like k_msleep.  And the
behaviour of hard interrupt callbacks will depend on the underlying device,
as well as the amount of ISR stack space.

Soft and hard interrupts tested on frdm_k64f and nucleo_f767zi boards.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-30 22:33:41 +10:00