Wykres commitów

91 Commity (fca5701f74b784834d1af22d10988a1d0fddddaf)

Autor SHA1 Wiadomość Data
Damien George 8045ac07f5 stm32/mpbthciport: Switch scheduling callback to use node scheduler.
Signed-off-by: Damien George <damien@micropython.org>
2022-04-14 12:33:31 +10:00
Damien George 43d50f006d stm32/mpconfigport.h: Let MICROPY_PY_IO_FILEIO take its default value.
This is enabled at MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES, which is the
default for stm32.  Not setting the value in mpconfigboard.h allows boards
to optionally configure it.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-07 13:25:48 +10:00
iabdalkader fe8b47e29f ports: Allow boards to define additional network interfaces. 2022-03-24 17:23:28 +11:00
Damien George 11b77263ef stm32/moduos: Convert module to use extmod version.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 10:03:23 +11:00
Damien George 94077c6402 samd/moduos: Convert module to use extmod version.
Signed-off-by: Damien George <damien@micropython.org>
2022-03-09 10:03:23 +11:00
Damien George fbd47fc46c ports: Consolidate inclusion of umachine module in built-ins.
The inclusion of `umachine` in the list of built-in modules is now done
centrally in py/objmodule.c.  Enabling MICROPY_PY_MACHINE will include this
module.

As part of this, all ports now have `umachine` as the core module name
(previously some had only `machine` as the name).

Signed-off-by: Damien George <damien@micropython.org>
2022-02-03 10:08:54 +11:00
Damien George 1892d03740 mimxrt,stm32: Enable MICROPY_PY_USSL_FINALISER.
This is needed because these ports allocate mbedtls data on the MicroPython
heap, and SSL socket objects must be fully cleaned up when they are garbage
collected, to free this memory allocated by mbedtls.  As part of this,
gc_sweep_all() will now ensure that the MP_STATE_PORT(mbedtls_memory)
linked-list is fully deallocated on soft reset.

Signed-off-by: Damien George <damien@micropython.org>
2022-01-08 00:02:04 +11:00
iabdalkader 8af9dbbde1 stm32/network_wiznet5k: Fix build error with wiznet5k and lwip enabled.
Commit 4dba04a50f refactored the network code
but the combination of MICROPY_PY_WIZNET5K=5500 and MICROPY_PY_LWIP=1
broke.
2021-12-30 11:54:19 +11:00
MikeTeachman 6d5296e65e stm32,esp32: In machine_i2s, make object reference arrays root pointers.
This change eliminates the risk of the IRQ callback accessing invalid data.
Discussed here:
https://github.com/micropython/micropython/pull/7183#discussion_r660209875

Signed-off-by: Mike Teachman <mike.teachman@gmail.com>
2021-11-13 12:22:42 +11:00
Damien George c62351fbd6 py/mpconfig.h: Revert MICROPY_REPL_INFO to disabled at all levels.
This is an stm32-specific feature that's accessed via the pyb module, so
not something that will be widely enabled.

Signed-off-by: Damien George <damien@micropython.org>
2021-11-01 15:18:22 +11:00
Jim Mussared 3041881353 stm32/mpconfigport.h: Use the "extra" feature level.
This commit is a no-op change.  Future improvements can come from making
individual boards use CORE or BASIC.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-01 15:02:22 +11:00
iabdalkader 782d5b2e53 stm32: Enable platform module.
The HAL version is based on the stm32lib version.
2021-09-19 23:35:44 +10:00
Jim Mussared b326edf68c all: Remove MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE.
This commit removes all parts of code associated with the existing
MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE optimisation option, including the
-mcache-lookup-bc option to mpy-cross.

This feature originally provided a significant performance boost for Unix,
but wasn't able to be enabled for MCU targets (due to frozen bytecode), and
added significant extra complexity to generating and distributing .mpy
files.

The equivalent performance gain is now provided by the combination of
MICROPY_OPT_LOAD_ATTR_FAST_PATH and MICROPY_OPT_MAP_LOOKUP_CACHE (which has
been enabled on the unix port in the previous commit).

It's hard to provide precise performance numbers, but tests have been run
on a wide variety of architectures (x86-64, ARM Cortex, Aarch64, RISC-V,
xtensa) and they all generally agree on the qualitative improvements seen
by the combination of MICROPY_OPT_LOAD_ATTR_FAST_PATH and
MICROPY_OPT_MAP_LOOKUP_CACHE.

For example, on a "quiet" Linux x64 environment (i3-5010U @ 2.10GHz) the
change from CACHE_MAP_LOOKUP_IN_BYTECODE, to LOAD_ATTR_FAST_PATH combined
with MAP_LOOKUP_CACHE is:

diff of scores (higher is better)
N=2000 M=2000       bccache -> attrmapcache      diff      diff% (error%)
bm_chaos.py        13742.56 ->   13905.67 :   +163.11 =  +1.187% (+/-3.75%)
bm_fannkuch.py        60.13 ->      61.34 :     +1.21 =  +2.012% (+/-2.11%)
bm_fft.py         113083.20 ->  114793.68 :  +1710.48 =  +1.513% (+/-1.57%)
bm_float.py       256552.80 ->  243908.29 : -12644.51 =  -4.929% (+/-1.90%)
bm_hexiom.py         521.93 ->     625.41 :   +103.48 = +19.826% (+/-0.40%)
bm_nqueens.py     197544.25 ->  217713.12 : +20168.87 = +10.210% (+/-3.01%)
bm_pidigits.py      8072.98 ->    8198.75 :   +125.77 =  +1.558% (+/-3.22%)
misc_aes.py        17283.45 ->   16480.52 :   -802.93 =  -4.646% (+/-0.82%)
misc_mandel.py     99083.99 ->  128939.84 : +29855.85 = +30.132% (+/-5.88%)
misc_pystone.py    83860.10 ->   82592.56 :  -1267.54 =  -1.511% (+/-2.27%)
misc_raytrace.py   21490.40 ->   22227.23 :   +736.83 =  +3.429% (+/-1.88%)

This shows that the new optimisations are at least as good as the existing
inline-bytecode-caching, and are sometimes much better (because the new
ones apply caching to a wider variety of map lookups).

The new optimisations can also benefit code generated by the native
emitter, because they apply to the runtime rather than the generated code.
The improvement for the native emitter when LOAD_ATTR_FAST_PATH and
MAP_LOOKUP_CACHE are enabled is (same Linux environment as above):

diff of scores (higher is better)
N=2000 M=2000        native -> nat-attrmapcache  diff      diff% (error%)
bm_chaos.py        14130.62 ->   15464.68 :  +1334.06 =  +9.441% (+/-7.11%)
bm_fannkuch.py        74.96 ->      76.16 :     +1.20 =  +1.601% (+/-1.80%)
bm_fft.py         166682.99 ->  168221.86 :  +1538.87 =  +0.923% (+/-4.20%)
bm_float.py       233415.23 ->  265524.90 : +32109.67 = +13.756% (+/-2.57%)
bm_hexiom.py         628.59 ->     734.17 :   +105.58 = +16.796% (+/-1.39%)
bm_nqueens.py     225418.44 ->  232926.45 :  +7508.01 =  +3.331% (+/-3.10%)
bm_pidigits.py      6322.00 ->    6379.52 :    +57.52 =  +0.910% (+/-5.62%)
misc_aes.py        20670.10 ->   27223.18 :  +6553.08 = +31.703% (+/-1.56%)
misc_mandel.py    138221.11 ->  152014.01 : +13792.90 =  +9.979% (+/-2.46%)
misc_pystone.py    85032.14 ->  105681.44 : +20649.30 = +24.284% (+/-2.25%)
misc_raytrace.py   19800.01 ->   23350.73 :  +3550.72 = +17.933% (+/-2.79%)

In summary, compared to MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE, the new
MICROPY_OPT_LOAD_ATTR_FAST_PATH and MICROPY_OPT_MAP_LOOKUP_CACHE options:
- are simpler;
- take less code size;
- are faster (generally);
- work with code generated by the native emitter;
- can be used on embedded targets with a small and constant RAM overhead;
- allow the same .mpy bytecode to run on all targets.

See #7680 for further discussion.  And see also #7653 for a discussion
about simplifying mpy-cross options.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-09-16 16:04:03 +10:00
Jim Mussared 68219a295c stm32: Enable LOAD_ATTR fast path, and map lookup caching on >M0.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-09-16 16:02:19 +10:00
iabdalkader 4dba04a50f extmod/modnetwork: Define network interfaces in port config files.
So this network implementation becomes more generic.
2021-09-15 01:29:26 +10:00
Damien George afe0634c98 extmod/machine_spi: Make SoftSPI configurable via macro option.
Signed-off-by: Damien George <damien@micropython.org>
2021-09-02 13:11:23 +10:00
Damien George 122d901ef1 extmod/machine_i2c: Make SoftI2C configurable via macro option.
The zephyr port doesn't support SoftI2C so it's not enabled, and the legacy
I2C constructor check can be removed.

Signed-off-by: Damien George <damien@micropython.org>
2021-09-02 13:11:23 +10:00
Jim Mussared b51e7e9d01 stm32: Disable computed goto on constrained boards.
Saves ~1kiB.  Add comment to this effect to mpconfig.h.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-20 20:18:52 +10:00
Jim Mussared e64cda5295 stm32: Add implementation of machine.bitstream.
Hand-written version for M0, and cycle-counter version for everything else.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-19 22:50:32 +10:00
Jim Mussared 5733c49174 stm32,esp32,rp2: Enable MICROPY_PY_FSTRINGS by default.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-14 16:58:40 +10:00
Damien George 71e3538a32 stm32/usb: Add USB_VCP.irq method, to set a callback on USB data RX.
Usage:

    usb = pyb.USB_VCP()
    usb.irq(lambda u:print(u, u.read()), usb.IRQ_RX)

Signed-off-by: Damien George <damien@micropython.org>
2021-06-10 15:26:21 +10:00
Damien George 647fa63f9c stm32/softtimer: Support static soft timer instances.
This adds support for making static (ie not on the Python GC heap) soft
timers.  This can be useful for a board to define a custom background
handler, or eventually for BLE/network processing to use instead of systick
slots; it will be more efficient using soft timer for this.

The main issue with using the existing code for static soft timers is that
it would combine heap allocated and statically allocated soft_timer_entry_t
instances in the same pairing-heap data structure.  This would prevent the
GC from tracing some of the heap allocated entries (because the GC won't
follow pointers outside the heap).

This commit makes it so that soft timer entries are explicitly marked,
instead of relying on implicit marking by having the root of the pairing
heap in the root pointer section.  Also, on soft reset only the heap-
allocated soft timers are deleted from the pairing heap, leaving the
statically allocated ones.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-29 16:54:35 +10:00
Damien George 4d9e657f0e stm32/mpconfigport.h: Add support for a board to specify root pointers.
A board can now define MICROPY_BOARD_ROOT_POINTERS to specify any custom
root pointers.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-08 17:00:26 +10:00
Damien George 53f5bb05a9 rp2,stm32: Enable MICROPY_PY_UBINASCII_CRC32 to get ubinascii.crc32().
These ports already have uzlib enabled so this additional ubinascii.crc32
function only costs about 90 bytes of flash.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-23 10:13:25 +11:00
Chris Mason 9d674cf7ab stm32/uart: Add support for LPUART1 on L0, L4, H7 and WB MCUs.
Add LPUART1 as a standard UART.  No low power features are supported, yet.
LPUART1 is enabled as the next available UART after the standard U(S)ARTs:

    STM32WB:      LPUART1 = UART(2)
    STM32L0:      LPUART1 = UART(6)
    STM32L4:      LPUART1 = UART(6)
    STM32H7:      LPUART1 = UART(9)

