Wykres commitów

415 Commity (49d8ae3ecc8833123609822567cbed239bbc36f2)

Autor SHA1 Wiadomość Data
MikeTeachman 49d8ae3ecc esp32/machine_i2s: Add support for ESP-IDF 4.4.
- Add default values for I2S features added in ESP-IDF 4.4.
- Add workaround for bug introduced in ESP-IDF 4.4
  (https://github.com/espressif/esp-idf/issues/8121).
2022-01-06 13:10:38 +11:00
Jim Mussared 599b61c086 esp32/machine_bitstream: Replace bit-bang code with RMT-based driver.
This aims to solve glitching issues on long neopixel strips.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-12-22 12:04:13 +11:00
IhorNehrutsa 09fe80d091 esp32/machine_pwm: Keep duty constant when changing frequency.
Save and restore the same duty cycle when the frequency (or frequency
resolution) is changed.  This allows a smooth frequency change.

Also update the esp32 PWM quickref to be clearer.
2021-12-22 00:05:58 +11:00
IhorNehrutsa 4189c64869 esp32/modnetwork: Synchronize WiFi AUTH_xxx constants with IDF values. 2021-12-21 23:56:23 +11:00
Damien George de43b500bd py/runtime: Allow initialising sys.path/argv with defaults.
If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is enabled (which it is by default)
then sys.path and sys.argv will be initialised and populated with default
values.  This keeps all bare-metal ports aligned.

Signed-off-by: Damien George <damien@micropython.org>
2021-12-18 00:08:07 +11:00
Jim Mussared 86ce442607 ports: Add '.frozen' as the first entry in sys.path.
Frozen modules will be searched preferentially, but gives the user the
ability to override this behavior.

This matches the previous behavior where "" was implicitly the frozen
search path, but the frozen list was checked before the filesystem.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-12-18 00:08:07 +11:00
Tomas Vanek 9aa151e3f3 esp32/boards: Remove SPI pin defaults from GENERIC S2/S3 boards.
Default SPI pins are now correctly assigned by machine_hw_spi.c even for S2
and S3.  mpconfigboard.h files define defaults with flipped SPI(1) and
SPI(2) to workaround a bug in machine_hw_spi.c - the bug is fixed.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
2021-12-15 15:53:17 +11:00
Tomas Vanek e761152d72 esp32/machine_hw_spi: Set proper default SPI(id=2) pins on S2 and S3.
Use IO_MUX pins as defined by ESP IDF in soc/esp32/include/soc/spi_pins.h

ESP32S2 and S3 don't have IO_MUX pins for SPI3, GPIO matrix is always used.
Choose suitable defaults for S2 and S3.

ESP32C3 does not have SPI3 at all.  Don't define pin mappings for it.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
2021-12-15 15:53:17 +11:00
Tomas Vanek d08886558b esp32/machine_hw_spi: Set proper default SPI(id=1) pins on S2,S3 and C3.
Use IO_MUX pins as defined by ESP IDF in soc/esp32*/include/soc/spi_pins.h
Alternatively use now deprecated HSPI_IOMUX_PIN_NUM_xxx
(or FSPI_IOMUX_PIN_NUM_xxx for ESP32S2) for compatibility with IDF 4.2
and older.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
2021-12-15 15:50:27 +11:00
Tomas Vanek 3305ec44a2 esp32/machine_hw_spi: Fix SPI default pins reordering on ESP32-S2/S3.
The index of machine_hw_spi_obj and machine_hw_spi_default_pins arrays is
assigned to 0 for ARG_id==HSPI_HOST and 1 for another SPI.  On ESP32S2 and
S3 HSPI_HOST=2 so the first set (idx=0) of default pins is used for
SPI(id=2) aka HSPI/SPI3 and the second set (idx=1) for SPI(id=1) aka
FSPI/SPI2.  This makes a misleading mess in MICROPY_HW_SPIxxxx definitions
and it is also in contradiction to the comments around the definitions.

Change the test of ARG_id to fix the order of machine_hw_spi_default_pins.

This change might require adjusting MICROPY_HW_SPIxxxx definitions in
mpconfigboard.h of S2/S3 based boards.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
2021-12-15 15:49:23 +11:00
Tomas Vanek f9733705a9 esp32/machine_pin: Make GPIO 26 usable for S2,S3 if SPIRAM not config'd.
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
2021-12-15 15:48:46 +11:00
Damien George 5adb1fa40e esp32,esp8266: Extract qstr from object when comparing keys in config().
Following on from a previous fix for the same problem made in
3a431fba50.

Fixes issue #8052.

Signed-off-by: Damien George <damien@micropython.org>
2021-12-14 14:27:13 +11:00
IhorNehrutsa b491967bbd esp32/machine_pwm: Implement duty_u16() and duty_ns() PWM methods.
The methods duty_u16() and duty_ns() are implemented to match the existing
docs.  The duty will remain the same when the frequency is changed.
Standard ESP32 as well as S2, S3 and C3 are supported.

Thanks to @kdschlosser for the fix for rounding in resolution calculation.

Documentation is updated and examples expanded for esp32, including the
quickref and tutorial.  Additional notes are added to the machine.PWM docs
regarding limitations of hardware PWM.
2021-12-03 23:58:52 +11:00
Jim Mussared 678f4b959f esp32/boards/GENERIC_S3: Enable BLE on ESP32 S3.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-26 11:58:12 +11:00
Seon Rozenblum 1904833e0c esp32: Add SDCard support for S3, and a GENERIC_S3_SPIRAM board.
Also add support for GPIO 47 and 48 on S3 boards.
2021-11-19 14:05:55 +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
MikeTeachman 0be3b91f11 stm32,esp32: In machine_i2s, send null samples in underflow situations.
Eliminate noise data from being sent to the I2S peripheral when the
transmitted sample stream is stopped.

Signed-off-by: Mike Teachman <mike.teachman@gmail.com>
2021-11-12 16:50:15 +11:00
Magnus von Wachenfeldt 6d9da27c21 esp32: Support building with latest IDF v5.
The latest ESP-IDF v5.0-dev declares MAJOR_VERSION 5 and MINOR_VERSION 0.
timer_ll_set_alarm_enable() is also changed to timer_ll_set_alarm_value().
2021-11-12 16:40:46 +11:00
Mike Causer 7f14344428 ports: Add images, features and urls to board.json. 2021-10-28 15:25:38 +11:00
Mike Causer 07ea1afe74 esp32/boards/ESP32_S2_WROVER: Link to specific deploy_s2 instructions. 2021-10-28 12:58:58 +11:00
Mike Causer 3ace779e8e esp32/boards/LOLIN_S2_PICO: Add LOLIN_S2_PICO board definition files. 2021-10-28 12:58:50 +11:00
Damien George 1e4849557d esp32/usb: Further improve speed of USB CDC output.
Following on from ba940250a5, the change here
makes output about 15 times faster (now up to about 550 kbytes/sec).

tinyusb_cdcacm_write_queue will return the number of bytes written, so
there's no need to use tud_cdc_n_write_available.

Signed-off-by: Damien George <damien@micropython.org>
2021-10-28 11:37:35 +11:00
Seon Rozenblum 5b9c9cd097 esp32/boards: Update board and deploy metadata for UM_xxx boards. 2021-10-28 11:32:13 +11:00
Mike Causer 5bb14c4e46 esp32/boards/LOLIN_S2_MINI: Add image to board.json. 2021-10-28 09:51:04 +11:00
Jim Mussared 910e9f9111 esp32: Add specific deploy_s2.md instructions for esp32-s2.
In particular the UM S2 boards (and update the features list).

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-10-28 09:47:47 +11:00
Jim Mussared e359b077dd ports: Add board.json for all boards.
This will be used by https://micropython.org/download/ to generate the
full listing of boards and firmware files.

Optionally supports a board.md for additional customisation of the
download page, as well as deploy.md for flashing instructions.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-10-27 14:04:53 +11:00
Damien George ba940250a5 esp32/usb: Improve speed of USB CDC output.
Signed-off-by: Damien George <damien@micropython.org>
2021-10-16 00:23:59 +11:00
Damien George 549448e8bb esp32: Enable optimisations and move code to iRAM to boost performance.
This commit enables some significant optimisations for esp32:
- move the VM to iRAM
- move hot parts of the runtime to iRAM (map lookup, load global/name,
  mp_obj_get_type)
- enable MICROPY_OPT_LOAD_ATTR_FAST_PATH
- enable MICROPY_OPT_MAP_LOOKUP_CACHE
- disable assertions
- change from -Os to -O2 for compilation

It's hard to measure performance on esp32 due to external flash and
hardware caching.  But this set of changes improves performance compared to
master by (on a TinyPICO with the GENERIC build, using IDF 4.2.2, running
at 160MHz):

diff of scores (higher is better)
N=100 M=100    esp32-master -> esp32-perf       diff      diff% (error%)
bm_chaos.py           71.28 ->     268.08 :  +196.80 = +276.094% (+/-0.04%)
bm_fannkuch.py        44.10 ->      69.31 :   +25.21 = +57.166% (+/-0.01%)
bm_fft.py           1385.27 ->    2538.23 : +1152.96 = +83.230% (+/-0.01%)
bm_float.py         1060.94 ->    3900.62 : +2839.68 = +267.657% (+/-0.03%)
bm_hexiom.py          10.90 ->      32.79 :   +21.89 = +200.826% (+/-0.02%)
bm_nqueens.py       1000.83 ->    2372.87 : +1372.04 = +137.090% (+/-0.01%)
bm_pidigits.py       288.13 ->     664.40 :  +376.27 = +130.590% (+/-0.46%)
misc_aes.py          102.45 ->     345.69 :  +243.24 = +237.423% (+/-0.01%)
misc_mandel.py      1016.58 ->    2121.92 : +1105.34 = +108.731% (+/-0.01%)
misc_pystone.py      632.91 ->    1801.87 : +1168.96 = +184.696% (+/-0.08%)
misc_raytrace.py      76.66 ->     281.78 :  +205.12 = +267.571% (+/-0.05%)
viper_call0.py       210.63 ->     273.17 :   +62.54 = +29.692% (+/-0.01%)
viper_call1a.py      208.45 ->     269.51 :   +61.06 = +29.292% (+/-0.00%)
viper_call1b.py      185.44 ->     228.25 :   +42.81 = +23.086% (+/-0.01%)
viper_call1c.py      185.86 ->     228.90 :   +43.04 = +23.157% (+/-0.01%)
viper_call2a.py      207.10 ->     267.25 :   +60.15 = +29.044% (+/-0.00%)
viper_call2b.py      173.76 ->     209.42 :   +35.66 = +20.523% (+/-0.00%)

Five tests have more than 3x speed up (200%+).

The performance of the tests bm_fft, bm_pidigits and misc_aes now scale
with CPU frequency (eg changing frequency to 240MHz boosts the performance
of these by 50%), which means they are no longer influenced by timing of
external flash access.  (The viper_call* tests did previously scale with
CPU frequency, and they still do.)

Turning off assertions reduces code size by about 80k, and going from -Os
to -O2 costs about 100k, so the net change in code size (for the GENERIC
board) is about +20k.

If a board wants to enable assertions, or use -Os instead of -O2, that's
still possible by overriding the sdkconfig parameters.

Signed-off-by: Damien George <damien@micropython.org>
2021-10-16 00:07:11 +11:00
Damien George ea186de4c5 esp32: Split out WLAN code from modnetwork.c to network_wlan.c.
To match network_lan.c and network_ppp.c, and make it clear what code is
specifically for WLAN support.

Also provide a configuration option MICROPY_PY_NETWORK_WLAN which can be
used to fully disable network.WLAN (it's enabled by default).

Signed-off-by: Damien George <damien@micropython.org>
2021-09-24 12:41:35 +10:00
Damien George f046b50ca5 esp32/main: Add option for a board to hook code into startup sequence.
To do this the board must define MICROPY_BOARD_STARTUP, set
MICROPY_SOURCE_BOARD then define the new start-up code.

For example, in mpconfigboard.h:

    #define MICROPY_BOARD_STARTUP board_startup
    void board_startup(void);

in mpconfigboard.cmake:

    set(MICROPY_SOURCE_BOARD
        ${MICROPY_BOARD_DIR}/board.c
    )

and in a new board.c file in the board directory:

    #include "py/mpconfig.h"

    void board_startup(void) {
        boardctrl_startup();
        // extra custom startup
    }

This follows stm32's boardctrl facilities.

Signed-off-by: Damien George <damien@micropython.org>
2021-09-24 12:23:14 +10:00
leo chung 4fdf795efa esp32/mpthreadport: Fix TCB cleanup function so thread_mutex is ready.
Because vPortCleanUpTCB is called by the FreeRTOS idle task, and it checks
thread, but didn't check the thread_mutex.

And if thread is not NULL, but thread_mutex not ready then it will crash
with an error when calling mp_thread_mutex_lock(&thread_mutex, 1).

As suggested by @dpgeorge, move the thread = &thread_entry0 line to the end
of mp_thread_init().

Signed-off-by: leo chung <gewalalb@gmail.com>
2021-09-24 12:12:03 +10:00
Seon Rozenblum a39a596b79 esp32/machine_pin: Block out IO16 and IO17 when using SPIRAM on ESP32.
Fixes issue #7819.
2021-09-24 10:56:09 +10:00
Seon Rozenblum 35fb90bd57 esp32/usb: Add USB host connection detection for CDC serial output.
This callback allows detecting if there is a USB host connected to the CDC
or not, in which case the stdout_tx should skip CDC TX writing and
flushing or the system will block.

Fixes issue #7820.
2021-09-22 00:42:20 +10:00
Seon Rozenblum 7bf466a281 esp32/README: Updated readme with req IDF vers for ESP32-S2, C3 and S3. 2021-09-22 00:41:02 +10:00
IhorNehrutsa 52636fa692 esp32/machine_pwm: Add support for all PWM timers and channels.
This commit allows using all the available PWM timers (up to 8) and
channels (up to 16), without affecting the PWM API.

If a new frequency is set, first it checks if another timer is using the
same frequency.  If yes, then it uses this timer, otherwise, it creates a
new one.  If all timers are used, the user should set an already used
frequency, or de-init a channel.

This work is based on #6276 and #3608.
2021-09-21 23:18:09 +10:00
Stewart Bonnick 0d9429f44c esp32/boards: Add LOLIN_S2_MINI ESP32-S2 board.
To support Lolin S2 Mini ESP32-S2 Variant board.  More information about
this board can be found at https://www.wemos.cc/en/latest/s2/s2_mini.html
2021-09-21 22:49:51 +10:00
patrick 4cfd85eb4a esp32/boards: Add board definition for ESP32-S2-WROVER module. 2021-09-19 16:49:35 +10:00
Seon Rozenblum 13e6e0d7f5 esp32/machine_hw_spi: Fix hardware SPI DMA channels for S2/S3. 2021-09-19 10:23:12 +10:00
Damien George 80fe25689f esp32/boards: Add new GENERIC_S3 board definition.
Thanks to Seon Rozenblum aka @UnexpectedMaker for the work.

Signed-off-by: Damien George <damien@micropython.org>
2021-09-16 22:58:47 +10:00
Damien George 54d33b266c esp32: Add support for ESP32-S3 SoCs.
Thanks to Seon Rozenblum aka @UnexpectedMaker for the work.

Signed-off-by: Damien George <damien@micropython.org>
2021-09-16 22:58:47 +10:00
Seon Rozenblum f690fd3a47 esp32/machine_timer: Use tx_update member for IDF 4.4 and above. 2021-09-13 18:25:16 +10:00
Seon Rozenblum 9a7f77bfbc esp32/boards: Add new FeatherS2-Neo board definition. 2021-09-10 15:40:32 +10:00
Damien George af64c2ddbd extmod/machine_pwm: Factor out machine.PWM bindings to common code.
This commit refactors machine.PWM and creates extmod/machine_pwm.c.  The
esp8266, esp32 and rp2 ports all use this and provide implementations of
the required PWM functionality.  This helps to reduce code duplication and
keep the same Python API across ports.

This commit does not make any functional changes.

Signed-off-by: Damien George <damien@micropython.org>
2021-09-04 16:31:17 +10:00
Damien George d41f6dde56 extmod/modonewire: Make _onewire module configurable via macro option.
Signed-off-by: Damien George <damien@micropython.org>
2021-09-02 13:11:23 +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
David Lechner 86371781e9 tools/uncrustify: Force 1 newline at end of file.
To keep things neat and tidy, we ensure that each file has 1 and only 1
newline at the end of each file.

Signed-off-by: David Lechner <david@pybricks.com>
2021-08-31 13:14:45 +10:00
Patrick Van Oosterwijck a66bd7a489 esp32/boards: Add GENERIC_C3_USB board with USB serial/JTAG support.
Add a new board type for ESP32-C3 revision 3 and up that implement the USB
serial/JTAG port on pin 18 and 19.  This variant uses the USB serial for
programming and console, leaving the UART free.

- Pins 18 and 19 are correctly reserved for this variant.  Also pins 14-17
  are reserved for flash for any ESP32-C3 so they can't be reconfigured
  anymore to crash the system.
- Added usb_serial_jtag.c and .h to implement this interface.
- Interface was tested to work correctly together with webrepl.
- Interface was tested to work correctly when sending and receiving
  large files with ampy.
- Disconnecting terminal or USB will not hang the system when it's
  trying to print.
2021-08-31 00:12:41 +10:00
Jim Mussared 996f703166 esp32,esp8266: Remove dead code for end_ticks in machine_bitstream.
The compiler was optimising this out already so it's a no-op change.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-24 23:55:08 +10:00
Jim Mussared 62fd450e62 drivers/neopixel: Add common machine.bitstream-based neopixel module.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-19 22:50:32 +10:00