Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) Unable to compile - VM_DBG.h errors (if Serial is being used/re-defined in user code) (Read 11530 times)
SwissRoLL
Newbies
*
Offline


Posts: 6
Joined: Dec 31st, 2012
Unable to compile - VM_DBG.h errors (if Serial is being used/re-defined in user code)
Dec 31st, 2012 at 5:58pm
Print Post  
Hi,
1st time building with this dev system. I'm using
Visual Micro for Arduino 12.12.3004
Visual Micro - Debug tools and visualizations 12.11.0402
Visual Studio 2010 Ultimate 10.0.30319

trying to compile a copy of Merlin v1.0 application for a RepRap printer.

I can build fine using the original Arduino.exe toolchain.
I can build fine using DevStudio before installing the debug tool.
I can build fine with (MicroDebug) set to None.
But when building with (MicroDebug) set to Full I get the following

Compiling 'Marlin' for 'Arduino Mega 2560 or Mega ADK'
Binary sketch size: 48018 bytes (of a 258048 byte maximum) (7.171875 secs)
Compiling debug version of 'Marlin' for 'Arduino Mega 2560 or Mega ADK'
Marlin.ino : In file included from
VM_DBG.h : ISO C++ forbids declaration of 'HardwareSerial' with no type
VM_DBG.h : expected ';' before '*' token
VM_DBG.h : 'HardwareSerial' has not been declared
VM_DBG.h : 'HardwareSerial' has not been declared
VM_DBG.h : : In member function 'void VisualMicroDebug::setVariable(T&, int, int)':
VM_DBG.h : 'transport' was not declared in this scope
Error compiling

I still have the same errors if I try setting the following additional options
RemoteTransport set to HardwareSerial
RemotePort set to Serial
LocalPort set to COM6 (my arduino)
LocalSpeed set to 200000 (Merlin uses this odd speed).

I notice in VM_DBG.h that a #include for HardwareSerial.h is patched out. Patching this back in makes no difference.

I have rebooted since (well XP bluescreened while watching the debugging vid on youtube). The reboot made no difference.


Any ideas?
Thanks
« Last Edit: Dec 19th, 2014 at 1:00am by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to compile - VM_DBG.h errors
Reply #1 - Dec 31st, 2012 at 6:17pm
Print Post  
Hi,

Would you please zip the sketch folder (and ensure you include the folder called "Visual Micro" that will exist below the sketch) and email to info [at] visualmicro.com

Thanks
  
Back to top
WWW  
IP Logged
 
SwissRoLL
Newbies
*
Offline


Posts: 6
Joined: Dec 31st, 2012
Re: Unable to compile - VM_DBG.h errors
Reply #2 - Dec 31st, 2012 at 7:21pm
Print Post  
Folder zipped and sent.

Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to compile - VM_DBG.h errors
Reply #3 - Dec 31st, 2012 at 8:02pm
Print Post  
Thanks. Well the Marlin is an interesting project! Very good but has one strange quirk which will be causing the problem.

With an Arduino project there are two main functions that appear within the sketch files. The sketch files are .ino files. The two functions are called 

Code
Select All
void setup()
void loop() 



In the case of the marlin project these two arduino functions appear in the marlin_main.cpp yet they are declared in arduino "mode" instead of c++ mode.

Whilst not good or normal practice, this works because the Arduino api design is quite tolerant. So this is why the normal compile works well. 

Don't get me wrong, whilst this isn't normal "arduino", the marlin program is an excellent program and better than anything I could write!

The debugger fails because it has to add some important start-up code to the setup() and loop() functions. However the debugger expects these functions to reside in the main .ino sketch source and not in a .cpp file. So the debugger can't work as is.

I will for the next release try to cater for this design. 

In the  meantime  you can make some minor changes to a couple of the files in the marlin program to avoid the problem. The changes do not change the functionality of the marlin program.

The changes will be to rename the setup() and loop() methods in marlin_main.cpp and call them from setup() and loop() methods in marlin.ino. 

3 steps as follows:-

1) Change the names of void setup() and loop() in the marlin_main.cpp to setup_marlin() and loop_marlin():-

Code
Select All
void setup_marlin()
{
  //existing marlin_main.cpp setup() code will be here!
}
void loop_marlin()
{
  //existing marlin_main.cpp loop() code will be here!
}
 



2) Add C++ prototypes for the newly named setup_marlin() and loop_marlin() functions to the top of marlin.h
Code
Select All
void loop_marlin();
void setup_marlin();
 



3) Add void setup() and void loop() to the marlin.ino and make them call the newly named functions
Code
Select All
void setup()
{
  setup_marlin();
}
void loop()
{
  loop_marlin();
}
 


« Last Edit: Dec 31st, 2012 at 8:08pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
SwissRoLL
Newbies
*
Offline


Posts: 6
Joined: Dec 31st, 2012
Re: Unable to compile - VM_DBG.h errors
Reply #4 - Dec 31st, 2012 at 10:20pm
Print Post  
Hi Tim,
Thanks for the quick reply, I've just tried your suggestions and hit the same problem but with some added errors...

Compiling 'Marlin' for 'Arduino Mega 2560 or Mega ADK'
Binary sketch size: 48030 bytes (of a 258048 byte maximum) (7.671875 secs)
Compiling debug version of 'Marlin' for 'Arduino Mega 2560 or Mega ADK'
Marlin.ino : In file included from
VM_DBG.h : ISO C++ forbids declaration of 'HardwareSerial' with no type
VM_DBG.h : expected ';' before '*' token
VM_DBG.h : 'HardwareSerial' has not been declared
VM_DBG.h : 'HardwareSerial' has not been declared
VM_DBG.h : : In member function 'void VisualMicroDebug::setVariable(T&, int, int)':
VM_DBG.h : 'transport' was not declared in this scope
Marlin.ino : : In function 'void setup()':
Marlin.ino : 'Serial' was not declared in this scope
Marlin.ino : 'class VisualMicroDebug' has no member named 'transport'
Error compiling

I notice that in Marlin.h the author has put in the following lines of code...
#ifndef AT90USB
#define  HardwareSerial_h // trick to disable the standard HWserial
#endif


If I patch out the #define temporarily I get a compile but with multiple definitions;

