espressif / esp32-arduino-lib-builder

134 stars 148 forks source link

Make LwIP Core Locking available #186

Open HamzaHajeir opened 3 weeks ago

HamzaHajeir commented 3 weeks ago

Make the implementation of LwIP core locking available: https://github.com/espressif/esp-lwip/blob/a45be9e438f6cf9c54ec150581819c3b95d5af6b/src/include/lwip/tcpip.h#L52-L59

Important when dealing with Raw APIs

me-no-dev commented 3 weeks ago

please provide more info. Why, how, etc.

HamzaHajeir commented 3 weeks ago

For OS Mode, the threading of LwIP Raw APIs should be taken care of, APIs should never be called in parallel to lwip task operations (which happens by using an RTOS, in calling APIs by both main and tcpip tasks), can be solved by two possible methods: 1) Using of tcpip_callback(). 2) Using LwIP Core Locking.

The nongnu website is down right now, so here's a reference to the raw file of the documentation regarding it: https://github.com/espressif/esp-lwip/blob/5378fd84df498759d4ba231f6ca3a42d6aa0fb93/doc/doxygen/main_page.h#L162-L182

This method is used and tested in H4AsyncTCP the library I maintain after the passage of its author, where it shows high reliability under heavy testing in ESP32 environment (The 8266 too but no OS).

And here's the relevant Kconfig description in esp-idf component lwip: https://github.com/espressif/esp-idf/blob/0479494e7abe5aef71393fba2e184b3a78ea488f/components/lwip/Kconfig#L37-L46

Jason2866 commented 5 days ago

What's the need/benefit for the Arduino code? In other words real life use case? This forked lib from me-no-dev does not need.

https://github.com/mathieucarbou/AsyncTCP https://github.com/mathieucarbou/ESPAsyncWebServer

HamzaHajeir commented 5 days ago

Refer to my last comment: https://github.com/espressif/esp32-arduino-lib-builder/pull/186#issuecomment-2189464829

On Sat, Jul 13, 2024, 13:59 Jason2866 @.***> wrote:

What's the need/benefit for the Arduino code? In other words real life use case?

— Reply to this email directly, view it on GitHub https://github.com/espressif/esp32-arduino-lib-builder/pull/186#issuecomment-2226855648, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH3O7J5YJK34YCBNZ6L325LZMEB7ZAVCNFSM6AAAAABJ4CLF2OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRWHA2TKNRUHA . You are receiving this because you authored the thread.Message ID: @.***>

Jason2866 commented 5 days ago

One! use case. Why should a setup be changed that may introduce side effects hitting all espressif32 Arduino users? My experience Lwip setup changes should be only done to fix a bug hitting most use cases. For special use cases there is the Arduino Lib Builder ;-)

HamzaHajeir commented 5 days ago

One! use case. Why should a setup be changed that may introduce side effects hitting all espressif32 Arduino users? My experience Lwip setup changes should be only done to fix a bug hitting most use cases. For special use cases there is the Arduino Lib Builder ;-)

I know that, and for that matter I've been using the builder for at least more than a year.

But per the lock feature, it has no side effects, as it's well ported to esp-idf: https://github.com/espressif/esp-lwip/blob/a45be9e438f6cf9c54ec150581819c3b95d5af6b/src/include/lwip/tcpip.h#L52-L64 https://github.com/espressif/esp-idf/tree/master/components/lwip/port/freertos

BTW, the H4 Stack is completely Async, with complete reliable stack starting from TCP to the application (MQTT/HTTPS WebServer/WSS/HTTPS Client). I've a running MQTT that publishes 13kB payload every 3 seconds over TLS, alongwith running HTTPS WebServer/WSS/HTTP Client, with lots of other stress tests performed.

The Lock is needed to allow it for public use with the official Arduino Core for at least the plain TCP part now.

Jason2866 commented 5 days ago

But per the lock feature, it has no side effects, as it's well ported to esp-idf

Famous last words :-)

So it has NO impact of Flash Usage, RAM usage. Every piece of code does run as before?

HamzaHajeir commented 5 days ago

But per the lock feature, it has no side effects, as it's well ported to esp-idf

Famous last words :-)

So it has NO impact of Flash Usage, RAM usage. Every piece of code does run as before?

Too little overhead due to the usage of the mutex, check sys_arch.c. Count the bytes :-)