Commit Graph

197 Commits

Author SHA1 Message Date
Josh Lloyd
1530fda9cf esp32/machine_rtc: Reduce memory footprint of user mem functionality. 2019-11-21 16:55:12 +11:00
Josh Lloyd
ed2314f35a esp32/machine_rtc: Make RTC.memory size and availability configurable.
The compile-time configuration value MICROPY_HW_RTC_USER_MEM_MAX can now be
used to define the amount of memory set aside for RTC.memory().  If this
value is configured to zero then the RTC.memory functionality is not
included in the build.
2019-11-21 16:55:12 +11:00
Josh Lloyd
82d358510b esp32/rtc: Set system microseconds when setting time via RTC.datetime(). 2019-11-13 13:46:33 +11:00
Jim Mussared
71299d3224 esp32/boards/sdkconfig.base: Resize SSL output buffer from 16 to 4kiB.
The IDF heap is more fragmented with IDF 4 and mbedtls cannot allocate
enough RAM with 16+16kiB for both in and out buffers, so reduce output
buffer size.

Fixes issue #5303.
2019-11-11 11:55:58 +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
4be316fb07 esp32/moduos: Enable uos.VfsLfs2 for littlefs filesystems.
This commit adds support for littlefs (v2) on all esp32 boards.

The original FAT filesystem still works and any board with a preexisting
FAT filesystem will still work as normal.  It's possible to switch to
littlefs by reformatting the block device using:

    import uos, flashbdev
    uos.VfsLfs2.mkfs(flashbdev.bdev)

Then when the board reboots (soft or hard) the new littlefs filesystem will
be mounted.  It's possible to switch back to a FAT filesystem by formatting
with uos.VfsFat.mkfs(flashbdev.bdev).
2019-11-06 12:16:00 +11:00
Damien George
d01ca7888b esp32/esp32_partition: Support extended block protocol. 2019-11-06 12:15:34 +11:00
Andreas Motl
d209f9ebe7 esp32: Remove unused "esponewire.c" in favour of extmod/modonewire. 2019-11-05 14:57:05 +11:00
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
742030945c esp32/Makefile: Add correct arch to MPY_CROSS_FLAGS for native code. 2019-11-04 15:32:20 +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
Mike Teachman
f301170c7c esp32/machine_hw_spi: Fix exception msg when host is already in use.
When a SPI bus is initialized with a SPI host that is currently in use the
exception msg incorrectly indicates "SPI device already in use".  The
mention of "device" in the exception msg is confusing because the error is
about trying to use a SPI host that is already claimed.  A better exception
msg is "SPI host already in use".
2019-10-23 13:31:13 +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
912892b209 esp32: Add missing and necessary newline at EOF for sdkconfig.240mhz.
When these files get concatenated the newline-at-EOF is necessary so that
the start of the next file doesn't join with the end of the previous.
2019-10-21 23:54:59 +11:00
Jim Mussared
8ba963cfa3 tools/makemanifest.py: Eval relative paths w.r.t. current manifest file.
When loading a manifest file, e.g. by include(), it will chdir first to the
directory of that manifest.  This means that all file operations within a
manifest are relative to that manifest's location.

As a consequence of this, additional environment variables are needed to
find absolute paths, so the following are added: $(MPY_LIB_DIR),
$(PORT_DIR), $(BOARD_DIR).  And rename $(MPY) to $(MPY_DIR) to be
consistent.

Existing manifests are updated to match.
2019-10-21 23:01:41 +11:00
Josh Lloyd
59c1b7d4b8 esp32/boards: Split out CPU frequency config, make 160MHz the default.
Remove the 240MHz CPU config option from sdkconfig.base and create a new
sdkconfig.240mhz file for those boards that want to use 240MHz on boot.

The default CPU frequency is now 160MHz (was 240MHz), to align with the ESP
IDF and support more boards (eg those with D2WD chips).

