Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Pages: 1 
Send Topic Print
Error when building with avr_gdb library (Read 1839 times)
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Error when building with avr_gdb library
Dec 19th, 2019 at 8:23pm
 
I'm back. I got Traffic_Light to work in debug. When I include avr_dbg in my sketch, I get the avr_ errors (I've attached a screen shot of includes & setup and a verbose log)

Thanks
Abbott

Back to top
« Last Edit: Dec 19th, 2019 at 8:29pm by Visual Micro »  

Capture_019.PNG (161 KB | )
Capture_019.PNG
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr-gdb library
Reply #1 - Dec 19th, 2019 at 8:30pm
 
It is possible the interrupts code in your project conflicts with the interrupts used by the avr-gdb library.

Please try the GDBStub in a simple project to prove it is working for you.

Thanks
Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #2 - Dec 20th, 2019 at 4:53pm
 
It works with Traffic_Light, although it throws an "Exception Unhandled" at the end of setup and then continues properly.
When I comment out the interrput related code, this is what I get - see screen and log.
Thanks
Abbott
Back to top
 

Capture_020.PNG (124 KB | )
Capture_020.PNG
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #3 - Dec 20th, 2019 at 4:54pm
 
Here's the Traffic_Light error ...
Abbott
Back to top
 

Capture2_004.PNG (120 KB | )
Capture2_004.PNG
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #4 - Dec 28th, 2019 at 2:15am
 
The full Maple Sap Pump project can be found at:
https://github.com/AbbottHMG/AduinoSolutions

The VS compile of my full project yields the errors in the attached png.
When I compile the sketch in the Arduino IDE the only  errors I get  are avg related:

Arduino: 1.8.10 Hourly Build 2019/04/02 05:33 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Code:
In file included from C:\Users\Abbott\Documents\Arduino\hardware\arduino\avr\cores\arduino/USBAPI.h:27:0,

                 from C:\Users\Abbott\Documents\Arduino\hardware\arduino\avr\cores\arduino/arduino.h:233,

                 from sketch\FlowMeter.h:7,

                 from sketch\FlowMeter.cpp:6:

c:\program files (x86)\arduinoide\hardware\tools\avr\avr\include\util\delay.h:112:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" [-Wcpp]

 # warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"

   ^

In file included from C:\Users\Abbott\Documents\Arduino\hardware\arduino\avr\cores\arduino/USBAPI.h:27:0,

                 from C:\Users\Abbott\Documents\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:233,

                 from sketch\MaplePump.ino.cpp:1:

c:\program files (x86)\arduinoide\hardware\tools\avr\avr\include\util\delay.h:112:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" [-Wcpp]

 # warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"

   ^

In file included from C:\Users\Abbott\Documents\Arduino\libraries\WiFi\src/WiFiServer.h:24:0,

                 from sketch\WebServer.h:17,

                 from C:\Users\Abbott\Documents\Arduino\Solutions\MaplePump\MaplePump.ino:36:

C:\Users\Abbott\Documents\Arduino\libraries\WiFi\src/utility/wl_definitions.h:42:0: warning: "MAX_SOCK_NUM" redefined

 #define MAX_SOCK_NUM  4

 ^

In file included from sketch\WebServer.h:12:0,

                 from C:\Users\Abbott\Documents\Arduino\Solutions\MaplePump\MaplePump.ino:36:

C:\Users\Abbott\Documents\Arduino\libraries\Ethernet\src/Ethernet.h:39:0: note: this is the location of the previous definition

 #define MAX_SOCK_NUM 8

 ^

HardwareSerial0.cpp.o (symbol from plugin): In function `__vector_25':

(.text+0x0): multiple definition of `__vector_25'

libraries\avr-debugger\avr8-stub.c.o (symbol from plugin):(.text+0x0): first defined here

c:/program files (x86)/arduinoide/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions

WInterrupts.c.o (symbol from plugin): In function `attachInterrupt':

(.text+0x0): multiple definition of `__vector_1'

libraries\avr-debugger\avr8-stub.c.o (symbol from plugin):(.text+0x0): first defined here

C:\Users\Abbott\AppData\Local\Temp\ccniHOKR.ltrans19.ltrans.o: In function `save_regs1':

C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'

C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'

C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'

C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'

C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'

C:\Users\Abbott\AppData\Local\Temp\ccniHOKR.ltrans19.ltrans.o:C:\Users\Abbott\Documents\Arduino\libraries\avr-debugger\src/avr8-stub.c:2043: more undefined references to `regs' follow

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "SD.h"
 Used: C:\Users\Abbott\Documents\Arduino\libraries\SD
 Not used: C:\Program Files (x86)\ArduinoIDE\libraries\SD
Multiple libraries were found for "Ethernet.h"
 Used: C:\Users\Abbott\Documents\Arduino\libraries\Ethernet
 Not used: C:\Program Files (x86)\ArduinoIDE\libraries\Ethernet
Multiple libraries were found for "WiFiUdp.h"
 Used: C:\Users\Abbott\Documents\Arduino\libraries\WiFi
 Not used: C:\Program Files (x86)\ArduinoIDE\libraries\WiFi
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
 

Back to top
« Last Edit: Dec 28th, 2019 at 1:14pm by Visual Micro »  

AbgErrors.PNG (19 KB | )
AbgErrors.PNG
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #5 - Dec 28th, 2019 at 1:15pm
 
Sorry we don't have time to assist with standard code syntax issues in this forum. Please use stackoverflow or the arduino forum where you will find the relevant experts.

Back to top
« Last Edit: Dec 28th, 2019 at 1:15pm by Visual Micro »  
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #6 - Dec 29th, 2019 at 12:27am
 
There are no syntax errors. Without the avr debugger, included the application compiles clean and uploads. With the avr debugger included, the only errors are :
libraries\avr-debugger\src/avr8-stub.c:1946: undefined reference to `regs'
Who's responsible for avr-debugger issues?
Abbott
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #7 - Dec 29th, 2019 at 1:35am
 
Reading the error again it appears to be saying that some sources can not work with optimization disabled. Is there any reason why you have disabled optimization? Was it based on a blog or expert advice? If so please post a link.

Thanks

ps: the lib is on git.
Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #8 - Jan 2nd, 2020 at 1:22am
 
I set Default Optimization and for the .ino - Maximum Optimization (Favor Size) (/O1).
The avr8-stub.c regs errors still appear. I've attached the verbose log and screen image.
Thanks for continued follow-up.
Abbott
Back to top
 
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 179
Re: Error when building with avr_gdb library
Reply #9 - Jan 2nd, 2020 at 11:46am
 
Would it be possible to post or email us the solution as you have it currently on your machine, so we can investigate further more easily?

Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #10 - Jan 2nd, 2020 at 9:27pm
 
You can find it at:
https://github.com/AbbottHMG/AduinoSolutions
If not, I'll zip it up and send it to you.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #11 - Jan 2nd, 2020 at 9:36pm
 
Thanks, if it is the MaplePump it looks like it is missing the .vcxproj files(s)

The GDbStub does not allow serial and does hog timer(s) so it might be a clash of libs. True hardware debug would then be the answer for lib debugging.

Anyway the vcxproj will allow is to replicate and possibly recommend workaround.
Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #12 - Jan 3rd, 2020 at 11:48pm
 
Are these sufficient?
Also, I've disabled my timed interrupts. Should I also stub out the RTC Class?

Abbott
Back to top
« Last Edit: Jan 4th, 2020 at 1:44pm by Abbott HMG »  

vcxproj.zip (7 KB | )
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 179
Re: Error when building with avr_gdb library
Reply #13 - Jan 6th, 2020 at 12:59pm
 
Thanks for the Project files.

Performing the following steps allowed us to get the debugging running on the ATMega 2560 with GDBStub and the MaplePump project, but as the remaining hardware isn't connected we could only get into the LCD init...

The steps we took were:
Pulling the Git Repo, and merging the additional VCXProj files
Open SLN in Visual Micro (note missing files)
Ensure Deep Search Enabled
Remove references in Solution to the missing files noted on startup
Set board, Hardware Debug, GDB Stub options
Comment out all Serial and Interrupt code
Add AVR GDB Stub Library Reference in MaplePump.ino
Add debug_init(); to top of setup()
Add breakpoint as early as needed (above LCDInit() for our purposes)
Build & Upload, then Attach to process

As our breakpoint is so early and we attached it after startup, we had to reset the board after attaching the debugger to land on the breakpoint.
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #14 - Jan 6th, 2020 at 7:24pm
 
Thanks.
I'll be working on this tonight & tomorrow am.
You've been lots of help.

Some notes ...
I still get the undefined references to regs, even though they are defined static within the avr8-stub.c at line 550 Code (C++):
static unsigned char regs[GDB_NUMREGBYTES];	/* Copy of all registers */
 


and used throughout avr8-stub.c

except at line 1946 in:

Code (C++):
/* Note: The save and restore functions must be always inline,
 otherwise the debug version will call these functions and
 destroy the stack; The functions assume the stack is not touched.
 */
__attribute__((always_inline))
static inline void save_regs1 (void)
{
	/*  20-6-2017
	 Nova verze, dle gdb.c co nejdrive zakazat preruseni */
	asm volatile (
				"push	r0	\n"
				"in		r0, __SREG__ \n"
				"cli	\n"			/* disable interrupts */
				"sts regs+32, r0\n"	/* save SREG to its place */
				"pop r0 \n"		/* restore r0 from stack */
				"sts	regs+31, r31\n"		/* save R31 */
				"sts	regs+30, r30\n"		/* save R30 */
				"ldi	r31, hi8(regs)\n"	/* Z points to regs */
				"ldi	r30, lo8(regs)\n"
				"std	Z+29, r29\n");		/* save R29 */
				/*"in	r29, __SREG__\n");*/	/* get SREG */

	/* Original verze, nebezpecna pokud se vola bez zakazanych preruseni, protoze
	  ISR muze poskodit obsah registru r31, r30...
	  Pro pouziti v ISR to neni problem, preruseni jsou zazakana ale pro breakpoint() by
	  to mohlo delat problemy... */
#if 0
	asm volatile (
	"sts	regs+31, r31\n"		/* save R31 */
	"sts	regs+30, r30\n"		/* save R30 */
	"ldi	r31, hi8(regs)\n"	/* Z points to regs */
	"ldi	r30, lo8(regs)\n"
	"std	Z+29, r29\n"		/* save R29 */
	"in	r29, __SREG__\n");	/* get SREG */
#endif
} 



As per your notes ...
I have no missing files in my solution
How do I enable Deep Search?
I've commented out all Serial references
When you refer to AVR GB Stub you mean avr8-stub..h

I've attached a zip of my entire solution

Abbott
Back to top
« Last Edit: Jan 7th, 2020 at 2:34am by Abbott HMG »  

VacuumPump_001.zip (Attachment deleted)
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 179
Re: Error when building with avr_gdb library
Reply #15 - Jan 7th, 2020 at 10:50am
 
Thanks for the solution, and running it on my machine I don't see the same errors related to regs, and it is the correct GDB Stub we suggest.

The missing files were likely just on the version on git so a red-herring.

Deep Search was just to ensure the SPI Library is found correctly, and is enabled from vMicro > Compiler > Deep Search For Libraries.

Trying to build this for GDBStub still showed there is interrupt code active in the FlowMeter.cpp file, and once these are commented out (just attach and detach interrupt lines) the project builds without error.

As the GDBStub is embedded in the project we are definitely using the same one and same VS.

Just a note - If you change the Error List to be just "Build" instead of "Build + Intellisense" it will hide all non-critical errors.
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #16 - Jan 7th, 2020 at 8:26pm
 
Let me start by saying that I think there are gremlins in my DELL Precision.

Thanks. When I disabled the flowmeter attachInterrupt, the solution clean compiled, no errors, but the link failed. When I compiled again, the regs errors popped up. (I noticed an attachInterrupt in SPI.h). I compiled again after removing & adding back all libraries & classes using interrupts and got a clean compile...but no Link.
I've attached the verbose output of my last compile.
Might the Mega2560 board (ELEGOO) have any effect on the linking???

An aside: Has anyone built some scaffolding that would ignore attachInterrupt/detachInterrupt, etc. and Serial calls when in AVR-GDB debug mode. That would eliminate this type of stupid (me) user error and reduce commenting out lines.

Abbott
Back to top
« Last Edit: Jan 7th, 2020 at 10:45pm by Abbott HMG »  

 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 179
Re: Error when building with avr_gdb library
Reply #17 - Jan 7th, 2020 at 8:59pm
 
Glad to hear its moving forwards for you now.

There is a project option in Visual Micro for just this:
Project Properties (highlight project in Solution Explorer, Press F4)
"Micro General Current Configuration" section > "Configuration Define _DEBUG"
Set this to 1

Now in your code you can check for the _DEBUG definitions presence (or value), which will not be present when in Release Mode:
Code:
// Only AttachInterrupt if not in Debug Configuration
#ifndef _DEBUG 
    attachInterrupt();
#endif   



Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #18 - Jan 8th, 2020 at 1:10pm
 
Thanks ...
But the project still does not link, so I can not debug it.
I've attached the full project and my libraries directory. The  original verbose log is in in my prior response.
What's worse is that when I recompile, the reg errors pop up again.
If I do a Build->Clean the regs errors disappear????

The new verbose with reg errors is also attached.

Abbott Embarrassed Embarrassed Embarrassed
Abbott
Back to top
« Last Edit: Jan 8th, 2020 at 2:23pm by Abbott HMG »  
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 179
Re: Error when building with avr_gdb library
Reply #19 - Jan 8th, 2020 at 1:41pm
 
Apologes, I think I had seen progress, and didn't acknowledge the linker error....

Can you confirm which version of the AVR Boards package you have installed? (shown in Visual Micro Explorer > Manage Boards)

The amended version of the maple project which compiles for me is attached for reference.
Back to top
 

MaplePump_001.zip (Attachment deleted)
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #20 - Jan 9th, 2020 at 4:01am
 
Version 1.6.23
Back to top
 

AVR_Boards.PNG (34 KB | )
AVR_Boards.PNG
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 179
Re: Error when building with avr_gdb library
Reply #21 - Jan 9th, 2020 at 9:08am
 
Thanks, rolling my system back to Arduino 1.8.9 brings this core with it (as its built in) and then I get the same errors for regs and the linking.

If you update your Arduino installation to 1.8.10 this should update the core to 1.8.1 and then it should compile as expected.
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #22 - Jan 9th, 2020 at 5:00pm
 
Thanks,
Funny, I just reinstalled VS2019 (latest) & VisualMicro (latest) and was about to check on the Arduino IDE.
Again, thanks for your help.
This was a real newbie error on my part, not keeping the Arduino IDE up to date.
Abbott Embarrassed Smiley
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #23 - Jan 9th, 2020 at 8:08pm
 
I updated the Arduino IDE, as suggested. There were no compile errors, but 444 warnings...and the program still didn't link and load. I included the Verbose updated avr Boards list.
Again, thanks for the follow through.
Abbott
Back to top
 

verbose_log.txt (277 KB | )
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 179
Re: Error when building with avr_gdb library
Reply #24 - Jan 9th, 2020 at 8:46pm
 
No problem and there are a lot of versions / software to keep up with...

Can you update the core as well to 1.8.1 and see if it improves?
(It must be a combination of all of this that works is all I can think now)

How: expand Arduino AVR Boards section and left click on 1.8.1
A message will appear at the bottom of this window when complete
Then click Rescan or restart VS to finish the update
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #25 - Jan 9th, 2020 at 11:20pm
 
The latest 1.8.2 was installed.
It appears that the #ifndef _DEBUG
did not work.
After I commented the attachInterrupts out (again) I was able to upload the sketch to the Mega 2560.

I then downloaded the vmicro\tools zip files and installed them.
After the upload debugging did not start. If I hit the vMicro upload button, the upload occurs and debugging does not start. When I hit Debug->Start Debugging I get the following screen without the breakpoint being hit.

Are there any special VMico Menu entries that should be set?

Thanks
Abbott

Abbott
Back to top
« Last Edit: Jan 10th, 2020 at 3:09pm by Abbott HMG »  

Debug1_003.PNG (108 KB | )
Debug1_003.PNG
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 179
Re: Error when building with avr_gdb library
Reply #26 - Jan 10th, 2020 at 3:10pm
 
_DEBUG not working:
have you set the project property "Configuration Define _DEBUG" to 1?
(highlight in solution explorer, press F4)

Not Landing on Breakpoint
With this GDBStub implementation you have to have at least one breakpoint set at compile time, using the breakpoint() function, which is in the top of loop() normally, and suits most needs.

If you add breakpoint() on the line before then it should land there after re-upload and starting debugging again.

The below shows the project property, code amendment and debug landing on this break.

...
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #27 - Jan 10th, 2020 at 7:31pm
 
Almost there ... I guess ...
_debug worked and I get ...
Uploading 'MaplePump' to 'ATmega2560 (Mega 2560) (Arduino Mega)' using 'COM3'
     The upload process has finished.
The breakpoint is still not hit. Are there any other vMicro config params that I should look at?
Is there a limit to the number of breakpoints?
Do the breakpoints set by clicking the desired line work?
See the screen shot after the upload.
Note - I left debug_init() at the top of setup.
Thanks
Abbott
Back to top
 

Debug2.PNG (107 KB | )
Debug2.PNG
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #28 - Jan 10th, 2020 at 8:14pm
 
One thing of note as mentioned previously, the GDBStub does not allow the main Serial to be used because you are trying to use that for GDB. You need to use a different serial on the mega along with an ftdi cable or other pin to usb converter.
Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #29 - Jan 10th, 2020 at 11:50pm
 
I previously commented out all the serial references. So the serial is free for GDBStub. The only things that might interfere is the Webserver.
I do believe that ethernet uses the Serial to report on the port id. I'll remove that for now and try it.
...I removed all Ethernet / wifi references ... which use Serial port and it does not go into debug after uploading.
Do I still have to set up a separate Serial?
Thanks
Abbott
Back to top
« Last Edit: Jan 11th, 2020 at 2:37am by Abbott HMG »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #30 - Jan 11th, 2020 at 12:07am
 
I suggest testing the debugger in a simple new project so that you can prove your config and it is also worth reading more on the avr-debugging library git page. The git page for the library might also be the best place for questions to the author.

https://github.com/jdolinay/avr_debug

Code (C++):
#include <avr8-stub.h>

void setup(void)
{
	debug_init();	// initialize the debugger
	pinMode(13, OUTPUT);
}

void loop(void)
{
	breakpoint();		// stop execution here
	digitalWrite(13, HIGH);
	delay(200);
	digitalWrite(13, LOW);
	delay(500);
}
 



I found some useful test on google about the limitations and also some suggestions. No idea if still current.


The Arduino Serial class cannot be used in your program together with the debugger. The debugger uses the serial line to communicate with the eclipse IDE. This may look like a big problem if you write your programs "the Arduino way", that is, print debug messages to serial line. But when you debug with a debugger you usually do not need to print such messages. If you do need it, there is a function debug_message which can be used to send mesages to debug console in eclipse. If you need to send data from your program (for normal operation, not for debugging), then you have to first debug the program without the serial output and then enable the serial output and disable the debugger. Or you can use the SoftwareSerial on Arduino Uno and on Arduino Mega also the other hardware serial interfaces Serial1, 2, etc.

One of the pins with external interrupt function (INT0, INT1,…) must be reserved for the debugger. With Arduino Uno this can be either digital pin 2 or 3 (PD2 or PD3 pin of the MCU). For Arduino Mega there are more options. By default, INT0 pin (Uno pin 2, Mega pin 21) is used, but you can change this by AVR8_SWINT_SOURCE constant in avr8-stub.h file.

As described above, in the default configuration with RAM breakpoints, the program executes at much lower speed when breakpoints are set in the program. This is because the breakpoints are implemented using a little strange feature of the Atmel AVR architecture - there is always one instruction executed after return from interrupt service routine (ISR) before the same or other ISR can be entered again. Thanks to this feature it is possible to single step the program and compare current program counter with desired breakpoint addresses. But having an interrupt triggered after each instruction does slow down the program a lot. This slowness is not a problem in many cases but if you do find it limiting, you can switch to flash breakpoints.

When using flash breakpoints the watchdog cannot be used. Arduino library does not use watchdog so this is usually not a problem. If you need to use watchdog in your application, enable the code which works with the watchdog only after the application is debugged, or use the RAM breakpoints configuration.
Back to top
« Last Edit: Jan 11th, 2020 at 12:08am by Visual Micro »  
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #31 - Jan 11th, 2020 at 11:04am
 
I tried the simple example you supplied and it works.
I'll contact Jan Dolinay
Thanks
Abbott
Back to top
« Last Edit: Jan 11th, 2020 at 11:34am by Abbott HMG »  
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #32 - Jan 11th, 2020 at 12:45pm
 
VS = Version 16.4.2
Micro Build -
Program MaplePump size: 72,692 bytes (used 29% of a 253,952 byte maximum) (7.90 secs)
Minimum Memory Usage: 5177 bytes (63% of a 8192 byte maximum)

# Copy build result to 'Project>Property Pages>Intermediate Directory'
# Destination: file:///C:/Users/Abbott/Documents/Arduino/Solutions/MaplePump/Debug/

Uploading 'MaplePump' to 'ATmega2560 (Mega 2560) (Arduino Mega)' using 'COM3'
     The upload process has finished.
# Copy build result to 'Project>Property Pages>Intermediate Directory'
# Destination: file:///C:/Users/Abbott/Documents/Arduino/Solutions/MaplePump/Debug/

Thanks
Abbott
Back to top
 

Debug3_001.PNG (107 KB | )
Debug3_001.PNG
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #33 - Jan 11th, 2020 at 1:17pm
 
Our posts crossed and I think you previously reported the simple example didn't work and subsequently changed to a post that confirmed it did work. I agree it's a question for the git site.

Your verbose output was useful and will help you be clearer in your report to git. At some point you have used board manager to install the arduino avr. The arduino ide is installed with an avr tool chain, when you install via board manager it overrides and can then cause some confusion.

I suggest you delete C:\Users\Abbott\AppData\Local\arduino15\packages\arduino. That will zap your arduino board manager packages (which can be reinstalled again via board manager in the future). The benefit of this is that your problem reporting  will be accurate in terms of the tool chains and core that you are using. Thus, when you report the issue on git you will say that you are using Arduino IDE 1.8.x and the author of git will be able to replicate your arduino environment.

After deleting the package restart vs or click Rescan so that VS is also using the same tool chain.



Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #34 - Jan 11th, 2020 at 9:33pm
 
I did as you asked and it still does not go into debug.
I then created a MaplePumpDebug2 in which I started to add the low level parts of my program.
I made the .ino logic basic (no calls to my classes).
When I hit the breakpoint, I got an exception dialog.

I've included the screen shot, program with verbose included.

I guess that this is a debugger issue???

I'll continue with this process (to see when debugger totally fails) and update the thread when I hit the failure.

All I did was to include the log.cpp file (which I forgot to include at the beginning of the thread), and the debugger stopped working completely. I did not even make a call to the log.
Back to top
« Last Edit: Jan 12th, 2020 at 2:55am by Abbott HMG »  

1Debug1.PNG (84 KB | )
1Debug1.PNG
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #35 - Jan 11th, 2020 at 9:43pm
 
Well it's good it is working of a sorts.

Yes you are now into either the gdbstuf realm of the microsoft mi debugger realm although the mi debugger has various options that might better control what errors are ignored.

Where you able to continue after the error or add another breakpoint? It might be that you just needed to add a real breakpoint for it to stop on. Try adding the breakpoint() to the setup() then adding a real breakpoint in the loop.

Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #36 - Jan 12th, 2020 at 10:58am
 
I made the test simpler (by removing everything but avr.
When  i add the breakpoint in Loop, the setup breakpoint is never hit.

The same exception now occurs in the loop breakpoint.

I can F10 to next, when it gets to delay, F10 steps into instead of over.

This seams pretty rudimentary for the debugger to fail like this.

I've attached the solution.

Abbott
Back to top
« Last Edit: Jan 12th, 2020 at 11:07am by Abbott HMG »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #37 - Jan 13th, 2020 at 1:12pm
 
It migt be an idea to debug some of your own simple code. You have optimize core enabled so diving into or over core methods might be a bit suspect. The control of the debugger is 100% in vs's hands. The Microsoft MI debugger is included with Visual Studio. We just pass it some json instructions and it does the rest.

You can see the json we pass to it at the end of the verbose build output in the Micro Build output window.

Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #38 - Jan 15th, 2020 at 12:16am
 
As you suggested, I dumbed down my test solution.
It stops at the various breakpoint, once (as expected).
But the count++ after the delay(600) is never trapped. The system goes into an internal loop.
Stopping debugging takes a while and the com3 port is locked.
I have to remove the usb cable to start another session.
See below, plus test solution.
The screen shot is of when the endless loop occurs.
Am I using the wrong approach to debug?
Abbott
Back to top
 
 
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #39 - Jan 15th, 2020 at 8:54pm
 
Before I continue, I think I should rethink gdb. My application is data intensive. It looks as if gdb goobles up too much memory for my json sring to cohabitate... and it puked on my large set of enums.
I'll go back to serial debugging for a bit and see if I can get any further there.
I may come back and test some basic modules with gdb.
When/if I have time after this project  I may put together notes about the experience and post them (??? where).
It has been an unwanted learning experience in a very time critical project.
Thanks
Abbott
You've been great with the support.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10555
United Kingdom
Re: Error when building with avr_gdb library
Reply #40 - Jan 15th, 2020 at 9:53pm
 
Thanks that will be useful but I should add that Visual Micro doesn't have any rethinking to do. We just hook up what is there. Non of the microcontroller debugging is as perfect as windows debugging that is for sure.

The choice of debugger can vary the gdb experience a lot. Each has it's own strenghts. The only strenght of the gdbStub compared to real avr hardware debug is the fact that you don't need to buy a hardware debugger.

The difference in gsb also vararies dramatically for each type of micro controller. Furthermore, many micro controllers support a variety of different hardware debuggers and each hardware debugger has different strenghts and quirks.

All we can do with the current state of the market is to make everything work as much as it is capable of.

The serial debugging might seem weak from point of view of stepping or live variable watch but it support lots of trace points and because it uses standard arduino serial it is more robust and faster.

Sorry there isn't a perfect world but if you find one it would be good to hear about it. An Atmel ICE debugger might give you better results on the mega2560, it will use the ICSP port on the board instead of the serial and doesn't kill the processor in the same was as gdbstub.
Back to top
 
WWW  
IP Logged
 
Abbott HMG
Junior Member
**
Offline



Posts: 55
Bedford, NY, USA
Re: Error when building with avr_gdb library
Reply #41 - Jan 17th, 2020 at 11:16pm
 
Went back to serial. Now it looks as if my handling of the strings used to populate json are giving me a problem.

Thanks
I'll stick with VisualMicro. Can't beat the support.
Abbott
Back to top
 
 
IP Logged
 
Pages: 1 
Send Topic Print