Visual Micro
https://www.visualmicro.com/forums/YaBB.pl
Visual Micro >> Usb/Serial/WiFi Debugging >> ESP32 serial debug - output stops, but works OK in Arduino IDE
https://www.visualmicro.com/forums/YaBB.pl?num=1621763199

Message started by chris52 on May 23rd, 2021 at 10:46am

Title: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by chris52 on May 23rd, 2021 at 10:46am
I have just acquired an ESP32 module (Lilygo-T-Call-SIM800) and trying it with a simple HTTP example. Works fine in the Arduino IDE but in VM the program appears to load correctly but then the serial output halts (before the program runs).
I get this reported on the serial monitor:
[code]rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:10944
load:0x40080400,len:6388
entry 0x400806b4
Opening port
Port open
[/code]
then nothing.
(Just to be sure, I went back to an old project with a UNO and get correct serial output with that in VM).

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by Simon@Visual Micro on May 24th, 2021 at 9:17am
Thanks for the report. 

So we can understand the environment, please attach the full output from the build with the Verbose and Show Build Properties enabled, as shown at the top of this page.

Just to note if Serial Debug is enabled, this may be automatically setting a breakpoint at the top of loop() where the execution will stop until you press continue in the IDE.

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by chris52 on May 24th, 2021 at 9:36pm
Build file attached. There were no breakpoints. If I try to add one (in first line of Setup()) I get this message:

Quote:
User Experience : The serial debugger was delayed waiting for an incoming line of data.If the Serial.print() command is used between breakpoints, then ensure that a line termnator is sent using.println() or .print("\r\n").Optionally, use #if defined(VM_DEBUG)to add code that is only active when debugging. (if this is expected then switch this user experience message off in tools > options > visual micro > micro debug)

All my print commands are println(). So maybe the program is stopping somewhere in the Cstartup section?
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=esp32-http-build.txt (220 KB | 5 )

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by chris52 on May 27th, 2021 at 12:17pm
Anybody?? I cannot make any programs* run under VM, they all work with the Arduino IDE. Using Lilygo-T-Call-SIM800. Build file attached to my previous message.
*even just an empty setup() and loop() with a single serial println().

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by Simon@Visual Micro on May 27th, 2021 at 12:28pm
If you disable the Serial debugger, by changing to the Build Configuration: "Release " do you still have the same issue?

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by chris52 on May 27th, 2021 at 3:38pm
Same result in release mode. But - discovery - if I remove all the serial commands, and just do this:
Code (c++):
void setup() {
pinMode(13, OUTPUT);
}

void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}

