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

esp32: Disable hardware stack protection on ESP32-C6. #15997

Merged

Conversation

dpgeorge
Copy link
Member

Summary

The same as #15771 (see fee9d66) but for C6.

Fixes issue #15667.

Testing

Tested with ESP32_GENERIC_C6 firmware using the method described in #15667. Without this patch the device resets after a few minutes. With this patch it ran for 30 minutes without error (at which point I stopped it running).

The same as fee9d66 but for C6.

Fixes issue micropython#15667.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge
Copy link
Member Author

Note that this is done slightly differently to how it was done for the C3 in fee9d66 ; here I've created a sdkconfig.c6 file and included that in all C6 boards.

@dpgeorge dpgeorge requested a review from projectgus October 13, 2024 23:46
@mattytrentini
Copy link
Contributor

I'll try and re-test this tonight on the M5Stack NanoC6.

@projectgus projectgus linked an issue Oct 14, 2024 that may be closed by this pull request
Copy link
Contributor

@projectgus projectgus left a comment

Choose a reason for hiding this comment

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

LGTM. I still intend to try and get a reproducer together for the ESP-IDF issue at some point, but haven't yet.

@dpgeorge
Copy link
Member Author

@mattytrentini I will merge this now, but feel free to test it yourself if you like (it's a bit involved setting up the test, with mosquitto).

@dpgeorge dpgeorge merged commit 44ed1c2 into micropython:master Oct 14, 2024
8 checks passed
@dpgeorge dpgeorge deleted the esp32-c6-disable-hw-stack-guard branch October 14, 2024 23:13
@mattytrentini
Copy link
Contributor

I will merge this now, but feel free to test it yourself if you like (it's a bit involved setting up the test, with mosquitto).

Yes, I set up the test environment last night but hadn't frozen the test code. I had the same result as you; the problem doesn't occur when the test code is copied to, and executed from, the filesystem.

I ran out of time to reproduce the issue with frozen code but will do so today.

@mattytrentini
Copy link
Contributor

For future reference, in order to reproduce this issue and assuming you're using mosquitto as the MQTT broker, it's easiest to run mosquitto in the foreground, configured to allow anonymous connections from any IP address.

To do so, ensure you've stopped mosquitto running as a service. Create (or modify) a mosquitto.conf file to include the following options:

allow_anonymous true
listener 1883 0.0.0.0

Then run mosquitto, with this configuration and in verbose mode to see the message activity:

mosquitto -v -c mosquitto.conf

@mattytrentini
Copy link
Contributor

I was able to confirm that before this PR was merged a fatal error would occur after running for some time (typically 20sec to a minute or so). After updating to include this PR, the issue seems resolved.

Here's an example of the error output:

A fatal error occurred. The crash dump printed below may be used to help
determine what caused it. If you are not already running the most recent
version of MicroPython, consider upgrading. New versions often fix bugs.

To learn more about how to debug and/or report this crash visit the wiki
page at: https://github.com/micropython/micropython/wiki/ESP32-debugging

MPY version : v1.24.0-preview.409.g82e69df33e.dirty on 2024-10-15
IDF version : v5.2.2
Machine     : M5Stack NanoC6 with ESP32C6

Guru Meditation Error: Core  0 panic'ed (Stack protection fault).

Detected in task "mp_task" at 0x4200e350
Stack pointer: 0x4082a830
Stack bounds: 0x40826be8 - 0x4082abe0


Core  0 register dump:
MEPC    : 0x408039fe  RA      : 0x420199fa  SP      : 0x4082a830  GP      : 0x40818de4
TP      : 0x407eb28c  T0      : 0x40030dca  T1      : 0x40813070  T2      : 0x0000003f
S0/FP   : 0x4082e400  S1      : 0x4082e450  A0      : 0x4219d998  A1      : 0x4219d998
A2      : 0x00000000  A3      : 0x40834600  A4      : 0x40834600  A5      : 0x4082a920
A6      : 0x00000002  A7      : 0x421a8824  S2      : 0x421a03d0  S3      : 0x408345f0
S4      : 0x00000001  S5      : 0x4219e000  S6      : 0x00000068  S7      : 0x4219dc58
S8      : 0x0000001b  S9      : 0x4219e000  S10     : 0x421a847d  S11     : 0x421a821a
T3      : 0x00000000  T4      : 0x000051a6  T5      : 0x00000003  T6      : 0x00000001
MSTATUS : 0x00001881  MTVEC   : 0x40800001  MCAUSE  : 0x0000001b  MTVAL   : 0xb86080e7
MHARTID : 0x00000000

Stack memory:
4082a830: 0x4081c704 0x4082e44c 0x00000267 0x00000000 0x00000004 0x4082e450 0x00000018 0x4081c000
4082a850: 0x4082a920 0x408345f0 0x40803a7c 0x4082e400 0x4082e450 0x421a03d0 0x40833ff0 0x00000001
4082a870: 0x00000062 0x00000068 0x4219dc58 0x0000001b 0x4219e000 0x421a847d 0x421a821a 0x4082a830
4082a890: 0x00000001 0x4082c840 0x4082a900 0x421a83f8 0x421a8400 0x4219e000 0x00000068 0x00000054
4082a8b0: 0x4082e400 0x0000000f 0x4082a9b8 0x00000000 0x00000001 0x4082c840 0x4082a900 0x42011ece
4082a8d0: 0x00000068 0x421a81e4 0x421a8401 0x4219dc58 0x00000068 0x421a81e4 0x4082a9b4 0x00000000
4082a8f0: 0x421a03d0 0x4082a9c4 0x4082a9a0 0x408040c2 0x4081c704 0x4082a9c0 0x00000006 0x00000000
4082a910: 0x4082c974 0x4082a9b8 0x00000020 0x00000000 0x4082aa20 0x00000006 0x408039b8 0x4082a9a0
4082a930: 0x4082a9c4 0x421a03d0 0x00000000 0x00000020 0x00000004 0x00000068 0x4219dc58 0x4081c000
4082a950: 0x4219e000 0x4082c98c 0x4082c967 0x4082a900 0x4082aab4 0x0000000f 0x4082cf30 0x4082c967
4082a970: 0x4082c98c 0x4219e000 0x00000030 0x00000000 0x4082a9a0 0x00000004 0x4082aabc 0x00000000
4082a990: 0x00000001 0x4082c840 0x4082aa00 0x42011ece 0x4082cec0 0x421a83ff 0x4082a9b0 0x00000004
4082a9b0: 0x4081c760 0x4082cc10 0x4082e290 0x4082d530 0x4082d530 0x4082c7d0 0x4082aa00 0x42011e22
4082a9d0: 0x00000000 0x00000000 0x4082c98d 0x4219dc58 0x00000068 0x4082c9c0 0x4082aab4 0x00000000
4082a9f0: 0x421a03d0 0x4082aac4 0x4082aaa0 0x4080400e 0x4081c704 0x4082aac0 0x000001dc 0x00000000
4082aa10: 0x4082ba74 0x4082aab8 0x00000009 0x0000000a 0x4082ab20 0x421a9bac 0x408039b8 0x4082aaa0
4082aa30: 0x4082aac4 0x421a03d0 0x00000000 0x00000020 0x00000004 0x00000068 0x4219dc58 0x4081c000
4082aa50: 0x4219e000 0x42181000 0x42181000 0x4082aa00 0x421ab580 0x7fffffff 0x0000208b 0x42181000
4082aa70: 0x42181000 0x42181000 0x00000030 0x00000000 0x4082aaa0 0x00000004 0x00000000 0x00000000
4082aa90: 0x00000000 0x4081c760 0x4082ab00 0x42011ece 0x4082c780 0x4082c98b 0x4082aab0 0x00000004
4082aab0: 0x4081c760 0x4082cec0 0x00000000 0x4082d530 0x00002eda 0x42181404 0x4082ab00 0x42011e22
4082aad0: 0x4082c910 0x42181000 0x4083ba74 0x00003c00 0x4082ba74 0x42008000 0x4081c704 0x00000001
4082aaf0: 0x00000001 0x4082c780 0x00000020 0x4202d152 0x00000000 0x00000000 0x00000000 0x00000000
4082ab10: 0x00000000 0x00000000 0x4082cf30 0x00000000 0x00000000 0x00000000 0x4202d0cc 0x00000020
4082ab30: 0x42181404 0x00000001 0x00000001 0x4081c704 0x42008000 0x4082ba74 0x00003c00 0x4083ba74
4082ab50: 0x42181000 0x42181000 0x42181000 0x4082ab00 0x40822000 0x4082ab70 0x40822000 0x42008968
4082ab70: 0x00000000 0x00000000 0x00000000 0x4082ab70 0x00000000 0x00000000 0x00000000 0x00000000
4082ab90: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4082abb0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4082abd0: 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0x00000158 0x4082a780
4082abf0: 0x00000119 0x4081bc8c 0x4081bc8c 0x4082abec 0x4081bc84 0x00000018 0x00000000 0x00000000
4082ac10: 0x4082abec 0x00000000 0x00000001 0x40826be8 0x745f706d 0x006b7361 0x00000000 0x00000000

(dirty since 82e69df was modified to freeze the test code.)

After updating (to 838f212) and rebuilding, the issue has not yet occurred.

@dpgeorge
Copy link
Member Author

Thanks @mattytrentini for your testing. That confirms also what I saw, which is good!

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