TLS errors on ESP-IDF 5.4 with default MICROPY_GC_INITIAL_HEAP_SIZE
Port, board and/or hardware
esp32 port
MicroPython version
➜ esp32 git:(master) git describe --dirty
v1.24.0-224-ga4ab84768
Reproduction
Making single requests to 2 different TLS endpoints (which have small payloads).
➜ esp32 git:(master) ✗ idf.py --version
ESP-IDF v5.4
...
Chip is ESP32-D0WDQ6 (revision v0.0)
Features: WiFi, BT, Dual Core, Coding Scheme None
Crystal is 40MHz
Expected behaviour
IDF 5.3 was stable without change to MICROPY_GC_INITIAL_HEAP_SIZE
➜ esp32 git:(master) idf.py --version
ESP-IDF v5.3
Observed behaviour
I was getting various intermittent lock up (including no ping responses via network to device) or OSError with TLS HTTP requests:
(-17040, 'MBEDTLS_ERR_RSA_PUBLIC_FAILED+MBEDTLS_ERR_MPI_ALLOC_FAILED')
(-29312, 'MBEDTLS_ERR_SSL_CONN_EOF')
[Errno 104] ECONNRESET
Workaround: Adjusting MICROPY_GC_INITIAL_HEAP_SIZE to (52 * 1024) (from 56) none of these errors triggered. Errors triggered if I had the value set to (54 * 1024) as well.
Additional Information
It is unstable on 5.3.2 as well, but I noted it is not in the "approved" IDF versions. I am not sure if the patch version matters, but because 5.2 and 5.2.2 are explicitly listed, it makes me think they are. Unfortunately, IDF does not have a 5.3.0, so I think micropython esp32 port just lists 5.3. May be worth indicating that supported patch versions will be explicitly listed.
it was relatively stable on 5.3.1 (not as bad as 5.3.2)
Code of Conduct
Yes, I agree
esp32: Drop support for ESP-IDF <v5.3, fix build on ESP-IDF v5.3
Summary
- We try to support at least some older ESP-IDF versions, so that people making custom MicroPython builds on esp32 aren't always forced to upgrade. Unfortunately we've sometimes merged fixes that break on older ESP-IDF and not noticed until later (recent example: https://github.com/micropython/micropython/pull/18894#issuecomment-4016278894)
- This PR drops support for ESP-IDF v5.2.x, leaving us with three minor versions to support.
- Also applies necessary fixes to build the esp32 port under ESP-IDF v5.3.
Testing
- Built with ESP-IDF v5.3 and v5.4 locally. Also built with ESP-IDF v5.3 in CI (those changes split off to a new PR, however).
Trade-offs and Alternatives
- Could more aggressively drop older versions. This makes our lives easier, and is arguably better than the current situation where we "support" older ESP-IDF but the port doesn't actually build. However, having some support for older ESP-IDF seems like a very helpful thing if you're maintaining a custom MicroPython build and want to update MicroPython without always updating ESP-IDF.
Generative AI
I did not use generative AI tools when creating this PR.