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

[BUG]WebSocketServer crash on ESP32-C6 #907

Closed
luc-github opened this issue Aug 31, 2024 · 3 comments
Closed

[BUG]WebSocketServer crash on ESP32-C6 #907

luc-github opened this issue Aug 31, 2024 · 3 comments

Comments

@luc-github
Copy link
Contributor

Hello Markus,
I hope you are ok - I am using your library (mainly WebSocketServer) on my project for years now, and it is working well on ESP8266, ESP8285, ESP32, ESP32-Pico,ESP32-S2, ESP32-S3, ESP32C3, great library.
Unfortunatly the WebSocketServer crash on ESP32-C6, I am just starting the porting.

I digged in the issue using your example: https://github.com/Links2004/arduinoWebSockets/blob/master/examples/esp32/WebSocketServer/WebSocketServer.ino
and found that line is the root cause on C6:
https://github.com/Links2004/arduinoWebSockets/blob/master/src/WebSocketsServer.cpp#L92

it seems ESP32-C6 really does not like :

#define DR_REG_RNG_BASE 0x3ff75144
    randomSeed(READ_PERI_REG(DR_REG_RNG_BASE));

replacing it by the default :

randomSeed(millis());

Solve the crash issue, I did not do a PR because I am not sure this is the solution you want, or you want to screen C6 only for it, etc...
So I just share my finding - hope it help

@Links2004
Copy link
Owner

Links2004 commented Sep 3, 2024

makes sense the address is diffrent for the C6, but espressif has added a define for get the correct address:

https://github.com/espressif/esp-idf/blob/6673376297b921d438790d195014b860eaf8bb17/components/soc/esp32c6/include/soc/wdev_reg.h#L13

can you test:

#ifdef ESP8266
    randomSeed(RANDOM_REG32);
#elif defined(ESP32) && defined(WDEV_RND_REG)
    randomSeed(REG_READ(WDEV_RND_REG));
#elif defined(ESP32)
#define DR_REG_RNG_BASE 0x3ff75144
    randomSeed(READ_PERI_REG(DR_REG_RNG_BASE));
#elif defined(ARDUINO_ARCH_RP2040)
    randomSeed(rp2040.hwrand32());
#else
    // TODO find better seed
    randomSeed(millis());
#endif

this may require to add a include to soc/wdev_reg.h

@luc-github
Copy link
Contributor Author

luc-github commented Sep 6, 2024

I have tested the changes with success on : ESP32 / ESP32-C3 / ESP32-C6 / ESP32-S2 / ESP32-S3
Using pioarduino 51.03.04 (platformio for esp32 arduino core 3.0.4 )
and for the header :

#if defined __has_include
#if __has_include("soc/wdev_reg.h")
#include "soc/wdev_reg.h"
#endif  // __has_include
#endif  // defined __has_include

and no issue so far ^_^, so looks good - thank you

@Links2004
Copy link
Owner

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

No branches or pull requests

2 participants