-
Notifications
You must be signed in to change notification settings - Fork 7.6k
ESP32-S3 Hangs on boot when UART is printing #8377
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
Comments
I'm not sure what that issue brings to us, I use PlatformIO.
The software does work ok after setup() is succeeded to be called.
…On Mon, Jul 3, 2023, 19:04 Vladislav ***@***.***> wrote:
Now I did one "research
<#8374 (comment)>"
about resetting the microcontroller, and found the reason, this is the
installed core 0 in the arduino IDE.
Tell me, are you flashing the microcontroller through an arduino IDE?
What do you have selected in the board settings?
—
Reply to this email directly, view it on GitHub
<#8377 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH3O7J3CTLVNCBFKZAFQIPTXOLUQZANCNFSM6AAAAAAZ3PYC6Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Show me your compilation settings. |
I don't override any such configuration. And other than the exact situation
described OP, everything works as expected.
…On Mon, Jul 3, 2023, 20:05 Vladislav ***@***.***> wrote:
The software does work ok after setup() is succeeded to be called.
Show me your compilation settings.
Are you specifying which core 0 or core 1 to use?
—
Reply to this email directly, view it on GitHub
<#8377 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH3O7J5LJRP37UBJBAGLOR3XOL3VXANCNFSM6AAAAAAZ3PYC6Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I'm having the same issue. I'm using the following compilation settings |
Issue confirmed. Currently under analysis. |
After investigating this issue, I found out a few things. A few facts: 2- IDF UART driver needs FreeRTOS resources to be set in order to run correctly. 3- C++ constructors are executed before the I have tested the same sketch running direct IDF UART writing functions, and it fails in the same way: #include "driver/uart.h"
class dummy {
public:
dummy () {
Serial.begin(115200);
for(int i=0;i<200;i++) {
char c = '0';
uart_write_bytes(0, &c, 1);
delayMicroseconds(delayMs);
}
}
}; As a workaround, I used class dummy {
public:
dummy () {
for(int i=0;i<200;i++) {
printf("%d", i%10);
delayMicroseconds(delayMs);
}
printf("\nConstructor finished\n");
}
};
|
Thanks for the investigation.
But what can make printing at constructors succeeding in the older ESP32.
If I remember correctly, there was a similar issue regarding ESP32 that was
fixed by somehow. But couldn't find it.
…On Fri, Aug 18, 2023, 07:12 Rodrigo Garcia ***@***.***> wrote:
After investigating this issue, I found out a few things.
As conclusion, I see that it is due to the way how IDF UART API, used in
Arduino, works.
The IDF UART driver freezes, apparently, depending of the "timing" of its
execution.
It can't be fixed at this time.
A few facts:
1- The 1st stage boot loader will set the Watchdog Timer to reset the
ESP32-S3 after about 8 seconds.
This WDT resets the S3 with the message "rst:0x10 (RTCWDT_RTC_RST)"
2- IDF UART driver needs FreeRTOS resources to be set in order to run
correctly.
3- C++ constructors are executed before the main() function is executed.
This creates a problem because the IDF Driver can't run well and the
program ends up with potential "inconsistencies".
I have tested the same sketch running direct IDF UART writing functions,
and it fails in the same way:
#include "driver/uart.h"
class dummy {
public:
dummy () {
Serial.begin(115200);
for(int i=0;i<200;i++) {
char c = '0';
uart_write_bytes(0, &c, 1);
delayMicroseconds(delayMs);
}
}
};
As a workaround, I used printf() instead of Serial.printf() which uses
some ROM functions instead of IDF UART drivers.
So, in case it is necessary to print something in a C++ Constructor, this
is the way to do it.
class dummy {
public:
dummy () {
for(int i=0;i<200;i++) {
printf("%d", i%10);
delayMicroseconds(delayMs);
}
printf("\nConstructor finished\n");
}
};
—
Reply to this email directly, view it on GitHub
<#8377 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH3O7J5KSGTG7C5GK2BK3PDXV3TSXANCNFSM6AAAAAAZ3PYC6Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
What do you mean with "older ESP32"? I tested the issue with ESP32 + Core 2.0.11 and time = 1 us. |
If I remember it correctly, it was printing okay, then made workarounds to disable on the S3 recently. I'll re-check at soonest anyway. |
Use snippet shown below. Flush every time instead of delay. #include <Arduino.h>
int delayMs = 10;
class dummy {
public:
dummy () {
Serial.begin(115200);
while(!Serial);
for(int i=0;i<200;i++) {
Serial.printf("0",i);
Serial.flush();
}
}
};
dummy d;
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
while(!Serial);
Serial.printf("Hello World!\n");
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}``` |
Board
Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD)
Device Description
Official board by Espressif
Programming and powering by the UART port.
Hardware Configuration
Unconnected to any external peripherals.
Version
v2.0.9
IDE Name
PlatformIO
Operating System
Windows 11
Flash frequency
40MHz (Default one)
PSRAM enabled
yes
Upload speed
115200
Description
When data rushes to UART at application startup the MCU hangs.
This is observed in printing to UART within global constructors, wherein the Serial began in an earlier one.
This issue wasn't observed with normal ESP32.
The amount of data being successfully printed depends on the introduced delay (delayMs in the example sketch).
With no delay it printed ~155 Bytes, and with a delay of uS it printed ~182 Bytes, finally run with not problems when delay was 100uS.
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: