-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ets intr lock nest #6484
Ets intr lock nest #6484
Conversation
Testing has shown that there are several paths in the SDK that result in nested calls to ets_intr_lock() / ets_intr_unlock() which may be a problem. These functions also do not preserve the enabled interrupt level and may result in code running with interrupts enabled when that is not intended. This issue has recently been fixed in the Arduino code by using xt_rsil() / xt_wsr_ps() but still exists in the Espressif SDK code. This commit is intended to fix that and should be used in addition to the above. The maximum nesting I have seen is 2 and lock/unlock calls appear to be balanced. A max of 7 levels of nesting leaves plenty of room for that to change.
…r/underflow The PS register is 15 bits, we should store the whole thing as xt_wsr_ps() writes the whole thing. Also if there is an underflow, we should make sure interrupts are enabled. Same goes for overflow making sure interrupts are disabled, although this is less important.
This saves having to modify libmain.a, libpp.a and libnet80211.a to use the nested versions. Adjusts fix_sdk_libs.sh accordingly.
Are the modifications you brought to fw libs scriptable ? |
b2c68f6
to
e5177ac
Compare
Add a wrapper around the ets_post code in rom to preserve the interrupt enable state. Rather than modifying the SDK libs, rename ets_post in the .ld file and call the wrapper "ets_post" to replace it. As far as I can establish, ets_post is the only rom function in use by our code or the SDK libs we use that causes calls to ets_intr_(un)lock.
The ets_post wrapper appears to have resolved the arp / network deafness issue - at least my test unit is 58 hours up and reachable where I was seeing it go deaf after around 25-30 hours operation. |
If that's true, this is a real major improvement ! What about
This should be merged asap ! |
|
With the IRAM_ATTR my node does boot and seems to run fine. |
Just a short update here. |
With |
@d-a-v If that's the default behavior then yes. The only WiFi sleep related code I have in the entire project is this: WiFi.setSleepMode(WIFI_NONE_SLEEP); And that one is now not being called, so it is just running the default sleep mode. |
Just some quick update. |
Me too, running two nodes with modem sleep option DTIM=3. I've had problems with connection stability on LWIP2 before this fix, while LWIP 1.4 was working longer w/o disconnection from MQTT and without router disassociation due to inactivity. Testing LWIP2 Higher Bandwidth right now on this PR. Everything flashed properly and my device started successfully. I will update soon. |
My nodes were still reacting fast after the night, so at least it is not breaking anything :) |
Awesome! My original test device is at 95 hours now and still going strong. |
Two nodes - 25 hours passed, no disconnection from MQTT on LWIP2. Never reached this before :) It means that it improves #2330 , don't saying 'fixes' yet. Test is still running. |
Let's dare @ChocolateFrogsNuts This is thrilling |
…sNuts/Arduino into ets_intr_lock_nest
Fixes #2330 |
Ref: tools uploaded to this repo: |
I'd like to mention that following this fix, a board that was never working suddenly resurrected. (symptom: Losing wifi after the first connected second. Never able to reconnect until a reset) |
To be able to use this merged PR: esp8266/Arduino#6484
To be able to use this merged PR: esp8266/Arduino#6484
Yeah ;) My boards connection time is now more than one week. No disconnections anymore! On LWIP2, before this fix, it was dropping after few hours. |
Replace the SDK's use of ets_intr_lock / ets_intr_unlock with nestable versions.
This is intended for use in addition to using xt_rsil / xt_wsr_ps in the Arduino code and other more correct approaches where they are possible.