Skip to content

esp32: Disable hardware stack protection on ESP32-C3. #15771

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

Merged

Conversation

projectgus
Copy link
Contributor

@projectgus projectgus commented Sep 3, 2024

Summary

Closes #15667. Really a workaround for what appears to be an upstream issue: espressif/esp-idf#14456 - if we find the root cause then we can revert this.

Testing

  • Ran the reproducer code from the linked issue, verified no longer crashes. Issue reporter has also reported that disabling hardware stack protector avoids the crash.
  • Verified MicroPython still builds on v5.0.4 even with the non-existent new config item.

Trade-offs and Alternatives

  • Could wait for a fix, but even if this turns out to be an MP issue the hardware stack protector feature was only recently enabled in ESP-IDF so we're otherwise no worse off.

@projectgus
Copy link
Contributor Author

Re-enables the stack protector watchpoint which was the ESP-IDF default before stack protector was enabled (and still the default for Xtensa CPUs).

Oh, this wasn't actually the default there was just a bug that enabled it - espressif/esp-idf#10414 😆

Will take it out from here for now, then.

@projectgus projectgus force-pushed the bugfix/esp32c3_stack_protector branch from 1ee9d1c to 7f7cd2d Compare September 3, 2024 06:35
Workaround for what appears to be an upstream issue:
espressif/esp-idf#14456

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
@dpgeorge dpgeorge force-pushed the bugfix/esp32c3_stack_protector branch from 7f7cd2d to fee9d66 Compare September 4, 2024 05:16
@dpgeorge dpgeorge merged commit fee9d66 into micropython:master Sep 4, 2024
8 checks passed
@dpgeorge
Copy link
Member

dpgeorge commented Sep 4, 2024

Thanks!

@dhalbert
Copy link
Contributor

dhalbert commented Oct 23, 2024

Thank you for diagnosing this. We ran into what seems like the same problem in CircuitPython: adafruit#9749 (see a simple test program there), and fixed it by disabling the stack guard as you did.

@dhalbert
Copy link
Contributor

CONFIG_ESP_SYSTEM_HW_STACK_GUARD is enabled when SOC_ASSIST_DEBUG_SUPPORTED is defined, which is true for ESP32-C2, C3, C6, P4, and will eventually be true for C5 and C61, according to comments in ESP-IDF. So we decided to turn it off for all relevant builds.

@projectgus
Copy link
Contributor Author

Thanks for the heads-up, @dhalbert! Good point to turn it off more broadly.

Your reproducer case is simpler, so might get as closer to a reproducer for upstream.

@projectgus projectgus deleted the bugfix/esp32c3_stack_protector branch October 29, 2024 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESP32C3 and C6: Stack protection fault on IDF 5.2.2
3 participants