Skip to content
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

Fix PWM crashes on ESP8266 #4035

Merged
merged 2 commits into from
Jul 13, 2024
Merged

Conversation

willmmiles
Copy link
Collaborator

Vendor in the ESP8266 Arduino core PWM library, with a fix for a nasty NMI crash bug. Sometimes the NMI return instruction seems to fail, resulting in an infinite loop as the PC gets stuck "returning" to the NMI handler itself. Work around this by backing up and restoring the PC (and PS) from the last known good target values if needed.

I've opted to place the code in the platformio "libs" folder, which makes it easy to conditionally include for ESP8266 builds via platformio.ini.

Fixes PWM crash issues issues described in #3962.

Vendor in the ESP8266 Arduino core PWM library, with a fix for a nasty
NMI crash bug.  Sometimes the NMI return instruction seems to fail,
resulting in an infinite loop as the PC gets stuck.  Work around this
by backing up and restoring the PC if needed.
@blazoncek
Copy link
Collaborator

@tablatronix @softhack007 @gaaat98 can you test this PR please?

@gaaat98
Copy link
Contributor

gaaat98 commented Jul 12, 2024

Hi! Sorry for the late reply but I was travelling. I did not do any stress test, but I can say that with the fix, the ESP8266 PWM light did not crash when UDP synced with an ESP32, even with the clock speed set to fastest. Before, it crashed in a few seconds, but now I was able to have it working for more than 10 minutes with sound reactive effects going! Thanks a lot for your great work and research effort!!

@blazoncek
Copy link
Collaborator

@softhack007 any second thoughts before merging?
@tablatronix were you able to do any testing?

Add additional clarification as to the original source URL and the
specific local patches.
Copy link
Collaborator

@softhack007 softhack007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 looks good for me, thanks

@blazoncek blazoncek merged commit bec1adf into Aircoookie:0_15 Jul 13, 2024
18 checks passed
@tablatronix
Copy link

I have not, my rgb lights are now in my pool, but I just got some small ones for bench testing. Will try to try to wire a tester up

@willmmiles willmmiles deleted the esp8266_pwm_fix branch July 14, 2024 15:39
softhack007 pushed a commit to MoonModules/WLED that referenced this pull request Aug 8, 2024
@Moonbase59
Copy link

FYI: This apparently also fixed my Athom 15W bulbs crashing every few seconds when controlled by LedFx. Installed WLED_0.15.0-b5_ESP02_160.bin.gz on these, and crashing problems are gone. Thanks!

willmmiles added a commit to willmmiles/WLED that referenced this pull request Sep 28, 2024
Use the phase-locked soft PWM from the Arduino core to implement the
same PWM phase management as ESP32s are using.  The soft PWM code is
vendored in, as it was previously, to add the NMI workaround from Aircoookie#4035.

Fixes Aircoookie#4148
willmmiles added a commit to willmmiles/WLED that referenced this pull request Sep 28, 2024
Use the phase-locked soft PWM from the Arduino core to implement the
same PWM phase management as ESP32s are using.  The soft PWM code is
vendored in, as it was previously, to add the NMI workaround from Aircoookie#4035.

Fixes Aircoookie#4148
willmmiles added a commit to willmmiles/WLED that referenced this pull request Sep 28, 2024
Use the phase-locked soft PWM from the Arduino core to implement the
same PWM phase management as ESP32s are using.  The soft PWM code is
vendored in, as it was previously, to add the NMI workaround from Aircoookie#4035.

Completes Aircoookie#4034
willmmiles added a commit to willmmiles/WLED that referenced this pull request Sep 29, 2024
Use the phase-locked soft PWM from the Arduino core to implement the
same PWM phase management as ESP32s are using.  The soft PWM code is
vendored in, as it was previously, to add the NMI workaround from Aircoookie#4035.

Completes Aircoookie#4034
willmmiles added a commit to willmmiles/WLED that referenced this pull request Sep 29, 2024
Use the phase-locked soft PWM from the Arduino core to implement the
same PWM phase management as ESP32s are using.  The soft PWM code is
vendored in, as it was previously, to add the NMI workaround from Aircoookie#4035.

Completes Aircoookie#4034
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants