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 2 3 
Send Topic Print
Error when building with avr_gdb library (Read 1841 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
 
Pages: 1 2 3 
Send Topic Print