Commit Graph

145 Commits

Author SHA1 Message Date
Eric Poulsen
fa5c0b819c esp32/network_ppp: Add ppp_set_usepeerdns(pcb, 1) when init'ing iface.
Without this you often don't get any DNS server from your network provider.
Additionally, setting your own DNS _does not work_ without this option set
(which could be a bug in the PPP stack).
2019-07-04 11:17:41 +10:00
Damien George
c80614dfc8 ports: Provide mp_hal_stdio_poll for sys.stdio polling where needed. 2019-07-01 17:10:12 +10:00
Josh Lloyd
2f262d5f9a esp32/Makefile: Include all driver/*.c source files in the build.
Fixes #4869.
2019-06-25 15:12:34 +10:00
Damien George
b80bccccff esp32/modnetwork: Still try to reconnect to WLAN even with AUTH_FAIL.
WIFI_REASON_AUTH_FAIL does not necessarily mean the password is wrong, and
a wrong password may not lead to a WIFI_REASON_AUTH_FAIL error code.  So to
improve reliability connecting to a WLAN always reconnect regardless of the
error.
2019-06-22 21:50:49 +10:00
Damien George
3ee3995be1 esp32: Update to use ESP IDF v3.3-beta3.
This updates ESP IDF to use v3.3-beta3.  And also adjusts README.md to
point to stable docs which provide a link to download the correct toolchain
for this IDF version, namely 1.22.0-80-g6c4433a-5.2.0
2019-06-19 14:32:15 +10:00
Nicko van Someren
1a51fc9ddf esp32/machine_sdcard: Fix bug in SPI slot number selection.
And fix minor typo in docs when referring to SDCard class.
2019-06-17 12:36:22 +10:00
Nicko van Someren
8e3af7d4c8 esp32: Add machine.SDCard class using built-in HW SD/MMC controller.
This adds support for SD cards using the ESP32's built-in hardware SD/MMC
host controller, over either the SDIO bus or SPI.  The class is available
as machine.SDCard and using it can be as simple as:

    uos.mount(machine.SDCard(), '/sd')
2019-06-03 00:37:41 +10:00
Martin Dybdal
de76f73d34 esp32/machine_timer: Reuse Timer handles, deallocate only on soft-reset.
The patch solves the problem where multiple Timer objects (e.g. multiple
Timer(0) instances) could initialise multiple handles to the same internal
timer.  The list of timers is now maintained not for "active" timers (where
init is called), but for all timers created.  The timers are only removed
from the list of timers on soft-reset (machine_timer_deinit_all).

Fixes #4078.
2019-05-31 14:55:07 +10:00
Damien George
883e987b90 esp32/modsocket: Raise EAGAIN when accept fails in non-blocking mode.
EAGAIN should be for pure non-blocking mode and ETIMEDOUT for when there is
a finite (but non-zero) timeout enabled.
2019-05-28 17:43:00 +10:00
Tom Manning
887a6712c2 esp32/machine_touchpad: Use HW timer for FSM to enable wake-on-touch. 2019-05-28 11:14:34 +10:00
Damien George
0557f0b74b esp32/network_ppp: Add a timeout for closing PPP connection.
This also fixes deleting the PPP task, since eTaskGetState() never returns
eDeleted.

A limitation with this patch: once the PPP is deactivated (ppp.active(0))
it cannot be used again. A new PPP instance must be created instead.
2019-05-17 17:14:45 +10:00
Damien George
2630d3e51f esp32/machine_uart: Implement UART.deinit() method. 2019-05-15 17:01:54 +10:00
Damien George
8586afa6f5 esp32/modnetwork: Change type to size_t for uses of mp_obj_str_get_data. 2019-05-13 12:39:03 +10:00
Krono
fbd4e61e57 esp32/machine_wdt: Add timeout arg to select interval, make WDT panic.
The machine.WDT() now accepts the "timeout" keyword argument to select the
WDT interval.  And the WDT is changed to panic mode which means it will
reset the device if the interval expires (instead of just printing an error
message).
2019-04-30 16:53:05 +10:00
Damien George
0646e607b5 ports: Convert to use pyexec_file_if_exists() to execute boot/main.py.
The stm32 and nrf ports already had the behaviour that they would first
check if the script exists before executing it, and this patch makes all
other ports work the same way.  This helps when developing apps because
it's hard to tell (when unconditionally trying to execute the scripts) if
the resulting OSError at boot up comes from missing boot.py or main.py, or
from some other error.  And it's not really an error if these scripts don't
exist.
2019-04-26 15:22:14 +10:00
Damien George
4ce0091449 esp32/README: Add info about pyparsing and the correct Python version.
See issue #4655.
2019-04-18 14:17:01 +10:00
Damien George
69cb24a21d esp32/boards/sdkconfig: Disable WDT check of idle task on CPU1.
With dual-core enabled it's possible that the uPy task has full utilisation
of CPU1.  Fixes issue #4673.
2019-04-05 12:25:21 +11:00
Damien George
92149c8a79 esp32/boards: Enable dual core support by default.
Single core is still supported, just by adding CONFIG_FREERTOS_UNICORE=y to
a custom sdkconfig file.
2019-03-27 11:20:21 +11:00
Damien George
815b79a8d0 esp32/mpthreadport: Exit vPortCleanUpTCB early if threading not init'd. 2019-03-27 11:11:06 +11:00
Damien George
673db939b5 esp32/machine_pin: Rework pull mode config to fix GPIO hold feature.
For gpio_hold_en() to work properly (not draw additional current) pull
up/down must be disabled when hold is enabled.  This patch makes sure this
is the case by reworking the pull constants to be a bit mask.
2019-03-26 15:21:23 +11:00
Damien George
ddc934631c esp32/machine_pin: Add new PULL_HOLD pin pull mode. 2019-03-14 07:28:57 +11:00
Damien George
349b54525e esp32/machine_pin: Make it so None as pull value disables pull up/down.
Previously specifying None as the pull value would leave the pull up/down
state unchanged.  This change makes it so -1 leaves the state unchanged and
None makes the pin float, as per the docs.
2019-03-14 07:26:59 +11:00
Damien George
297092a76a esp32/mphalport: Use ets_delay_us for mp_hal_delay_us_fast.
The system provided one is in ROM and is more accurate.
2019-03-12 15:46:44 +11:00
Damien George
fcace26d87 esp32/Makefile: Add some missing IDF source files to bootloader and app.
Functions in these files may be needed when certain features are enabled
(eg dual core mode), even if the linker does not give a warning or error
about unresolved symbols.
2019-03-11 23:17:09 +11:00
Petr Kracík
41e7ad647e esp32/modnetwork: Remove redundant esp_log include. 2019-03-08 23:36:07 +11:00
Petr Kracík
73c48b1b45 esp32/modnetwork: Implement RSSI for WiFi STA via WLAN.status('rssi'). 2019-03-08 23:35:28 +11:00
Damien George
b5f33ac2cb ports: Update to work with new oofatfs version. 2019-03-05 15:56:39 +11:00
Petr Kracík
21f9329d5d esp32/modnetwork: Fix wifi.isconnected to return False after disconnect.
esp_wifi_connect will return ESP_OK for the normal path of execution which
just means the reconnect is started, not that it is actually reconnected.
In such a case wifi.isconnected() should return False until the
reconnection is complete.  After reconnect a GOT_IP event is called and it
will change wifi_sta_connected back to True.
2019-02-26 00:49:40 +11:00
Petr Kracík
5801a003f0 esp32/network_lan: Make power arg to constructor optional.
A value of None for this argument is already supported, so the argument can
be made optional.
2019-02-21 23:29:10 +11:00
Petr Kracík
01c1432e32 esp32/modnetwork: Catch and report Ethernet events. 2019-02-21 23:28:51 +11:00
Petr Kracík
7d8c71c222 esp32/network_lan: Add arg to constructor to set clock mode for ETH PHY.
This optional parameter for network.LAN clock_mode can be used for cases
where the clock source is different from the default GPIO0.  Fixes #4502.
2019-02-21 23:28:17 +11:00
Damien George
303f27f656 esp32/modsocket: Change socket.socket to be socket type rather than fun.
To make all ports consistent.  Addresses issue #4514.
2019-02-18 23:20:13 +11:00
Damien George
ed09e13943 esp32/modsocket: Fix usocket.send to accept anything with buffer proto. 2019-02-18 12:38:38 +11:00
Yonatan Goldschmidt
bc4f8b438b extmod/moduwebsocket: Refactor websocket to uwebsocket.
As mentioned in #4450, `websocket` was experimental with a single intended
user, `webrepl`. Therefore, we'll make this change without a weak
link `websocket` -> `uwebsocket`.
2019-02-14 00:35:45 +11:00
Mike Causer
812969d615 all: Change PYB message prefix to MPY.
Replaces "PYB: soft reboot" with "MPY: soft reboot", etc.

Having a consistent prefix across ports reduces the difference between
ports, which is a general goal.  And this change won't break pyboard.py
because that tool only looks for "soft reboot".
2019-02-12 15:18:33 +11:00
Damien George
6e30f96b0b ports: Convert legacy uppercase macro names to lowercase. 2019-02-12 14:54:51 +11:00
Damien George
c33f538066 esp32/modmachine: Add support for changing the CPU frequency. 2019-02-07 22:51:55 +11:00
Damien George
6a95e74387 esp32: Use SPIRAM in mem-map mode so all of it can be used for uPy heap.
Also enable CONFIG_SPIRAM_IGNORE_NOTFOUND to allow boards with faulty or
missing SPIRAM to still boot.
2019-02-06 00:10:50 +11:00
Damien George
8de17b3d96 esp32/modmachine: Rename machine.sleep to machine.lightsleep.
While keeping machine.sleep as an alias for machine.lightsleep for
backwards compatibility.
2019-01-30 13:00:26 +11:00
Damien George
dadee5fa24 esp32/modsocket: Fix crashes when connect/bind can't resolve given addr.
Fixes issue #4441.
2019-01-30 12:40:50 +11:00
Damien George
f431795caf esp32/boards: Use auto xtal freq config instead of default 40MHz.
Auto-detection of the crystal frequency is convenient and allows for a
single binary for many different boards.  But it can be unreliable in
certain situations so in production, for a given board, it's recommended to
configure the correct fixed frequency.
2019-01-28 20:42:12 +11:00
Damien George
5d88272342 esp32/Makefile: Make sure that directory exists for sdkconfig.h. 2019-01-28 20:41:13 +11:00
Damien George
9ac9aa989c esp32/machine_timer: Deinit all active timers on soft reset.
Otherwise they will keep triggering the callback and access invalid data on
the heap.
2019-01-28 16:16:03 +11:00
Damien George
3d49b157b8 esp32: Update to latest ESP IDF using sdkconfig and new ldgen procedure.
Configuration for the build is now specified using sdkconfig rather than
sdkconfig.h, which allows for much easier configuration with defaults from
the ESP IDF automatically applied.  sdkconfig.h is generated using the new
ESP IDF kconfig_new tool written in Python.  Custom configuration for a
particular ESP32 board can be specified via the make variable SDKCONFIG.

The esp32.common.ld file is also now generated using the standard ESP IDF
ldgen.py tool.
2019-01-28 12:44:03 +11:00
Damien George
f59904f799 esp32/Makefile: Put all IDF compenents in .a libs to use IDF ld script.
When the ESP IDF builds a project it puts all separate components into
separate .a library archives.  And then the esp32.common.ld linker script
references these .a libraries by explicit name to put certain object files
in iRAM.

This patch does a similar thing for the custom build system used here,
putting all IDF .o's into their respective .a.  So a custom linker script
is no longer needed.
2019-01-28 12:41:37 +11:00
Damien George
e7ab475276 esp32: Don't put py/scheduler.o in iRAM, it's no longer needed.
ISR's no longer need to be in iRAM, and the ESP IDF provides an option to
specify that they are in iRAM if an application needs lower latency when
handling them.  But we don't use this feature for user interrupts: both
timer and gpio ISR routines are registered without the ESP_INTR_FLAG_IRAM
option, and so the scheduling code no longer needs to be in iRAM.
2019-01-27 16:15:47 +11:00
Damien George
da72bb6833 esp32/machine_hw_spi: Make HW SPI objects statically allocated.
This aligns more closely with the hardware, that there are two, fixed HW
SPI peripherals.  And it allows to recreate the HW SPI objects without
error, as well as create them again after a soft reset.

Fixes issue #4103.
2019-01-23 23:47:36 +11:00
Damien George
d82f344f61 esp32/machine_hw_spi: Use separate DMA channels for HSPI and VSPI.
Otherwise only one of HSPI or VSPI can be used at a time.  Fixes
issue #4068.
2019-01-23 23:40:06 +11:00
Matt Trentini
cd52d2c691 esp32/modules/neopixel.py: Change NeoPixel to different default timings.
In order to suit the more common 800KHz by default (instead of 400KHz), and
also have the same behaviour as the esp8266 port.

Resolves #4396.

Note! This is a breaking change. Anyone that has previously used the
NeoPixel class on an ESP32 board may be affected.
2019-01-23 14:22:38 +11:00
Damien George
eb446ec227 esp32/Makefile: Use system provided math library rather than uPy one.
The ESP IDF system already provides a math library, and that one is likely
to be better tuned to the Xtensa architecture.  The IDF components are also
tested against its own math library, so best not to override it.  Using the
system provided library also allows to easily switch to double-precision
floating point by changing MICROPY_FLOAT_IMPL to MICROPY_FLOAT_IMPL_DOUBLE.
2019-01-17 16:43:20 +11:00