Age | Commit message (Collapse) | Author |
|
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>
|
|
Remove the "vfs" entry from all partitions-*.csv files, and then remove
duplicated files.
And remove the ESP32_GENERIC_S3-FLASH_4M variant, because it's no longer
needed.
Signed-off-by: Damien George <damien@micropython.org>
|
|
Currently in the esp32 port the size of the SPI flash must be configured at
build time, eg 4MiB, 8MiB, etc. Also, the esp32 partition table must be
configured at build time, which depends on the size of the SPI flash. A
bigger flash means more can be allocated to the user filesystem.
This commit makes it so the SPI flash size is automatically determined at
runtime, and the filesystem size is automatically set to take up as much
room as possible (a "vfs" partition is created automatically if it doesn't
exist).
This works by:
- Setting the SPI flash size to be 4MiB in the build (or some other value,
as long as the firmware app fits).
- Removing the vfs partition from the esp32 partition table (only nvs,
phy_init and firmware, and maybe romfs, remain in the partition table).
- At boot, query the physical size of the SPI flash and use that as the
actual size in the code.
- If it doesn't already exist, automatically create a "vfs" partition which
takes up the flash from the end of all existing partitions to the end of
flash.
This allows simplifying a lot of board configurations, and removing some
board variants that just change the flash size (to be done in a following
commit).
It's also fully backwards compatible, in the following sense:
- Existing boards with MicroPython firmware will continue to work with the
same filesystem, ie the filesystem won't be erased when the firmware is
updated.
- If a user has a custom esp32 partition table and installs MicroPython as
a bare app into the app partition, the new MicroPython firmware will
honour the esp32 partition table and use either "vfs" or "ffat"
partitions as the filesystem.
Signed-off-by: Damien George <damien@micropython.org>
|
|
This commit updates the ADC to use the new driver `esp_adc/adc_oneshot.h`.
There are several errata notes about not being able to change the bit-width
of the ADCs certain chips. The only chip that can switch resolution to a
lower one is the normal ESP32. ESP32 C2 and S3 are stuck at 12 bits, while
S2 is at 13 bits.
On the S2, you can change the resolution, but it has no effect on the
resolution, rather, it prevents attenuation from working at all!
The resolution is set to the maximum possible for each SoC, with the ESP32
being the only one not throwing errors when trying to set the bit-width to
9, 10, 11 or 12 bits using `ADC.width(bits)`.
Signed-off-by: Damian Nowacki (purewack) bobimaster15@gmail.com
|
|
If the interrupt is not freed but merely disabled, instead of reallocating
it every time the timer is enabled again we can instead just re-enable it.
That means we're no longer setting the handler every time, and we need to
ensure it does not change. Doing so by adding an additional wrapper
function does not only solve that problem, it also allows us to remove
some code duplication and simplify how machine_uart uses the timer.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
|
|
esp_intr_free is not safe to call from the timer ISR because it requires
the current task (the one the ISR interrupted) to be pinned to the same
core as the interrupt was allocated on. Merely disabling the ISR however is
safe since that only requires that we're currently running on the same core
(which the ISR always is), regardless of the current task.
This was causing deadlocks in machine_uart when the ISR happened to
interrupt a task that was not pinned to a specific core.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
|
|
If the BLE radio stops responding before deinit is called the function can
get stuck waiting for an event that is never received, particularly if the
radio is external or on a separate core.
This commit adds a timeout, similar to the timeout already used in the init
function. Updated for nimble, btstack, esp32 and zephyr bindings.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
|
|
The vendor and product fields in the `board.json` files were somewhat
inconsistent. Remove any duplication of the vendor name in the product
field so that `f"{vendor} {product}"` reads well.
In addition to that, update most of the URL's for `board.json` files that
are modified here, and match case and spacing used by the manufacturers for
the vendor and product names.
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
|
|
Implements MSG_PEEK and MSG_DONTWAIT (both passed through to LWIP
sockets API).
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|