| Age | Commit message (Collapse) | Author |
|
Assuming proper C99 language support, we can select "the int type as big as
a pointer" (most of the time) or "the 64-bit int type" (nanboxing with
REPR_D), and then define everything else automatically.
This simplifies port configuration files. And the types can still be
overridden if needed.
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
|
|
Saves approx 19KB on ESP32-C6 and 11KB on ESP32-C2, meaning IDF V5.5.1
builds now have more free RAM than V5.4.2.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
Tested with ESP32_GENERIC, ESP32_GENERIC_C3, ESP32_GENERIC_C6 and
ESP32_GENERIC_S3 firmware, using the full test suite. There do not seem to
be any regressions.
Signed-off-by: Damien George <damien@micropython.org>
|
|
Factors out the space-saving config options from `sdkconfig.d2wd` to a new
`sdkconfig.flash_2MiB` file, and uses that in the new C2 FLASH_2M variant.
Signed-off-by: Florent <florent@frizoncorrea.fr>
|
|
Much cleaner. Also add deltas to the output table for easier
interpretation.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
The esp32 I2C driver sets a global timeout during init. The functionality
for this is currently only correct for original esp32 and esp32-s2, newer
parts have a slightly different argument which is log-base-2 of the
timeout.
Note that `i2c_set_timeout()` is a thin layer around `i2c_ll_set_tout()`
with the latter writing directly to the hardware register. So the timeout
argument passed to `i2c_set_timeout()` needs to be in units calculated by
`i2c_ll_calculate_timeout_us_to_reg_val()`.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
|
|
With the aim of getting consistency, and removing the need to learn an
additional term, replace uses of uPy/uPython with MPy/MicroPython.
Rule of thumb was to use "MPy" abbreviation where "CPy" is used nearby, but
the full word MicroPython otherwise.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
Support both the legacy ESP-IDF I2C driver (driver/i2c.h) and the new
driver/i2c_master.h API for all ESP32-series SoCs. This is controlled by
the new config option MICROPY_HW_ESP_NEW_I2C_DRIVER, which is disabled by
default.
There is a small change to the legacy variant, which shows now as well freq
and timeout_us in the print() method.
Open issues with the new driver:
- No control of the stop=True|False option. stop is always assumed to
be True. An issue is raised at the esp-idf repository for it.
- Separate call to probe the address at fixed 100kHz. The need is caused
by the fact, that NACK on an address is considered as an hard error.
According to espressif's issue tracker this is already changed for
v6.x and will be backported to earlier versions. So we may see it in
a version after V5.5.1 or in a version 5.4.3. There is code in
comments to support zero-length writes.
Original patch for the v2 driver by Vincent1-python <pywei201209@163.com>.
Signed-off-by: robert-hh <robert@hammelrath.com>
|
|
machine.Timer() has inconsistent behaviour between ports: some run
callbacks in hard IRQ context whereas others schedule them like soft IRQs.
Most ports now support a hard= argument to the machine.Timer constructor
or initialiser to explicitly choose between these behaviours. However,
esp32 does not support hardware interrupts because they are not delivered
to the main thread, so the interrupt handler would need to acquire the GIL.
Raise a ValueError if hard=True is requested for esp32 machine.Timer.
Signed-off-by: Chris Webb <chris@arachsys.com>
|
|
Otherwise an error message will pop up at the first instatiation
of the UART object.
Addresses #18122 / #18123.
Signed-off-by: robert-hh <robert@hammelrath.com>
|
|
Before, it was ignored. Tested with ESP32, ESP32S3, ESP32C6.
Signed-off-by: robert-hh <robert@hammelrath.com>
|
|
Makes machine.UART objects static instances (similar to other ports), adds
machine_uart_deinit_all() function for cleanup on soft reset.
- Fixes the case where the OS-level uart_event_task is leaked
(along with 2KB of heap) when a UART object is garbage collected
(including after a soft reset).
- Fixes hard fault if a previous UART irq() fires after the UART object is
garbage collected (including after a soft reset), but before any new UART
object is instantiated for the same UART number.
- Constructing multiple UART objects for the same UART now returns the
same instance multiple times, not different instances.
- Was also able to streamline deinit/init to only install the driver once,
rather than install-with-defaults/uninstall/reinstall.
Alternative would be to add a finaliser, but this is more consistent
with how most other UART objects are implemented.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
This is recommended by Espressif, and it's the only way to ensure
everyone builds the same set of component versions.
The awkward part is that updating the ESP-IDF version will churn a line
in each of these files (and possibly other changes).
Adds a build-time check for lock file changes, which is either a warning or
a hard error depending on the value of MICROPY_MAINTAINER_BUILD
flag (introduced in previous commit).
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
Reported to fix issues reported with serial corruption when interacting
with MicroPython from macOS hosts.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
This commit fixes the build issues in the ESP32 port that arise when
explicitly disabling USB CDC support.
The USB support code gated the USB serial number retrieval behind the
USB CDC support definition, even though all USB devices must be able to
be queried for their serial number.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
|
|
This reverts commit 3c9546ea0911b50d4b85ad4046864c90f84b3fd3.
I2CTarget now fits on ESP32-C6 because it's compiled with -Os, see commit
5b98126c21f8eaa996e258761a291a7a88624082.
Signed-off-by: Damien George <damien@micropython.org>
|
|
I2S works on the ESP32-C6, and it now has enough space to fit.
Signed-off-by: Jimisola Laursen <jimisola@jimisola.com>
Signed-off-by: Damien George <damien@micropython.org>
|
|
Same optimisation that was applied to C6 in the parent commit, now applied
to all RISC-V boards.
+------------+------------+------------+------------+
| Size | Before | After | Delta |
+------------+------------+------------+------------+
| C2 Binary | 1680384 | 1494224 | -186160 |
| C2 D/IRAM | 83710 | 79080 | -4630 |
| C3 Binary | 1833328 | 1636624 | -196704 |
| C3 D/IRAM | 139608 | 131896 | -7712 |
+------------+------------+------------+------------+
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
Reduces ESP32_GENERIC_C6 application flash size from 2024432 to
1813216 (206KB smaller).
Also has benefit of reducing D/IRAM size, increasing free memory at
runtime (167187 to 148584, -18603 bytes).
Most of this savings comes from building with -Os instead of -O2,
but about 10KB comes from using the SPI flash functions from the ROM.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
When disconnecting from PPP the modem sends a confirmation. This message
is received, like all messages, through the poll() method. lwIP may then
immediately call our status callback with code PPPERR_USER to indicate
the connection was closed. Our callback then immediately proceeds to
free the PCB. Thus, during each new iteration of the loop in poll() we
must check if we haven't disconnected in the meantime to prevent calling
the pppos_input_tcpip with a PCB that is now NULL.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
|
|
If while a polling operation is active the stream is removed we should
stop polling data from that stream.
This was already the intended behaviour, but implemented incorrectly.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
|
|
This commit unifies the configuration of MICROPY_PY_CRYPTOLIB,
MICROPY_PY_HASHLIB_MD5 and MICROPY_PY_HASHLIB_SHA1, so they are enabled by
default if MICROPY_PY_SSL is enabled. This matches the existing
configuration of most of the ports.
With this change, all ports remain the same except:
- reneses-ra now enables MICROPY_PY_CRYPTOLIB, MICROPY_PY_HASHLIB_MD5 and
MICROPY_PY_HASHLIB_SHA1.
- rp2 now enables MICROPY_PY_HASHLIB_MD5.
Signed-off-by: Damien George <damien@micropython.org>
|
|
This factors code out of the ports and into the common `time.localtime`
implementation in `extmod/modtime.c`. That helps to reduce code
duplication, prevent errors in implementation, and reduce code size on
some ports (mimxrt and stm32 at least).
Signed-off-by: Damien George <damien@micropython.org>
|
|
If PPP is still connected, freeing the PCB will fail and thus instead we
should trigger a disconnect and wait for the lwIP callback to actually
free the PCB.
When PPP is not connected we should check if the freeing failed, warn
the user if so, and only mark the connection as inactive if not.
When all this happens during garbage collection the best case is that
the PPP connection is already dead, which means the callback will be
called immediately and cleanup will happen correctly. The worst case is
that the connection is still alive, thus we are unable to free the PCB
(lwIP won't let us) and it remains referenced in the netif_list, meaning
a use-after-free happens later when lwIP traverses that linked list.
This change does not fully prevent that, but it *does* improve how the
PPP.active(False) method on the ESP32 port behaves: It no longer
immediately tries to free (and fails), but instead triggers a disconnect
and lets the cleanup happen correctly through the status callback.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
|
|
The status callback runs on the lwIP tcpip_thread, and thus must use the
non-thread-safe API because the thread-safe API would cause a deadlock.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
|
|
A small follow-up to 3b1e22c66947271e8b60eddf4e8aa6dadc6d9a7d, in which
the entire PPP implementation was reworked to more closely resemble the
extmod version. One of the differences between extmod and the ESP32 port
is that the ESP32 port uses the thread-safe API, but in that changeset
the PPP input function was accidentally changed to use the non-safe API.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
|
|
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
|
|
Also future-proofs this code for other chips. Apart form C6 and C2, all
currently supported chips use APB clock for GPTIMER_CLK_SRC_DEFAULT.
ESP32-C2 uses 40MHz PLL but APB_CLK_FREQ was 26MHz.
ESP32-C6 uses 80MHz PLL but APB_CLK_FREQ was 40MHz.
Implementation now gets the correct frequency from ESP-IDF.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
Otherwise the PLL is not enabled. These changes are adapted from
`timer_legacy.h` in ESP-IDF.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
Signed-off-by: Damien George <damien@micropython.org>
|
|
I2CTarget costs about 8k of flash size on ESP32-S2, and about 11k on
ESP32-C6. The ESP32-C6 only has about 8k remaining, so disable I2CTarget
on that SoC until more flash can be made available.
Signed-off-by: Damien George <damien@micropython.org>
|
|
Adds a Python override of the `machine` module, which delegates to the
built-in module and adds an implementation of `Counter` and `Encoder`,
based on the `esp32.PCNT` class.
Original implementation by: Jonathan Hogg <me@jonathanhogg.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
Add a new `esp32.PCNT` class that provides complete, low-level support to
the ESP32 PCNT pulse counting hardware units.
This can be used as a building block to implement the higher-level
`machine.Counter` and `machine.Encoder` classes.
This is enabled by default on all OG, S2, S3, C6 boards, but not on C3 (as
the PCNT peripheral is not supported).
Original implementation by: Jonathan Hogg <me@jonathanhogg.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
Only soft IRQs are supported.
Signed-off-by: Damien George <damien@micropython.org>
|
|
So the implementation of I2CTarget can use them.
Signed-off-by: Damien George <damien@micropython.org>
|
|
ESP32-C2 ROM prints at 74880bps (same as ESP8266), so need a newline
before first MicroPython output to avoid it being appended on end of
a line of noise.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
This is necessary for ESP32-C2 Wi-Fi & BT to work reliably (and for TLS to
work at all). On IDF 5.4.2 the free static RAM goes from 60KB to 100KB, and
there will also be a reduction in lwIP & Wi-Fi memory use at runtime.
The performance trade-off seems low for most use cases, although it will
probably be significant for certain combinations of load (i.e. heavy
TCP/IP, heavy BT throughput, and some peripheral driver functions).
Added as a set of config flags because this is potentially useful on other
SoCs where the goal is to maximise RAM available for MicroPython.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
Includes:
esp32/esp32c2: Adapt to target chip ESP32C2.
esp32/esp32c2: Fix heap size is too small to enable Bluetooth.
Signed-off-by: TianShuangKe <qinyun575@gmail.com>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
The default definition in `py/mpconfig.h` for 32-bit architectures is
`%u/%d`, so these can be removed.
Signed-off-by: Jeff Epler <jepler@gmail.com>
|
|
This is a patch release of the IDF. Comparing with 5.4.1, firmware size is
up by about 1.5k on ESP32 and 9k on ESP32-S3. But IRAM usage (of the IDF)
is down by about 500 byte on ESP32 and DRAM usage is down by about 20k on
ESP32 and 10k on ESP32-S3.
Testing on ESP32, ESP32-S2, ESP32-S3 and ESP32-C3 shows no regressions,
except in BLE MTU ordering (the MTU exchange event occuring before the
connect event).
Signed-off-by: Damien George <damien@micropython.org>
|
|
Currently, `UART.sendbreak()` on esp32 will reconfigure the UART to a
slower baudrate and send out a null byte, to synthesise a break condition.
That's not great because it changes the baudrate of the RX path as well,
which could miss incoming bytes while sending the break.
This commit changes the sendbreak implementation to just reconfigure the TX
pin as GPIO in output mode, and hold the pin low for the required duration.
Signed-off-by: Damien George <damien@micropython.org>
|
|
This is code makes sure that time functions work properly on a
reasonable date range, on all platforms, regardless of the epoch.
The suggested minimum range is 1970 to 2099.
In order to reduce code footprint, code to support far away dates
is only enabled specified by the port.
New types are defined to identify timestamps.
The implementation with the smallest code footprint is when
support timerange is limited to 1970-2099 and Epoch is 1970.
This makes it possible to use 32 bit unsigned integers for
all timestamps.
On ARM4F, adding support for dates up to year 3000 adds
460 bytes of code. Supporting dates back to 1600 adds
another 44 bytes of code.
Signed-off-by: Yoctopuce dev <dev@yoctopuce.com>
|
|
The IDF panic handler resets the watchdog timeout to prevent the printing
of the error message from being cut off by a WDT reset. We use the exact
same function call in our wrapper function for the same purpose.
In IDFv5.4.2 the function used for this was changed from
`esp_panic_handler_reconfigure_wdts` to `esp_panic_handler_feed_wdts`,
specifically in this commit:
https://github.com/espressif/esp-idf/commit/cd887ef59a7b966a7f431754aaec6ee653849d77
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
|
|
|
|
In different functions `machine_rtc_config.ext0_pin` is accessed where
SOC_PM_SUPPORT_EXT0_WAKEUP is not defined, fix that.
Signed-off-by: Meir Armon <meirarmon@gmail.com>
|
|
The `esp32.wake_on_ext1()` method should only be available on boards that
have SOC_PM_SUPPORT_EXT1_WAKEUP=y. And update docs to reflect this.
Signed-off-by: Meir Armon <meirarmon@gmail.com>
|
|
The `esp32.wake_on_ext0()` method should only be available on boards that
have SOC_PM_SUPPORT_EXT0_WAKEUP=y. And update docs to reflect this.
Signed-off-by: Meir Armon <meirarmon@gmail.com>
|
|
The `esp32.wake_on_touch()` method should only be available on boards that
have SOC_TOUCH_SENSOR_SUPPORTED=y. And update docs to reflect this.
Signed-off-by: Meir Armon <meirarmon@gmail.com>
|
|
The `esp32.wake_on_ulp()` method should only be available on boards that
have SOC_ULP_SUPPORTED=y. Update docs to reflect this.
Signed-off-by: Meir Armon <meirarmon@gmail.com>
|
|
Signed-off-by: Damien George <damien@micropython.org>
|