Skip to content

ESP32 1.0.5 not working with M5Stack lib. Serial.begin() with M5.begin() stops running the code #4948

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

Closed
PatKeel opened this issue Mar 15, 2021 · 5 comments
Assignees

Comments

@PatKeel
Copy link

PatKeel commented Mar 15, 2021

After updating esp32 board package from 1.0.4 to 1.0.5 my projects with M5Stack Core Gray and Black (Basic) did not work anymore. It compiles but did not came over setup into the loop.
Trying several combinations of installed libs i found one combination makes this issue: esp32 1.0.5! All other constellations worked for me.
If i comment the line with Serial.begin() it works and serial output works tough at 115200baud.
If i remove all M5 stuff (M5.Lcd) the Serial.begin() statement works.

Hardware:

Board: M5Stack Core GRAY and BASIC
IDE name: Arduino 1.8.13
Flash Frequency: 80Mhz
Upload Speed: 921600
Computer OS: Windows 10

`#include <M5Stack.h>

int i = 0;

void setup(void) {
Serial.begin(115200); // comment this line if installed esp32 lib 1.0.5!

M5.begin();
M5.Power.begin();
M5.Lcd.setCursor(10, 20, 4);
M5.Lcd.setTextColor(TFT_YELLOW);
M5.Lcd.setTextSize(1);
M5.Lcd.print("Hello World!");
delay(2000);
M5.Lcd.clear(TFT_BLACK);
}

void loop() {
M5.Lcd.setCursor(10, 20, 4);
M5.Lcd.fillRect(10, 20, 100, 19, TFT_BLACK);
M5.Lcd.println(i);

Serial.println(i);
i++;
delay(1000);
}`

Regards Patrick

@felmue
Copy link

felmue commented Mar 15, 2021

Hello @PatKeel

if you look into M5.begin() you'll see that there already is a Serial.begin() call.

  if (SerialEnable == true) {
    Serial.begin(115200);
    Serial.flush();
    delay(50);
    Serial.print("M5Stack initializing...");
  }

In my experience calling Serial.begin() twice is a bad idea and can lead to very strange errors.
Thanks
Felix

@PatKeel
Copy link
Author

PatKeel commented Mar 15, 2021

Thank you Felix

@PatKeel PatKeel closed this as completed Mar 15, 2021
@me-no-dev
Copy link
Member

I investigated this possible issue with multiple Serial.begin() and could not get the code to not run. What I do get is that the Serial is not immediately available for writing. Also some prints in between Serial.begin() calls could also get lost for some reason. I poked at registers, tried more complex Flush and all... Everything looked normal but prints were not coming through.

@felmue
Copy link

felmue commented Mar 15, 2021

Hello @me-no-dev

thank you for your feedback and taking the time to do extra tests. Much appreciated.

Cheers
Felix

@SuGlider
Copy link
Collaborator

Issue is solved with PR #5385 using version 2.0.0Alpha

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

4 participants