Fixes issue #5169.
2019-10-18 13:42:24 +11:00
Jeremy Herbert
7a7ee16ccf esp32/machine_uart: Add ability to invert UART pins. 2019-10-18 12:05:16 +11:00
Damien George
ce1de1faf0 esp32: Convert to use FROZEN_MANIFEST to specify frozen code.
All symlinks are removed.  boards/manifest.py is used as a default, and can
optionally use boards/manifest_release.py for more scripts.
2019-10-15 21:37:02 +11:00
Jim Mussared
4b2b05718a esp32: Run NimBLE on the app core.
This prevents issues with concurrent access to the ringbuf.
MICROPY_BEGIN_ATOMIC_SECTION is only atomic to the same core.  We could
address this with a mutex, but it's also not safe to call mp_sched_schedule
across cores.
2019-10-15 17:22:15 +11:00
Jim Mussared
418f12c5f5 extmod/modbluetooth: Increase maximum connections from 1 to 4.
This avoids a confusing ENOMEM raised from gap_advertise if there is
currently an active connection.  This refers to the static connection
buffer pre-allocated by Nimble (nothing to do with MicroPython heap
memory).
2019-10-15 17:20:25 +11:00
Damien George
d7a9388fe0 ports: Add new make target "submodules" which inits required modules. 2019-10-15 17:14:41 +11:00
Jim Mussared
d5cbee3cfb esp32: Add 4.x version of IDLE WDT config. 2019-10-11 14:30:47 +11:00
Jim Mussared
cd8bbf4cfc esp32/boards: Enable BLE by default when building with IDF 4.x. 2019-10-08 14:50:01 +11:00
Jim Mussared
6a9bd1c1ab esp32: Implement BLE using Nimble from IDF 4.x. 2019-10-08 14:50:01 +11:00
Damien George
917f027c0b esp32: Enable native emitter. 2019-10-05 13:45:25 +10:00
Jim Mussared
c33a4cc213 esp32/Makefile: Fix printing of supported git hash. 2019-09-20 14:37:53 +10:00
Jim Mussared
62d78e231c esp32/main: Use both 3.3 and 4.0 config vars to enable SPIRAM. 2019-09-18 15:49:45 +10:00
Jim Mussared
f469634c0c esp32: Add check to Makefile that the toolchain is in PATH. 2019-09-17 12:26:47 +10:00
Jim Mussared
970f798ea9 esp32: Add check to Makefile for pyparsing version. 2019-09-17 12:26:42 +10:00
Jim Mussared
96008ff59a esp32: Support building with ESP IDF 4.0-beta1.
This commit adds support for a second supported hash (currently set to the
4.0-beta1 tag).  When this hash is detected, the relevant changes are
applied.

This allows to start using v4 features (e.g. BLE with Nimble), and also
start doing testing, while still supporting the original, stable, v3.3 IDF.

Note: this feature is experimental, not well tested, and network.LAN and
network.PPP are currently unsupported.
2019-09-17 12:25:36 +10:00
Damien George
356a728bd0 esp32/Makefile: Add SDKCONFIG_H to QSTR_GLOBAL_REQUIREMENTS.
Fixes issue #5091.
2019-09-12 18:16:16 +10:00
Damien George
bd1d27f00f esp32/modules/inisetup.py: Use bdev.ioctl instead of bdev.SEC_SIZE.
Since the bdev is now a Partition it doesn't have SEC_SIZE.
2019-09-10 22:41:50 +10:00
Alex Albino
80d37d936c esp32: Add support for ESP32-D2WD with 2MiB internal flash.
This patch adds a partitions file for the D2WD and a new board GENERIC_D2WD
which runs on these chip variants.

Resolves issue #4986.
2019-09-10 15:22:16 +10:00
Damien George
31de44775c esp32: Add VFS FAT partition to partitions.csv and mount it as the FS.
This patch uses the newly-added esp32.Partition class to replace the
existing FlashBdev class.  Partition objects implement the block protocol
so can be directly mounted via uos.mount().  This has the following
benefits:

- allows the filesystem partition location and size to be specified in
  partitions.csv, and overridden by a particular board
- very easily allows to have multiple filesystems by simply adding extra
  entries to partitions.csv
- improves efficiency/speed of filesystem operations because the block
  device is implemented fully in C
- opens the possibility to have encrypted flash storage (since Partitions
  can be encrypted)

Note that this patch is fully backwards compatible: existing filesystems
remain untouched and work with this new code.
2019-09-10 15:14:13 +10:00
Damien George
e9af6f5f88 esp32/boards/TINYPICO: Switch to use QIO and 80MHz for SPI interface. 2019-09-10 11:10:19 +10:00
Braden Mars
5641aa55dd esp32: Update to use ESP IDF v3.3
Includes patches for CVE-2019-12586 & CVE-2019-12587
2019-09-07 01:28:11 -05:00
Damien George
983283a8cd esp32/machine_adc: Add ADC.read_u16() method. 2019-09-05 22:13:04 +10:00
Jim Mussared
50482cdc0c esp32/Makefile: Fix subst->patsubst in ESPIDF_BOOTLOADER_SUPPORT_O. 2019-09-03 23:21:50 +10:00
Eric Poulsen
5635b96461 esp32: Add 'config' function to network.LAN, reusing network.WLAN. 2019-08-28 13:11:48 +10:00
Damien George
05eb897d06 esp32: Add esp32.Partition class to expose partition and OTA funcs.
Partitions are exposed as a standard MicroPython block device.
2019-08-20 16:49:18 +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
Jim Mussared
8db517f26d esp32: Add per-board configs, following other ports.
Replaces the `SDKCONFIG` makefile variable with `BOARD`.  Defaults to
BOARD=GENERIC.  spiram can be enabled with `BOARD=GENERIC_SPIRAM`

Add example definition for TINYPICO, currently identical to GENERIC_SPIRAM
but with custom board/SoC names for the uPy banner.
2019-08-16 00:22:29 +10:00
Damien George
baeebc557c esp32/modules: On initial setup mount internal flash at root.
Like it's done on normal boot up.  Fixes issue #5004.
2019-08-15 22:03:09 +10:00
Damien George
2ccf030fd1 esp32: Add support for mDNS queries and responder.
They are both enabled by default, but can be disabled by defining
MICROPY_HW_ENABLE_MDNS_QUERIES and/or MICROPY_HW_ENABLE_MDNS_RESPONDER to
0.  The hostname for the responder is currently taken from
tcpip_adapter_get_hostname() but should eventually be configurable.
2019-08-15 16:36:47 +10:00
Kenta IDA
b6906fa573 esp32/network_ppp: Add authentication support to the PPP interface.
This commit adds the connect() method to the PPP interface and requires
that connect() be called after active(1).  This is a breaking change for
the PPP API.

With the connect() method it's now possible to pass in authentication
information for PAP/CHAP, eg:

    ppp.active(1)
    ppp.connect(authmode=ppp.AUTH_PAP, username="user", "password="password")

If no authentication is needed simply call connect() without any
parameters.  This will get the original behaviour of calling active(1).
2019-08-14 17:20:58 +10:00
Damien George
7c15e50eb8 esp32/Makefile: Include CFLAGS_EXTRA in CFLAGS definition.
Following other ports, so builds can be customised more easily, eg on the
command line building with a user C-module.
2019-07-30 17:31:23 +10:00
Amir Gonnen
995f9cfdfc esp32: Pin MicroPython tasks to a specific core.
On this port the GIL is enabled and everything works under the assumption
of the GIL, ie that a given task has exclusive access to the uPy state, and
any ISRs interrupt the current task and therefore the ISR inherits
exclusive access to the uPy state for the duration of its execution.

If the MicroPython tasks are not pinned to a specific core then an ISR may
be executed on a different core to the task, making it possible for the
main task and an ISR to execute in parallel, breaking the assumption of the
GIL.

The easiest and safest fix for this is to pin all MicroPython related code
to the same CPU core, as done by this patch.  Then any ISR that accesses
MicroPython state must be registered from a MicroPython task, to ensure it
is invoked on the same core.

See issue #4895.
2019-07-25 15:33:47 +10:00
Damien George
e3e7e3a781 esp32/Makefile: Simplify include of IDF source by using wildcards. 2019-07-20 14:07:18 +10:00
Damien George
b88e51d718 esp32/Makefile: Put OBJ and LIB rule additions in gen_espidf_lib_rule. 2019-07-20 13:04:55 +10:00