summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-12-07stm32/Makefile: Change -O0 to -Og for DEBUG=1 builds.Damien George
The -Og optimisation level produces a more realistic build, gives a better debugging experience, and generates smaller code than -O0, allowing debug builds to fit in flash. This commit also assigns variables in can.c to prevent warnings when -Og is used, and builds a board in CI with DEBUG=1 enabled. Signed-off-by: Damien George <damien@micropython.org>
2020-12-07stm32: Add support for a board to reserve certain peripherals.Damien George
Allows reserving CAN, I2C, SPI, Timer and UART peripherals. If reserved the peripheral cannot be accessed from Python. Signed-off-by: Damien George <damien@micropython.org>
2020-12-07stm32/i2c: Factor I2C finding code to i2c_find_peripheral function.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-12-07stm32/powerctrl: Ensure SysTick is disabled on STOP mode entry for H7.iabdalkader
Even though IRQs are disabled this seems to be required on H7 Rev Y, otherwise Systick interrupt triggers and the MCU leaves the stop mode immediately.
2020-12-07stm32/powerctrl: Set H7 RTC wakeup flags.iabdalkader
2020-12-07stm32/powerctrl: Disable RTC write protection before changing flags.iabdalkader
2020-12-07stm32/powerctrl: On H7, re-enable disabled OSCs/PLLs on exit from STOP.iabdalkader
This commit saves OSCs/PLLs state before STOP mode and restores them on exit. Some boards use HSI48 for USB for example, others have PLL2/3 enabled, etc.
2020-12-07stm32/powerctrl: Fix STOP mode voltage scaling on H7 REV V devices.iabdalkader
2020-12-07stm32/powerctrl: Define RCC_SR_SFTRSTF flag for H747.iabdalkader
2020-12-07stm32/Makefile: Disable text compression in debug builds.iabdalkader
Otherwise the flash overflows. Fixes issue #6653.
2020-12-07stm32/modmachine: Add device and revision ids to machine.info().iabdalkader
2020-12-02tests/multi_bluetooth: Add multitests for BLE pairing and bonding.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-12-02extmod/nimble: Generate and persist a unique IRK.Jim Mussared
This provides a workaround for https://github.com/apache/mynewt-nimble/issues/887. Without this, all devices would share a fixed default IRK. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02docs/library/ubluetooth.rst: Add passkey docs.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02examples/bluetooth: Add bonding/passkey demo.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/modbluetooth: Add support for passkey authentication.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/modbluetooth: Simplify synchronous invoke_irq_handler signature.Jim Mussared
Rather than dealing with the different int types, just pass them all as a single array of mp_int_t with n_unsigned (before addr) and n_signed (after addr). Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02docs/library/ubluetooth.rst: Add bonding docs.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/modbluetooth: Add support for bonding (key persistence).Jim Mussared
This adds `_IRQ_GET_SECRET` and `_IRQ_SET_SECRET` events to allow the BT stack to request the Python code retrive/store/delete secret key data. The actual keys and values are opaque to Python and stack-specific. Only NimBLE is implemented (pending moving btstack to sync events). The secret store is designed to be compatible with BlueKitchen's TLV store API. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02docs/library/ubluetooth.rst: Add gap_pair() docs.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/modbluetooth: Add gap_pair(conn_handle) func to intiate pairing.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02docs/library/ubluetooth.rst: Add pairing/bonding config docs.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/modbluetooth: Allow configuration of pairing/bonding parameters.Jim Mussared
This allows setting the security and MITM-protection requirements. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/modbluetooth: Add _IRQ_ENCRYPTION_UPDATE event.Andrew Leech
This allows the application to be notified if any of encrypted, authenticated and bonded state change, as well as the encryption key size. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/modbluetooth: Add compile-config flag to enable pairing/bonding.Jim Mussared
Enable it on STM32/Unix NimBLE only (pairing/bonding requires synchronous events and full bindings). Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02docs/library/ubluetooth.rst: Update read request IRQ docs.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/modbluetooth: Allow user-specified reason in read request IRQ.Jim Mussared
Instead of returning None/bool from the IRQ, return None/int (where a zero value means success). This mirrors how the L2CAP_ACCEPT return value works. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02docs/library/ubluetooth.rst: Update char/desc flags.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/modbluetooth: Allow setting char/desc enc/auth options.Andrew Leech
This widens the characteristic/descriptor flags to 16-bit, to allow setting encryption/authentication requirements. Sets the required flags for NimBLE and btstack implementations. The BLE.FLAG_* constants will eventually be deprecated in favour of copy and paste Python constants (like the IRQs). Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02docs/library/ubluetooth.rst: Add _IRQ_CONNECTION_UDPATE docs.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/modbluetooth: Add _IRQ_CONNECTION_UPDATE event.Andrew Leech
This allows the application to be notified of changes to the connection interval, connection latency and supervision timeout. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/nimble: Fail read if the characteristic is too big.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02extmod/uasyncio: Fix cancellation handling of wait_for.Damien George
This commit switches the roles of the helper task from a cancellation task to a runner task, to get the correct semantics for cancellation of wait_for. Some uasyncio tests are now disabled for the native emitter due to issues with native code generation of generators and yield-from. Fixes #5797. Signed-off-by: Damien George <damien@micropython.org>
2020-12-02extmod/uasyncio: Add Task.done() method.Damien George
This is added because task.coro==None is no longer the way to detect if a task is finished. Providing a (CPython compatible) function for this allows the implementation to be abstracted away. Signed-off-by: Damien George <damien@micropython.org>
2020-12-02extmod/uasyncio: Delay calling Loop.call_exception_handler by 1 loop.Damien George
When a tasks raises an exception which is uncaught, and no other task await's on that task, then an error message is printed (or a user function called) via a call to Loop.call_exception_handler. In CPython this call is made when the Task object is freed (eg via reference counting) because it's at that point that it is known that the exception that was raised will never be handled. MicroPython does not have reference counting and the current behaviour is to deal with uncaught exceptions as early as possible, ie as soon as they terminate the task. But this can be undesirable because in certain cases a task can start and raise an exception immediately (before any await is executed in that task's coro) and before any other task gets a chance to await on it to catch the exception. This commit changes the behaviour so that tasks which end due to an uncaught exception are scheduled one more time for execution, and if they are not await'ed on by the next scheduling loop, then the exception handler is called (eg the exception is printed out). Signed-off-by: Damien George <damien@micropython.org>
2020-12-01docs/reference/repl.rst: Add information about new raw-paste mode.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-12-01tools/pyboard.py: Add fast raw-paste mode.Damien George
This commit adds support to pyboard.py for the new raw REPL paste mode. Note that this new pyboard.py is fully backwards compatible with old devices (it detects if the device supports the new raw REPL paste mode). Signed-off-by: Damien George <damien@micropython.org>
2020-11-30lib/utils/pyexec: Add stdin-reader on raw REPL with flow control.Damien George
Background: the friendly/normal REPL is intended for human use whereas the raw REPL is for computer use/automation. Raw REPL is used for things like pyboard.py script_to_run.py. The normal REPL has built-in flow control because it echos back the characters. That's not so with raw REPL and flow control is just implemented by rate limiting the amount of data that goes in. Currently it's fixed at 256 byte chunks every 10ms. This is sometimes too fast for slow MCUs or systems with small stdin buffers. It's also too slow for a lot of higher-end MCUs, ie it could be a lot faster. This commit adds a new raw REPL mode which includes flow control: the device will echo back a character after a certain number of bytes are sent to the host, and the host can use this to regulate the data going out to the device. The amount of characters is controlled by the device and sent to the host before communication starts. This flow control allows getting the maximum speed out of a serial link, regardless of the link or the device at the other end. Also, this new raw REPL mode parses and compiles the incoming data as it comes in. It does this by creating a "stdin reader" object which is then passed to the lexer. The lexer requests bytes from this "stdin reader" which retrieves bytes from the host, and does flow control. What this means is that no memory is used to store the script (in the existing raw REPL mode the device needs a big buffer to read in the script before it can pass it on to the lexer/parser/compiler). The only memory needed on the device is enough to parse and compile. Finally, it would be possible to extend this new raw REPL to allow bytecode (.mpy files) to be sent as well as text mode scripts (but that's not done in this commit). Some results follow. The test was to send a large 33k script that contains mostly comments and then prints out the heap, run via pyboard.py large.py. On PYBD-SF6, prior to this PR: $ ./pyboard.py large.py stack: 524 out of 23552 GC: total: 392192, used: 34464, free: 357728 No. of 1-blocks: 12, 2-blocks: 2, max blk sz: 2075, max free sz: 22345 GC memory layout; from 2001a3f0: 00000: h=hhhh=======================================hhBShShh==h=======h 00400: =====hh=B........h==h=========================================== 00800: ================================================================ 00c00: ================================================================ 01000: ================================================================ 01400: ================================================================ 01800: ================================================================ 01c00: ================================================================ 02000: ================================================================ 02400: ================================================================ 02800: ================================================================ 02c00: ================================================================ 03000: ================================================================ 03400: ================================================================ 03800: ================================================================ 03c00: ================================================================ 04000: ================================================================ 04400: ================================================================ 04800: ================================================================ 04c00: ================================================================ 05000: ================================================================ 05400: ================================================================ 05800: ================================================================ 05c00: ================================================================ 06000: ================================================================ 06400: ================================================================ 06800: ================================================================ 06c00: ================================================================ 07000: ================================================================ 07400: ================================================================ 07800: ================================================================ 07c00: ================================================================ 08000: ================================================================ 08400: ===============================================.....h==......... (349 lines all free) (the big blob of used memory is the large script). Same but with this PR: $ ./pyboard.py large.py stack: 524 out of 23552 GC: total: 392192, used: 1296, free: 390896 No. of 1-blocks: 12, 2-blocks: 3, max blk sz: 40, max free sz: 24420 GC memory layout; from 2001a3f0: 00000: h=hhhh=======================================hhBShShh==h=======h 00400: =====hh=h=B......h==.....h==.................................... (381 lines all free) The only thing in RAM is the compiled script (and some other unrelated items). Time to download before this PR: 1438ms, data rate: 230,799 bits/sec. Time to download with this PR: 119ms, data rate: 2,788,991 bits/sec. So it's more than 10 times faster, and uses significantly less RAM. Results are similar on other boards. On an stm32 board that connects via UART only at 115200 baud, the data rate goes from 80kbit/sec to 113kbit/sec, so gets close to saturating the UART link without loss of data. The new raw REPL mode also supports a single ctrl-C to break out of this flow-control mode, so that a ctrl-C can always get back to a known state. It's also backwards compatible with the original raw REPL mode, which is still supported with the same sequence of commands. The new raw REPL mode is activated by ctrl-E, which gives an error on devices that do not support the new mode. Signed-off-by: Damien George <damien@micropython.org>
2020-11-30github/workflows: Run unix and qemu-arm workflows when tests change.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-30README: Update badges for new GitHub Actions workflows.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-30tests/run-tests: Update skipped tests on CI for GitHub Actions.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-29travis: Stop using Travis for CI.Damien George
Travis now limits the amount of free minutes for open-source projects, and it does not provide enough for this project. So stop using it and instead use on GitHub Actions. Signed-off-by: Damien George <damien@micropython.org>
2020-11-29github/workflows: Add workflows for all CI tasks, builds and tests.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-29tools/ci.sh: Add helper script to run CI tasks.Damien George
The aim is for this script to be used on any CI platform, as well as run locally. Signed-off-by: Damien George <damien@micropython.org>
2020-11-29py/mpprint: Prevent case fall-through when assert is disabled.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-29tests/extmod: Add vfs_posix.py test for uos.VfsPosix class.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-24extmod/nimble/modbluetooth_nimble: Fix build when l2cap unavailable.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-24tests/multi_bluetooth: Add L2CAP channels multi-test.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-24docs/library/ubluetooth.rst: Add docs for L2CAP channels.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-24extmod/modbluetooth: Add API for L2CAP channels.Jim Mussared
Also known as L2CAP "connection oriented channels". This provides a socket-like data transfer mechanism for BLE. Currently only implemented for NimBLE on STM32 / Unix. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>