then the program runs (and I can add working breakpoints). So a workaround will be to remove (or #define out somehow) all the 'normal' serial commands from the examples I'm trying, and just use VM's debugger.

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by Simon@Visual Micro on May 27th, 2021 at 4:00pm
Understood, apologies I expected the Release mode to disable the serial debugger.

Depending on the complexity of your serial code, you can use your own Serial code at the same time as the Serial debugger on the same port, noting the information on the below page regarding String only data, Serial.Read() and baud rate alignment:
https://www.visualmicro.com/page/User-Guide.aspx?doc=Debugging.html#vmd7

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by chris52 on May 27th, 2021 at 5:24pm
Hmmm. All the baud rates are the same, and I'm not using serial.read().
[code]void setup() {
  Serial.begin(115200);
}
void loop() {
  Serial.println("test");
}[/code]
This fails to output anything, whether in debug or release mode. I could try OTA debugging, I suppose. I will need to see a stream of serial data from the device though, in real time, rather than just adding breakpoints.

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by Tim@Visual Micro on May 27th, 2021 at 8:36pm
It's possible you have the wrong usb driver installed. The one marked for windows universal has a bug in it when the serial is accessed via C#. The one for windows 8 is actually also for windows 10. Which usb driver date/ver are you using?

We have reported it. Arduino IDE uses java so is immune fro this issue.

See the top of this page for more info https://www.visualmicro.com/page/How-to-install-Esp32-for-Arduino-and-Visual-Micro.aspx


Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by chris52 on May 27th, 2021 at 10:33pm
So, I changed USB driver to ver 6 (it was ver 10) but no effect.
Then I installed everything fresh on my laptop. The USB driver here is also ver 6 (though I didn't have to change it). Same board manager files (espressif/arduino-esp32) and the serial output worked - after a fashion - once.  Next run , I get the same result as on the desktop, i.e. a simple LED blink program does not run if serial.begin() is used in setup().
So how/why did it run just once? Still runs fine in Arduino IDE!

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by Tim@Visual Micro on May 27th, 2021 at 10:39pm
Can we see another build output so the settings you have are clear. It should work same as the Uno without a hitch. There are a lot of ESP32 users of Visual Micro so it will be interesting to see the settings now.

Please give build output when release is selected and optimization has not been disabled.

If you want to save some time the verbose output from same sketch in the Arduino IDE will allow us to compare the selected board settings.

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by chris52 on May 28th, 2021 at 8:34am
Ok, attached two new builds. The Arduino one doesn't seem very verbose though.
I'm away now until Tuesday so no rush!
Thanks
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=esp-32-build-VM.txt (84 KB | 7 )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=esp-32-build-arduino.txt (32 KB | 5 )

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by Tim@Visual Micro on May 28th, 2021 at 5:55pm
Thanks. Arduino don't put the build properties in the verbose output but same can be decuded from the actual build commands.

Is it possible the DTR or RTS on the serial window have been enabled? Can you confirm they are off? For esp32 boards, they should automatucally be off unless switched on manually. They have different effect than for AVR and should be avoided for ESp32

Can you show screen shot of serial monitor please.

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by chris52 on May 31st, 2021 at 9:23pm
Screen shot attached. RTS and DTR both off (I also tried with them on!)
Today (after leaving everything switched off for nearly 4 days) I ran the programs again (on my desktop)  and they worked fine first time! A couple of times. Then they stopped as before. I also tried swapping to another ESP32 module (identical to the first) - same problem. And this one also works fine with the Arduino IDE.
So, the issue is definitely intermittent (both laptop and desktop work for a while than stop).
I note that a  new release is available - should I try that or will that cloud the issue?
Screenshot-vm.png (9 KB | 1 )

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by Tim@Visual Micro on Jun 1st, 2021 at 12:25am
Thanks for the info. The Serial system hasn't changed for a long time and is very widely used. This type of problem would have been reported by others so we need to look at your outputs and see tool chain versions, board then replicate.

It might take a few days, sorry about that. Can you please give update as to if you still see the errors appear in the serial monitor or is it just that the serial stops?



Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by chris52 on Jun 1st, 2021 at 10:58am
It's not just that the serial stops, the program doesn't run at all. (Current test program below).

  • When the problem occurs, restarting VS doesn't help.
  • When the problem occurs, the serial output stops AND the LEDs stop flashing - so the program just isn't running.
  • When it has occurred, removing the Serial commands and reloading makes the LEDS flash again.
  • Restarting Windows makes everything work again (for a while).
  • Sometimes I get "VMDPR_" appearing in the output window, but I think that was only when there were no serial commands.
  • I can't make the serial output work at all on my laptop now; it did work once however.

[code]void setup() {
    Serial.begin(115200);
    pinMode(13, OUTPUT);
}

void loop() {
     Serial.println("led on");
     digitalWrite(13, HIGH);
     delay(1000);
     Serial.println("off");
     digitalWrite(13, LOW);
     delay(1000);
}[/code]

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by Tim@Visual Micro on Jun 1st, 2021 at 4:13pm
Thanks. The cpu is crashing, it is not related to serial. The build commands we are using are the same as the ones the Arduino IDE is using.

When the serial debugger is enabled there can sometimes be broken debug reporting packets. This is especially the case if the debugger "Auto reports" has been enabled. The broken report packets will appear as "VMDPR_" in the serial monitor but cause no issue. It however an indication that the board struggles with high rates of serial.

The only thing left to check is that the same code is being found during compile. To do this you need to click "Build>Clean Solution". This will zap the cache for the core so the next build will show the core being built.

Please post a verbose output with debug Off after "cleaning the solution" and also post or email a zip with this file that is created during the build

[code]C:\Users\quilk\AppData\Local\Temp\VMBuilds\esp-32-blink\esp32_ttgo-t7-v13-mini32\Release\esp-32-blink.cpp[/code]

Thanks

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by chris52 on Jun 2nd, 2021 at 9:36pm
Here's the cpp file:
[code]#include <arduino.h>
#line 1 "C:\\Users\\quilk\\Documents\\Arduino\\esp-32-blink\\esp-32-blink.ino"
#line 1 "C:\\Users\\quilk\\Documents\\Arduino\\esp-32-blink\\esp-32-blink.ino"

//
//

#line 2 "C:\\Users\\quilk\\Documents\\Arduino\\esp-32-blink\\esp-32-blink.ino"
void setup() {

     Serial.begin(115200);
    pinMode(13, OUTPUT);
}

void loop() {
     Serial.println("led on");
     digitalWrite(13, HIGH);
     delay(1000);
     Serial.println("off");
     digitalWrite(13, LOW);
     delay(1000);
}
[/code]
and the cleaned build file is attached.
I've now also come across a different issue that shows in VM but not in Arduino, but I will investigate/post in the relevant section.
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=esp-32-cleanbuild-VM.txt (85 KB | 2 )

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by Tim@Visual Micro on Jun 2nd, 2021 at 10:10pm
Thanks

Please try the .4 release if you get a mo. We will be doing some more testing later today but interested to know if this resolves.

https://www.visualmicro.com/forums/YaBB.pl?board=VS_ARDUINO_EXT_RELEASES

Title: Re: ESP32 serial debug - output stops, but works OK in Arduino IDE
Post by chris52 on Jun 3rd, 2021 at 5:04pm
Tim, I uploaded 2021.527.0 first, and that seems to have solved the problem, on both laptop and desktop - I can now run in debug mode on both  :)
Version before on desktop was 2021.106.1, on laptop I think it was 106.18.
Other issue with incorrect intellisense is still there, I will post separately about that.

Visual Micro » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2021. All Rights Reserved.