Compiling 'Marlin' for 'Arduino Mega 2560 or Mega ADK'
Binary sketch size: 48030 bytes (of a 258048 byte maximum) (7.6875 secs)
Compiling debug version of 'Marlin' for 'Arduino Mega 2560 or Mega ADK'
core.a(HardwareSerial.cpp.o)* : : In function `__vector_25':
HardwareSerial.cpp : multiple definition of `__vector_25'
MarlinSerial.cpp.o : :C:\Documents and Settings\Me\Local Settings\Application Data\VMicro\Arduino\Builds\Marlin\mega2560/MarlinSerial.cpp:54: first defined here
ld.exe : : Disabling relaxation: it will not work with multiple definitions
core.a(HardwareSerial.cpp.o)* : : In function `serialEvent()':
HardwareSerial.cpp : multiple definition of `rx_buffer'
MarlinSerial.cpp.o : Sad.bss.rx_buffer+0x0): first defined here
ld.exe : : Warning: size of symbol `rx_buffer' changed from 132 in C:\Documents and Settings\Me\Local Settings\Application Data\VMicro\Arduino\Builds\Marlin\mega2560\MarlinSerial.cpp.o to 68 in C:\Documents and Settings\Me\Local Settings\Application Data\VMicro\Arduino\Builds\Marlin\mega2560\core.a(HardwareSerial.cpp.o)
avr-objcopy* : : 'C:\Documents and Settings\Me\Local Settings\Application Data\VMicro\Arduino\Builds\Marlin\mega2560\Marlin.elf': No such file
avr-objcopy* : : 'C:\Documents and Settings\Me\Local Settings\Application Data\VMicro\Arduino\Builds\Marlin\mega2560\Marlin.elf': No such file
Couldn't determine program size: 

So it looks like the Marlin app needs more tweaking to allow it to co-exist with the debugging environment.

Sounds like the first job for 2013 if I can get up in the morning.

Shocked)
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to compile - VM_DBG.h errors
Reply #5 - Dec 31st, 2012 at 10:35pm
Print Post  
Yes you are right I didn't see that and haven't had time to test it. You have two options at the moment. 

Option 1 is probably the best because the marlin grabs the serial ports. Option 1) requires an ftdi able.

1) Use the software serial "RemoteTransport" on one or two spare digital pins.

or

2) Notice the RemoteTransport called "FastSerial" this is for a custom serial protocol allowing the debugger to use a re-defined hardware serial class of your choice. 

The FastSerial option is defined in a couple of files that are installed with the plugin. VM_DBG.h and VM_DBG.cpp, I'll try to make a version of them that uses the serial of your project and email them to you over the next day or so. This will mean that when you set the RemoteTransport property of a sketch to FastSerial it will expect to use the serial of the Marlin project.
« Last Edit: Jan 4th, 2013 at 12:43am by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
SwissRoLL
Newbies
*
Offline


Posts: 6
Joined: Dec 31st, 2012
Re: Unable to compile - VM_DBG.h errors
Reply #6 - Dec 3rd, 2014 at 8:55pm
Print Post  
Hello,
I know.... last post was 2 years ago, but this is my winter project so it progresses in yearly intervals  Cool

I've purchased a license BTW and started building a new 3D printer, hence getting back into this again.

To catch up with things I've updated to Arduino 1.0.6 and the latest VisualMicro release.

I have finally got VisualMicro debugging to work with the Marlin project but found an possible issue?? with how HardwareSerial.cpp is implemented.

I'm using a Mega2560 board, with Serial Port 1 (UART1) configured to be the Marlin app serial interface. The Marlin app defines its own UART vector for this.
UART0 (the Mega2560 USB port) is used for code download (via the std bootloader), and as the VisualMicro debug port.

I've updated the Marlin code as per the ideas in this thread, but I had to also modify "HardwareSerial.cpp" because it was trying to define another UART1 vector (~line 150).
I had to change the "#if defined(USART1_RX_vect)" to read "!if" in order to get it to build.

if the VM GUI "Remote Port" option called "Serial" was called "Serial0" that would make it more clearer as to which port it was using but I don't understand why HardwareSerial is trying to define all the other serial port vectors regardless of the "Remote Port" setting (shouldn't it only use the serial port that the VM GUI says it needs for the debug connection?) 

The other change to "HardwareSerial.cpp" was to rename the variable rx_buffer, because Marlin also has an "rx_buffer" variable as well.

Once these were done, the code compiles and can be break-pointed \ controlled by VM  Cheesy



  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to compile - VM_DBG.h errors
Reply #7 - Dec 3rd, 2014 at 9:10pm
Print Post  
Hi again,

No probs for the delay and thanks for the suggestion.

The Serial (remote port) used by default matches/is the Serial object available in the Arduino Ide and whatever is defined for that.

Arduino defines all Serial[n] ports in the hardwareserial.cpp but I noticed in recent versions of 1.5.x they have split each into a separate hardwareserial[x]n.cpp

Just a guess, but maybe if you upgrade your arduino ide (and Visual micro if it's older) the problem might not be a problem. Sorry if this isn't right and wastes your time.

You can install arduino using the zip so can test this by unzipping into a test folder without disturbing your current build environment. Remember to set the Visual Micro Arduino 1.5.x application path to the correct location.

  
Back to top
WWW  
IP Logged
 
SwissRoLL
Newbies
*
Offline


Posts: 6
Joined: Dec 31st, 2012
Re: Unable to compile - VM_DBG.h errors
Reply #8 - Dec 18th, 2014 at 1:29pm
Print Post  
Hi,

I upgraded to Arduino 1.5.8 beta (via the windows installer), resulting in a complete mess (intellisense was broken and I counld'nt get a build to work either)... so I uninstalled Arduino and VM completely and reinstalled both from scratch.
Retaining my rx_buffer rename in the Marlin source code, I can now build \ debug the Marlin code under Arduino 1.5.8.
So to summarize,
I have Marlin debugging on a Mega2560 with the Marlin app using Serial1 (via a 2nd UART cable), Visual Micro using "Serial" for download\debug via the USB cable and the following app versions
Visual Studio 2010 v10.0.30319.1
Visual Micro 14.12.1000
Arduino 1.5.8
Marlin v1

Smiley


  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Unable to compile - VM_DBG.h errors (if Serial is being used/re-defined in user code)
Reply #9 - Dec 19th, 2014 at 12:48am
Print Post  
Great news (apart from the hassle), thanks for the update and the complete answer

Answer: Use the RemotePort project property to change the debugger port or change the user code to use a different port
« Last Edit: Dec 19th, 2014 at 1:03am by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint