Commit Graph

48 Commits

Author SHA1 Message Date
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
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
Jim Mussared
b02d7e612d extmod/modbluetooth: Rename module to "ubluetooth".
For consistency with "umachine". Now that weak links are enabled
by default for built-in modules, this should be a no-op, but allows
extension of the bluetooth module by user code.

Also move registration of ubluetooth to objmodule rather than
port-specific.
2019-10-22 21:58:05 +11:00
Damien George
d2384efa80 py: Automatically provide weak links from "foo" to "ufoo" module name.
This commit implements automatic module weak links for all built-in
modules, by searching for "ufoo" in the built-in module list if "foo"
cannot be found.  This means that all modules named "ufoo" are always
available as "foo".  Also, a port can no longer add any other weak links,
which makes strict the definition of a weak link.

It saves some code size (about 100-200 bytes) on ports that previously had
lots of weak links.

Some changes from the previous behaviour:
- It doesn't intern the non-u module names (eg "foo" is not interned),
  which saves code size, but will mean that "import foo" creates a new qstr
  (namely "foo") in RAM (unless the importing module is frozen).
- help('modules') no longer lists non-u module names, only the u-variants;
  this reduces duplication in the help listing.

Weak links are effectively the same as having a set of symbolic links on
the filesystem that is searched last.  So an "import foo" will search
built-in modules first, then all paths in sys.path, then weak links last,
importing "ufoo" if it exists.  Thus a file called "foo.py" somewhere in
sys.path will still have precedence over the weak link of "foo" to "ufoo".

See issues: #1740, #4449, #5229, #5241.
2019-10-22 15:30:52 +11:00
Jim Mussared
902bb4ceae stm32: Extract port-specific Nimble implementation.
On other ports (e.g. ESP32) they provide a complete Nimble implementation
(i.e. we don't need to use the code in extmod/nimble). This change
extracts out the bits that we don't need to use in other ports:
 - malloc/free/realloc for Nimble memory.
 - pendsv poll handler
 - depowering the cywbt

Also cleans up the root pointer management.
2019-10-08 14:40:35 +11:00
Jim Mussared
6f35f214d3 stm32/mpconfigport.h: Add modbluetooth module to stm32. 2019-10-01 09:51:02 +10:00
Jim Mussared
d72dbb822c stm32: Provide port-specific implementation for Nimble on STM32. 2019-10-01 09:51:02 +10:00
Damien George
3328b7d71f stm32: Support disabling the compiler.
Disable via "#define MICROPY_ENABLE_COMPILER (0)" in the board's
mpconfigboard.h file.
2019-09-26 17:05:40 +10:00
stijn
af5c998f37 py/modmath: Implement math.isclose() for non-complex numbers.
As per PEP 485, this function appeared in for Python 3.5.  Configured via
MICROPY_PY_MATH_ISCLOSE which is disabled by default, but enabled for the
ports which already have MICROPY_PY_MATH_SPECIAL_FUNCTIONS enabled.
2019-08-17 23:23:17 +10:00
Damien George
102815f700 stm32/mpconfigport.h: Enable lwIP raw sockets. 2019-08-06 15:56:05 +10:00
Damien George
6053e450b8 stm32/mpconfigport.h: Make "framebuf" module configurable by a board. 2019-07-05 17:26:49 +10:00
Damien George
6d2e654b14 stm32/mpconfigport.h: Enable useful networking modules if lwIP enabled. 2019-07-03 11:21:45 +10:00
Damien George
fed4c23590 stm32: Integrate optional mbedTLS component for ussl module.
To use it a board should define MICROPY_PY_USSL=1 and MICROPY_SSL_MBEDTLS=1
at the Makefile level.  With the provided configuration it adds about 64k
to the build.
2019-06-05 15:37:31 +10:00
Chris Mason
1b956ec817 stm32: Add support for F413 MCUs.
Includes:
- Support for CAN3.
- Support for UART9 and UART10.
- stm32f413xg.ld and stm32f413xh.ld linker scripts.
- stm32f413_af.csv alternate function mapping.
- startup_stm32f413xx.s because F413 has different interrupt vector table.
- Memory configuration with: 240K filesystem, 240K heap, 16K stack.
2019-05-02 16:26:53 +10:00
Andrew Leech
9d6f70f715 stm32: Make default USB_VCP stream go through uos.dupterm for main REPL.
Use uos.dupterm for REPL configuration of the main USB_VCP(0) stream on
dupterm slot 1, if USB is enabled.  This means dupterm can also be used to
disable the boot REPL port if desired, via uos.dupterm(None, 1).

For efficiency this adds a simple hook to the global uos.dupterm code to
work with streams that are known to be native streams.
2019-04-01 13:04:05 +11:00
Damien George
781947afdc stm32/mpconfigport.h: Remove malloc/free/realloc helper macros.
These macros are unused, and they can conflict with other entities by the
same name.  If needed they can be provided as static inline functions, or
just functions.

Fixes issue #4559.
2019-03-26 18:42:19 +11:00
Damien George
b5f33ac2cb ports: Update to work with new oofatfs version. 2019-03-05 15:56:39 +11:00
Damien George
08a24c5f41 stm32/mpconfigport.h: Enable lwIP concurrency protection mechanism. 2019-02-26 23:32:19 +11:00
Damien George
800871c0cb stm32/modnetwork: Change lwIP polling to be based on background systick. 2019-02-08 16:38:09 +11:00
Damien George
da1d849ad1 stm32,esp8266,cc3200: Use MICROPY_GC_STACK_ENTRY_TYPE to save some RAM. 2018-12-04 18:32:10 +11:00
Damien George
84090edaa3 stm32/mpconfigport.h: Enable math.factorial, optimised version. 2018-09-26 15:05:19 +10:00
Damien George
8f86fbfd6c ports: Enable ure.sub() on stm32, esp8266 (not 512k) and esp32. 2018-07-02 15:13:18 +10:00
Damien George
565f590586 ports: Enable IOBase on unix, stm32, esp8266 and esp32.
It's a core feature, in particular required for user-streams with uasyncio.
2018-06-12 12:29:26 +10:00
Damien George
190c7dba89 stm32/mpconfigport.h: Enable DELATTR_SETATTR and BUILTINS_NOTIMPLEMENTED
MICROPY_PY_DELATTR_SETATTR can now be enabled without a performance hit for
classes that don't use this feature.

MICROPY_PY_BUILTINS_NOTIMPLEMENTED is a minor addition that improves
compatibility with CPython.
2018-06-08 12:55:18 +10:00
Damien George
93150a0d40 ports: Enable descriptors on stm32, esp8266, esp32 ports.
They are now efficient (in runtime performance) and provide a useful
feature that's hard to obtain without them enabled.

See issue #3644 and PR #3826 for background.
2018-06-08 12:23:08 +10:00
Damien George
f35aae366c extmod/vfs_fat: Rename FileIO/TextIO types to mp_type_vfs_fat_XXX.
So they don't clash with other VFS implementations.
2018-06-06 14:28:23 +10:00
Damien George
6d83468a30 stm32: Allow a board to disable MICROPY_VFS_FAT. 2018-05-28 21:46:20 +10:00
Damien George
20b4b85f72 ports: Enable MICROPY_PY_BUILTINS_ROUND_INT on selected ports. 2018-05-22 14:18:16 +10:00
Damien George
cda964198a stm32: Integrate lwIP as implementation of usocket module.
This patch allows to use lwIP as the implementation of the usocket module,
instead of the existing socket-multiplexer that delegates the entire TCP/IP
layer to the NIC itself.

This is disabled by default, and enabled by defining MICROPY_PY_LWIP to 1.

When enabled, the lwIP TCP/IP stack will be included in the build with
default settings for memory usage and performance (see
lwip_inc/lwipopts.h).  It is then up to a particular NIC to register itself
with lwIP using the standard lwIP netif API.
2018-05-21 17:36:06 +10:00
Damien George
8a949ba599 stm32: Introduce MICROPY_PY_STM config to include or not the stm module.
By default the stm module is included in the build, but a board can now
define MICROPY_PY_STM to 0 to not include this module.  This reduces the
firmware by about 7k.
2018-04-24 12:01:49 +10:00
Damien George
58ebeca6a9 drivers/bus: Pull out software SPI implementation to dedicated driver.
This patch takes the software SPI implementation from extmod/machine_spi.c
and moves it to a dedicated file in drivers/bus/softspi.c.  This allows the
SPI driver to be used independently of the uPy runtime, making it a more
general component.
2018-03-10 00:59:43 +11:00
Damien George
989fc16162 stm32: Move MCU-specific cfg from mphalport.h to mpconfigboard_common.h.
It's cleaner to have all the MCU-specific configuration in one location,
not least to help with adding support for a new MCU series.
2018-02-23 16:54:07 +11:00
Damien George
82828340a0 ports: Enable ucollections.deque on relevant ports.
These ports are all capable of running uasyncio.
2018-02-21 22:55:13 +11:00
Damien George
2d5bab46be stm32: Add mpconfigboard_common.h with common/default board settings.
This file mirrors py/mpconfig.h but for board-level config options.  It
provides a default configuration, to be overridden by a specific
mpconfigboard.h file, as well as setting up certain macros to automatically
configure a board.
2018-02-09 18:40:13 +11:00
Damien George
c73360bfdb stm32: Allow to build a board without any hardware I2C ports defined.
This patch adds in internal config value MICROPY_HW_ENABLE_HW_I2C that is
automatically configured, and enabled only if one or more hardware I2C
ports are defined in the mpconfigboard.h file.  If none are defined then
the pyb.I2C class is excluded from the build, along with all supporting
code.  The machine.I2C class will still be available for software I2C.

Disabling all hardware I2C on an F4 board saves around 10,000 bytes of code
and 200 bytes of RAM.
2017-12-22 15:20:42 +11:00
Damien George
d6bf3658f4 stm32: Make uos.dupterm() conform to specs by using extmod version.
The legacy function pyb.repl_uart() is still provided and retains its
original behaviour (it only accepts a UART object).  uos.dupterm() will now
accept any object with write/readinto methods.  At the moment there is just
1 dupterm slot.
2017-10-19 14:16:42 +11:00
Li Weiwei
5c437963d7 stm32/mpconfigport.h: Add MICROPY_THREAD_YIELD() macro. 2017-10-16 13:32:26 +11:00
Damien George
81a06d2c9c lib/libm: Remove implementation of log2f, use MP_NEED_LOG2 instead. 2017-10-10 16:01:13 +11:00
Damien George
aca498c2b0 stm32/mpconfigport.h: Add configuration for max periphs on L4 series. 2017-09-13 17:03:57 +10:00
Damien George
d7cd1d2027 stm32/timer: Make pyb.Timer() instances persistent.
Prior to this patch calling pyb.Timer(id) would always create a new timer
instance, even if there was an existing one.  This patch fixes this
behaviour to match other peripherals, like UART, such that constructing a
timer with just the id will retrieve any existing instances.

The patch also refactors the way timers are validated on construction to
simplify and reduce code size.
2017-09-13 16:20:42 +10:00
Damien George
4a93801c12 all: Update Makefiles and others to build with new ports/ dir layout.
Also renames "stmhal" to "stm32" in documentation and everywhere else.
2017-09-06 14:09:13 +10:00
Damien George
01dd7804b8 ports: Make new ports/ sub-directory and move all ports there.
This is to keep the top-level directory clean, to make it clear what is
core and what is a port, and to allow the repository to grow with new ports
in a sustainable way.
2017-09-06 13:40:51 +10:00