Commit Graph

114 Commits

Author SHA1 Message Date
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
Damien George
90f86a0197 esp32/machine_pin: Add Pin.off() and Pin.on() methods. 2019-01-16 17:33:56 +11:00
Damien George
f350b640a0 esp32/modsocket: For socket read only release GIL if socket would block.
If there are many short reads to a socket in a row (eg by readline) then
releasing and acquiring the GIL each time will give very poor throughput.
So first poll the socket to see if it has data, and if it does then don't
release the GIL.
2019-01-10 15:46:44 +11:00
Damien George
efe0569c26 esp32/mphalport: When tx'ing to REPL only release GIL if many chars sent
Otherwise, if multiple threads are active, printing data to the REPL may be
very slow because in some cases only one character is output per call to
mp_hal_stdout_tx_strn.
2019-01-10 15:43:47 +11:00
Damien George
da7355e213 esp32/modmachine: Enable machine.sleep() now that the IDF supports it. 2018-12-06 17:23:27 +11:00
Damien George
9c6c32cc51 esp32/machine_pwm: On deinit stop routing PWM signal to the pin.
Fixes issue #4273.
2018-12-06 17:05:16 +11:00
Damien George
287b02d98a esp32/machine_pwm: Support higher PWM freq by auto-scaling timer res. 2018-12-06 16:43:39 +11:00
Damien George
87623082e3 esp32/machine_uart: Implement UART.sendbreak() method.
The uart_write_bytes_with_break() function requires non-zero data to be
sent before the break, so a standalone break must be synthesised.
2018-12-06 15:40:22 +11:00
Damien George
9ddc182ec7 esp32/machine_uart: Add txbuf/rxbuf keyword args to UART construct/init.
As per the machine.UART documentation, these are used to set the length of
the TX and RX buffers.
2018-12-05 16:48:34 +11:00
Damien George
485514f57a esp32: Allocate task TCB and stack from system heap not uPy heap.
This is necessary for two reasons: 1) FreeRTOS still needs the TCB data
structure even after vPortCleanUpTCB has been called, so this latter hook
function cannot free the TCB, and there is no where else to safely delete
it (this behaviour has changed recently in the ESP IDF); 2) when using
external SPI RAM the uPy heap is in this external memory but the task stack
must be allocated from internal SRAM.

Fixes issue #3904.
2018-11-28 15:00:45 +11:00
Damien George
0233049b79 esp32/mpthreadport: Prevent deadlocks when deleting all threads.
vTaskDelete now immediately calls vPortCleanUpTCB, which requires the
thread_mutex mutex, so vTaskDelete must be called after this mutex is
released.
2018-11-28 14:30:11 +11:00
Eric Poulsen
3c6f639aa5 esp32/network_ppp: Add PPPoS functionality.
This commit adds network.PPP(stream) which allows to create a TCP/IP
network interface over a stream object (eg a UART).
2018-10-19 23:32:02 +11:00
Eric Poulsen
5e5aef53fb esp32/modesp32: Add hall_sensor() function. 2018-10-19 17:28:02 +11:00
Damien George
185716514f esp32/machine_rtc: Fix locals dict entry, init qstr points to init meth. 2018-09-20 17:52:16 +10:00
Siarhei Farbotka
e62f59217b esp32: Fix int overflow in machine.sleep/deepsleep functions. 2018-09-14 13:25:45 +10:00
Damien George
48d736f491 esp32: Update to latest ESP IDF.
Among other things, this requires putting bootloader object files in to
their relevant .a archive, so that they can be correctly referenced by the
ESP IDF's linker script.
2018-08-14 16:45:37 +10:00
Eric Poulsen
419eb86074 esp32/modnetwork: Add network.(W)LAN.ifconfig('dhcp') support. 2018-07-18 11:02:11 +10:00
Nicko van Someren
c3c914f4dd esp8266,esp32: Implement high-res timers using new tick_hz argument.
machine.Timer now takes a new argument in its constructor (or init method):
tick_hz which specified the units for the period argument.  The period of
the timer in seconds is: period/tick_hz.

For backwards compatibility tick_hz defaults to 1000.  If the user wants to
specify the period (numerator) in microseconds then tick_hz can be set to
1000000.  The user can also specify a period of an arbitrary number of
cycles of an arbitrary frequency using these two arguments.

An additional freq argument has been added to allow frequencies to be
specified directly in Hertz.  This supports floating point values when
available.
2018-07-17 13:17:23 +10:00
Damien George
a3ba5f127e esp32/modesp32: Use MP_ROM_QSTR and MP_ROM_PTR in const locals dict. 2018-07-16 00:02:35 +10:00
Jérôme Poulin
4f5b435d9b esp32/modesp32: Add raw temperature reading to esp32 module.
Using direct register control as specified by ESP-IDF in
components/esp32/test/test_tsens.c.  Temperature doesn't represent any
particular unit, isn't calibrated and will vary from device to device.
2018-07-16 00:02:26 +10:00
Mitchell Currie
385fa51806 esp32: Implement WLAN.status() return codes.
Resolves #3913: missing esp32 status() implementation.
2018-07-14 16:26:43 +10:00
Damien George
9c8141f07e esp32/modnetwork: Add support for bssid parameter in WLAN.connect(). 2018-07-09 14:01:52 +10:00
Nicko van Someren
14ab81e87a esp32: Reduce latency for handling of scheduled Python callbacks.
Prior to this patch there was a large latency for executing scheduled
callbacks when when Python code is sleeping: at the heart of the
implementation of sleep_ms() is a call to vTaskDelay(1), which always
sleeps for one 100Hz tick, before performing another call to
MICROPY_EVENT_POLL_HOOK.

This patch fixes this issue by using FreeRTOS Task Notifications to signal
the main thread that a new callback is pending.
2018-07-04 10:49:37 +10:00
Damien George
349d8e1324 esp32: Allow to build with uPy floats disabled. 2018-07-03 12:10:03 +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
82bc4838d2 esp32/mpconfigport.h: Enable ucryptolib module. 2018-06-27 16:44:59 +10:00
Damien George
34b2f6b6fc esp32/modules: Include umqtt library in frozen modules. 2018-06-15 16:39:49 +10:00
Damien George
d61d119c94 esp32: Update to latest ESP IDF. 2018-06-15 16:23:53 +10:00
Damien George
cf1509c911 esp32/fatfs_port: Implement get_fattime so FAT files have a timestamp.
Fixes issue #3859.
2018-06-13 14:13:34 +10:00
Damien George
0501427907 esp32: Remove port-specific uhashlib implementation and use common one.
Now that the common module has mbedtls support for both SHA1 and SHA256 it
can now be used on this port.
2018-06-12 13:50:11 +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
b2fa1b50ed ports: Call gc_sweep_all() when doing a soft reset.
This calls finalisers of things like files and sockets to cleanly close
them.
2018-06-12 11:56:25 +10:00