On all ports: LPUART1 = machine.UART('LP1')

LPUART1 is enabled by defining MICROPY_HW_LPUART1_TX and
MICROPY_HW_LPUART1_RX in mpconfigboard.h.

Signed-off-by: Chris Mason <c.mason@inchipdesign.com.au>
2021-02-21 15:49:32 +11:00
Damien George 9b78f3e6c6 stm32: Make pyb, uos, utime, machine and onewire modules configurable.
The default for these is to enable them, but they can now be disabled
individually by a board configuration.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-17 14:42:46 +11:00
Damien George 7c44354592 ports: Remove def of MP_PLAT_PRINT_STRN if it's the same as the default.
To simplify config, there's no need to specify MP_PLAT_PRINT_STRN if it's
the same as the default definition in py/mpconfig.h.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-04 22:39:17 +11:00
Jim Mussared 61d1e4b01b extmod/nimble: Make stm32 and unix NimBLE ports use synchronous events.
This changes stm32 from using PENDSV to run NimBLE to use the MicroPython
scheduler instead.  This allows Python BLE callbacks to be invoked directly
(and therefore synchronously) rather than via the ringbuffer.

The NimBLE UART HCI and event processing now happens in a scheduled task
every 128ms.  When RX IRQ idle events arrive, it will also schedule this
task to improve latency.

There is a similar change for the unix port where the background thread now
queues the scheduled task.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-13 17:19:05 +11:00
robert 59019d7f75 stm32/mpconfigport.h: Seed the urandom module on import.
For seeding the rng_get function is used, which is also the heart of
uos.urandom and pyb.rng, and is a hardware RNG where available.
2020-10-29 14:12:53 +11:00
Damien George 9e0533b9e1 extmod/machine_spi: Remove "id" arg in SoftSPI constructor.
The SoftSPI constructor is now used soley to create SoftSPI instances, it
can no longer delegate to create a hardware-based SPI instance.

Signed-off-by: Damien George <damien@micropython.org>
2020-10-01 12:57:10 +10:00
Damien George aaed33896b extmod/machine_i2c: Remove "id" arg in SoftI2C constructor.
The SoftI2C constructor is now used soley to create SoftI2C instances, it
can no longer delegate to create a hardware-based I2C instance.

Signed-off-by: Damien George <damien@micropython.org>
2020-10-01 12:57:10 +10:00
Jim Mussared f3f31ac959 extmod/nimble: Make nimble_malloc work with allocated size. 2020-09-08 11:41:31 +10:00
Jim Mussared ed14435a8e extmod/modbluetooth: Refactor stack/hci/driver/port bindings.
Previously the interaction between the different layers of the Bluetooth
stack was different on each port and each stack.  This commit defines
common interfaces between them and implements them for cyw43, btstack,
nimble, stm32, unix.
2020-09-08 11:41:31 +10:00
Damien George 5e69926ea0 stm32/mpconfigport.h: Enable MICROPY_PY_REVERSE_SPECIAL_METHODS.
It's a useful core feature.

