← index #16650Issue #538
Related · medium · value 1.289
QUERY · ISSUE

TLS errors on ESP-IDF 5.4 with default MICROPY_GC_INITIAL_HEAP_SIZE

openby chaseadamopened 2025-01-25updated 2025-10-31
bugport-esp32

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

CANDIDATE · ISSUE

urequests TLS requests fail on ESP32 with ESP-IDF 4.3 and 4.4

closedby chaseadamopened 2022-09-20updated 2022-10-12

TLS calls work in the 1.19.1 official release binary and with master commit 13c4470fd04981fce3fd29771e1d973febbe7d60 built against ESP-IDF 4.2.

MicroPython v1.19.1-437-g13c4470fd on 2022-09-20; ESP32 module with ESP32
Type "help()" for more information.
>>> gc.mem_free()
29712
>>> gc.collect()
>>> gc.mem_free()
69664
>>> r = requests.get('https://google.com')
>>>

Using ESP-IDF 4.3 and 4.4 with 1.19.1 sources or HEAD of master result in what appear to be memory issues.

Output:

>>> import urequests as requests
>>> gc.mem_free()
23360
>>> gc.collect()
>>> gc.mem_free()
66336
>>> r = requests.get('https://google.com')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "urequests.py", line 180, in get
  File "urequests.py", line 93, in request
OSError: 16

I have also seen the following errors:

This is most common

Error: [Errno 113] ECONNABORTED, Reason: null

I saw this intermittently while testing

OSError: (-17040, 'MBEDTLS_ERR_RSA_PUBLIC_FAILED+MBEDTLS_ERR_MPI_ALLOC_FAILED')
2 comments
jimmo · 2022-09-21

@chaseadam this is https://github.com/micropython/micropython/issues/8940

(And unfortunately, it's the reason why we still do ESP32 builds with IDF 4.2)

chaseadam · 2022-10-12

closing out as this is duplicate of https://github.com/micropython/micropython/issues/8940

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied