AtomVM icon indicating copy to clipboard operation
AtomVM copied to clipboard

Address several ESP32 network driver issues

Open UncleGrumpy opened this issue 1 year ago • 3 comments

These changes close the following issues for the ESP32 network driver:

  • [#643] When network:stop/0 is used the driver is now completely stopped and all resources are freed.
  • [#1100] Adds a configurable event handler for STA beacon timeouts (Event: 21).
  • Fixes several possible cases of double free() when using network:start/1.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

UncleGrumpy avatar Apr 23 '24 18:04 UncleGrumpy

Thank you for the explanation of the REGISTER_PORT_DRIVER destroy_cb in the Telegram chat, this did not work as advertised! I was also several missing steps, so even when the VM exited and the destroy_cb would execute this code, netif and IP callbacks would still be triggered.

These problems have all been fixed, and the driver shuts down and exits cleanly. There is still one ESP-IDF message (in some builds, depending on the IDF version) in the console logs that is being reported as an error:

E (8246) wifi:NAN WiFi stop

I looked into this and it is actually a known ESP-IDF issue, that will be changed to an information message in a future update. See espressif/esp-idf#12473.

UncleGrumpy avatar May 01 '24 03:05 UncleGrumpy

This is great!

Can anecdotally confirm this resolves esp32s2 OOM'ing with the forthcoming wifi test CI (oom only on esp-idf v5.1.4, on the test after wifi).. and adding network:stop() to the code resolved it. (3 failed runs OOM, 3 success runs with network:stop())

Have tested full Sim CI suite - all is green, the systems with wifi exercised network:stop().

Screenshot 2024-06-15 at 23 48 39

petermm avatar Jun 15 '24 21:06 petermm

Can anecdotally confirm this resolves esp32s2 OOM'ing with the forthcoming wifi test CI (oom only on esp-idf v5.1.4, on the test after wifi).. and adding network:stop() to the code resolved it. (3 failed runs OOM, 3 success runs with network:stop())

That is awesome, however I need a complete understanding about how this fix is working during the review...

bettio avatar Jun 18 '24 12:06 bettio