Signed-off-by: Damien George <damien@micropython.org>
2020-09-04 10:45:39 +10:00
Damien George eb9850ef6c stm32/mpconfigport.h: Enable PY_IO_FILEIO when any VFS is enabled.
Previously, if FAT was not enabled but LFS1/2 was then MICROPY_PY_IO_FILEIO
would be disabled and file binary-mode was not supported.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-25 16:32:48 +10:00
Jim Mussared 8119ec0765 extmod/modbluetooth: Don't hold atomic section during mp_sched_schedule.
Because, for example, on unix the atomic section isn't re-entrant, and
mp_sched_schedule() will try to re-acquire the atomic section.
2020-04-29 16:45:40 +10:00
Damien George 09154f585f stm32/mpconfigport.h: Make most extended modules configurable by board. 2020-03-28 13:46:35 +11:00
Damien George dbba6b05dc stm32/mpconfigport.h: Remove unused root pointer for BTstack bindings.
This was a cut-and-paste error from the NimBLE bindings.
2020-03-27 00:30:37 +11:00
Damien George 35e2dd0979 stm32: Enable and freeze uasyncio. 2020-03-26 01:25:45 +11:00
Damien George 0674917bc5 extmod/btstack: Implement advertising.
Work done in collaboration with Jim Mussared aka @jimmo.
2020-03-10 01:53:42 +11:00
Damien George 69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
hahmadi b169904254 stm32/mpconfigport.h: Add option to have custom help text.
Define MICROPY_PY_BUILTINS_HELP_TEXT in <yourboard>/mpconfigboard.h for a
custom help text.
2020-02-21 15:02:19 +11:00
Damien George 98a3911c43 py/scheduler: Add "raise_exc" argument to mp_handle_pending.
Previous behaviour is when this argument is set to "true", in which case
the function will raise any pending exception.  Setting it to "false" will
cancel any pending exception.
2020-02-07 16:08:20 +11:00
Damien George f70373c7b2 stm32/softtimer: Change linear linked list to a pairing heap. 2020-01-22 17:31:18 +11:00
Nicko van Someren 4c93955b7b py/objslice: Add support for indices() method on slice objects.
Instances of the slice class are passed to __getitem__() on objects when
the user indexes them with a slice.  In practice the majority of the time
(other than passing it on untouched) is to work out what the slice means in
the context of an array dimension of a particular length.  Since Python 2.3
there has been a method on the slice class, indices(), that takes a
dimension length and returns the real start, stop and step, accounting for
missing or negative values in the slice spec.  This commit implements such
a indices() method on the slice class.

It is configurable at compile-time via MICROPY_PY_BUILTINS_SLICE_INDICES,
disabled by default, enabled on unix, stm32 and esp32 ports.

This commit also adds new tests for slice indices and for slicing unicode
strings.
2019-12-28 23:55:15 +11:00
Yonatan Goldschmidt 61d2b40ad5 lib/utils/pyexec: Introduce MICROPY_REPL_INFO, wrap debug prints in it.
For the 3 ports that already make use of this feature (stm32, nrf and
teensy) this doesn't make any difference, it just allows to disable it from
now on.

For other ports that use pyexec, this decreases code size because the debug
printing code is dead (it can't be enabled) but the compiler can't deduce
that, so code is still emitted.
2019-12-28 00:05:39 +11:00
Damien George 93509ac8c7 stm32: Add configuration to build in nanbox mode.
Most stm32 boards can now be built in nan-boxing mode via:

    $ make NANBOX=1

Note that if float is enabled then it will be forced to double-precision.
Also, native emitters will be disabled.
2019-12-27 22:54:53 +11:00
Damien George d980d51807 stm32: Fix to build in nanbox mode. 2019-12-27 22:54:53 +11:00
Damien George 40cc7ec677 stm32/mpconfigport.h: Use IRQ_PRI_PENDSV to protect bluetooth ringbuf.
The default protection for the BLE ringbuf is to use
MICROPY_BEGIN_ATOMIC_SECTION, which disables all interrupts. On stm32 it
only needs to disable the lowest priority IRQ, pendsv, because that's the
IRQ level at which the BLE stack is driven.
2019-12-04 13:39:22 +11:00
Damien George 799b6d1e0c extmod: Consolidate FAT FS config to MICROPY_VFS_FAT across all ports.
This commit removes the Makefile-level MICROPY_FATFS config and moves the
MICROPY_VFS_FAT config to the Makefile level to replace it.  It also moves
the include of the oofatfs source files in the build from each port to a
central place in extmod/extmod.mk.

For a port to enabled VFS FAT support it should now set MICROPY_VFS_FAT=1
at the level of the Makefile.  This will include the relevant oofatfs files
in the build and set MICROPY_VFS_FAT=1 at the C (preprocessor) level.
2019-11-11 11:37:38 +11:00