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

The ESP32 processor hangs on a second call to Serial.begin(115200) when compiled for ESP32 Dev Module. #5043

Closed
ZinggJM opened this issue Apr 11, 2021 · 15 comments · Fixed by #8634
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@ZinggJM
Copy link

ZinggJM commented Apr 11, 2021

// SerialBeginTwice test by Jean-Marc Zingg
//
// Purpose: test issue with ESP32 compiled for ESP32 Dev Module

void setup()
{
  Serial.begin(115200);
  delay(100);
  Serial.println("going to call Serial.begin(115200); a second time. Should tell success ...");
  delay(100);
  Serial.begin(115200);
  delay(100);
  Serial.println("... success, returned from second call to Serial.begin(115200); Bye and out.");
  delay(100);
}

void loop() {}

I verified this on a ESP32 Dev Module clone, on a Wemos LOLIN32 Lite, and on the Waveshare e-Paper ESP32 Driver Board.

The GxEPD2 examples call Serial.begin(115200) in setup() to Serial.print("setup"), and again in display.init(115200).

Related post in Arduino Forum Displays: https://forum.arduino.cc/index.php?topic=487007.msg4952538#msg4952538

@lbernstone
Copy link
Contributor

Please follow the ISSUE_TEMPLATE.

@ZinggJM
Copy link
Author

ZinggJM commented Apr 12, 2021

Never mind if you are not interested. All relevant information is there, can be verified easily.

OS: Windows 10 - not relevant
Arduino IDE: 1.8.13
package: actual
target: 3 mentioned - not relevant
Error message: none
expected behavior: see both lines in Serial Monitor
actual behavior: only first line, processor hangs.

@lbernstone
Copy link
Contributor

Can you please indicate what version of the code you are running?

@ZinggJM
Copy link
Author

ZinggJM commented Apr 12, 2021

1.0.6 - is this the version you mean?
C:\Users\ZinggJ\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\variants\esp32

@lbernstone
Copy link
Contributor

Well, there's an easy workaround. I'll put in a PR and see if someone with JTAG can figure out what is actually causing the hang.

@ZinggJM
Copy link
Author

ZinggJM commented Apr 12, 2021

I just repeated the test with ESP32-Wrover on LOLIN D32 PRO:
works when compiled for LOLIN D32 PRO
fails when compiled for ESP32 Wrover Module

@lbernstone
Copy link
Contributor

If you set core debugging to verbose it will work. This is a timing issue.

@ZinggJM
Copy link
Author

ZinggJM commented Apr 12, 2021

Ok, thank you, I will try. But how to explain this to users of my library?

@ZinggJM
Copy link
Author

ZinggJM commented Apr 12, 2021

Verbose didn't help, on LOLIN D32 PRO.

@ZinggJM
Copy link
Author

ZinggJM commented Apr 12, 2021

Thank you for the fast response. Glad the issue is verified and a solution is found.

me-no-dev pushed a commit that referenced this issue Apr 15, 2021
workaround for #5043. There is a timing issue with HardwareSerial::end. I'm not sure what is hung, but it should be possible to see this in jtag, as it does cause a reboot if you let it. The delay needs to be before you detach the device!?
@stale
Copy link

stale bot commented Jun 18, 2021

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Jun 18, 2021
@stale
Copy link

stale bot commented Jul 11, 2021

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Jul 11, 2021
@ZinggJM
Copy link
Author

ZinggJM commented Nov 21, 2021

This issue seems still to be present. See e.g. https://forum.arduino.cc/t/esp32-e-paper-display-upload-but-no-output/927375/3

@DriekdeGadgetfreak
Copy link

Here is the fix:.
In uartBegin the output buffer is flushed:
uartFlush(uart);
Change this to
uartFlushTxOnly(uart,false); // also flush the input buffer:

@ZinggJM
Copy link
Author

ZinggJM commented Aug 16, 2022

Maybe someone should make the old download link invalid, remove the version pointed to!
I still get issues reported by users of this outdated version.

See https://forum.arduino.cc/t/waveshare-e-paper-displays-with-spi/467865/3114

Jean-Marc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants