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....
  • 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
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
T4.x Library issues with GDBStub using USBHost_t36 library (Read 508 times)
KurtE
Newbies
*
Offline



Posts: 9
T4.x Library issues with GDBStub using USBHost_t36 library
Jun 27th, 2020 at 11:40pm
 
As I mentioned up on the PJRC forum thread:
https://forum.pjrc.com/threads/58979-duplicate-Arduino-Debug-via-Serial?p=244482
&viewfull=1#post244482

I thought I would try out the new GDBStub stuff, with an sketch I have been working on that controls a Lynxmotion Hexapod with their LSS servos, using my own T4.1 board.  I am also using the Teensy USB Host support to allow me to control the hexapod using BlueTooth Joysticks, currently mainly a PS3.

I am now able to build using @ftrias setup on Teensudino and start up the sketch.

But it would be a lot easier to debug at the Source level so I update my VisualMicro on VS2019, with the appropriate install.  I setup for dual Serial, I set to debug ,
No optimize sketch-library, Debug Hardware GDBStub.

I also setup to show hidden files, so I can now see the libraries, which is great.

But now when I compile the link fails:
Code:
LSS_Phoenix_Input_USB_Joystick.cpp.o: In function USBDriver::USBDriver()

Error linking for board Teensy 4.1
USBHost_t36.h:429: undefined reference to vtable for USBDriver
Build failed for project 'LSS_PhoenixUSBJoystick'

LSS_Phoenix_Input_USB_Joystick.cpp.o: In function USBHIDInput::USBHIDInput()
USBHost_t36.h:505: undefined reference to vtable for USBHIDInput

collect2.exe*: error: ld returned 1 exit status

  


Again it links and run using arduino, so wondering what options that I may need to do to compile the sketch and this library to make it such that it will properly link in debug mode.

The sketch is up in the github project: https://github.com/KurtE/LSS_Test_sketches/tree/master/LSS_PhoenixUSBJoystick

I have not uploaded the VS (Or the Sublime text) projects.

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



Posts: 10753
United Kingdom
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #1 - Jun 27th, 2020 at 11:50pm
 
If you leave optimization as default does it build okay?
Back to top
« Last Edit: Jun 27th, 2020 at 11:50pm by Visual Micro »  
WWW  
IP Logged
 
KurtE
Newbies
*
Offline



Posts: 9
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #2 - Jun 28th, 2020 at 2:48pm
 
Thanks,

I notice two different issues with my stuff here.  First off it appears like the code is choosing the version of the library that is installed by Teensyduino In my case (C:\arduino-1.8.13\hardware\teensy\avr\libraries\USBHost_t36) instead of my WIP version of the library which is stored in my <Sketch folders>/libraries/... again in my case: C:\Users\kurte\Documents\Arduino\libraries\USBHost_t36

Note: I am also playing a trick here where the actual sources are in my d:\github\USBHost_t36 directory and my library folder (Windows 10) is using a directory Symbolic link to it...

But hopefully there is some simple parameter in the project that will point it to the right place...

But when I switch over to default optimizations (Faster) and switch to Default Optimization, it still fails to link.

I included the text file showing the log. If you search for some of the files contained in the file like bluetooth.cpp, you will see that the compile has both an -O2 at start of the compile and later near end of command line it also has an -O0.

I believe that it has to do with the some of the Extras stuff that is shown at start of build like:
Code:
build.vm.extra_flags.core=-O0
build.vm.extra_flags.library=-O0
build.vm.extra_flags.project=-O0 


Hopefully I can find some place in some configuration and just remove these?

Back to top
 

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10753
United Kingdom
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #3 - Jun 28th, 2020 at 3:24pm
 
Sorry for the confusion. Teensy is one of very few boards that has it's own optimization settings on the board menu. Those settings are used in a specific way by teensy and will work the same in both Arduino and Visual Micro.

The optimization setting I was talking about is the Visual Micro debugger optimization setting. vMicro > Debugger > 'Compiler Optimization.That should remain at default.
Back to top
 
WWW  
IP Logged
 
KurtE
Newbies
*
Offline



Posts: 9
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #4 - Jun 28th, 2020 at 4:31pm
 
Quick update - I completely deleted everything but the original code (all stuff created by VisualStduio...)  Then restarted, and told it to use an existing Arduino project... 
I have not turn on your debugger settings yet.  but it does now link Cheesy

But as mentioned it does use the version of USBHost_t36 that was installed with Teensyduino. As is in the compile lines that include:

-I"C:\arduino-1.8.13\hardware\teensy\avr\libraries\USBHost_t36"

Not sure what would happen if I now simply delete it from there... 
It fails until I tell the system to rescan libraries... Now it looks like it builds...

Now to see if I can turn on debug with this one...
Back to top
 
 
IP Logged
 
KurtE
Newbies
*
Offline



Posts: 9
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #5 - Jun 28th, 2020 at 4:42pm
 
Another quick update:

Now builds with GDBStub Cheesy

I have not tried much... One interesting thing here is to figure out what Serial COMM port to setup when...
That is I have setup for Dual Serial.
So on my T4.1 it now has COM32(SerialUSB1) and COM33(Serial).

I believe to upload you need to set the Serial port to 33, but then GDB fails to start.
But then if you change setting for COM32 and then Debug->Attach to process, which looks like it may connect Cheesy

Now to try debugging something.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10753
United Kingdom
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #6 - Jun 28th, 2020 at 4:45pm
 
Great thanks. We will look into library priority. Historically the sketchbook/libraries is weak and does not allow a different library for different architectures. Therefore libraries includes below each architecure are consider to be of higher importance, leaving the sketchbook\libraries to cater for any architecure that does not provide the library.

That said, it should be an option so that it can do same as Arduino IDE.

You can do exactly as you have said, delete the one you don't want then click "Rescan" in Visual Micro or restart the IDE.

After you do that all should be well, however you can also use the "create shared project when adding libraries" option on the "Add Library" menu. After enabled that checkbox reselect the library from the "Add Library" menu. This will link the live library sources to the solution as a Visual Studio shared c++ project. It will also add a Reference from the Arduino project to the library. You will see all this in the solution explorer. With this configuration Visual Micro will know to use the library in the sketchbook\libraries folder even if the one below the Teensy core platform is subsequently replaced/updated/reinstated.

Adding the library as a shared project will show how easily you can add libraries of a "specific" location. This is useful if you want your libraries to be stored in more flexible locations than the published Arduino locations. There is also a new Arduino library project in "File>New>Project" which shows more detail of shared library projects.


Back to top
 
WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10753
United Kingdom
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #7 - Jun 28th, 2020 at 5:02pm
 
Our last posts crossed Smiley

The teensy gdb stub is new for us and based on the teensy gdb stub that is not our work. Someone will look during the week to see if the stub can use an alternative port. It probbaly can. If so, then we will feed the upload port through to it or provide an option to set the GDB port.
Back to top
« Last Edit: Jun 28th, 2020 at 5:02pm by Visual Micro »  
WWW  
IP Logged
 
KurtE
Newbies
*
Offline



Posts: 9
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #8 - Jul 4th, 2020 at 3:58pm
 
Quick updates:

I have been able to make some of this work, found I had the best luck by doing the build and upload like and then attach the debug process...

But again there are a few things I have not figured out the proper way of doing things like:

a) After I connect the debugger, can I break back in to the program to debug?  If I do the break-all, the Visual Studio (2019) hangs or at least the UI is unresponsive, and about the only thing I can do is kill the process

b) Can I while my program is running, set a new break point?  So far when I try it and I am not at a breakpoint, it does not take, but if I then tell it to build-download and attach again it does... I assume that is normal.  Not a problem if I can break in... Maybe I will add a UI way to call the debugger...

c) The GDBStub code has some other things to his stub, that you can supposedly call from command line GDB, like:
"monitor digitalWrite(13,1)"
Which would turn the LED on. 
Is there any way to feed a command line in to the GDB here?

d) Should I raise an issue somewhere about your library search order code works different than Arduino?  As mentioned earlier, you use the one that Teensyduino installs, instead of my version in the Arduino sketches/libraries/... folder

e) Probably obvious, as I see you quickly do it in your video talking about this debugging, but how to open up Terminal window on the 2nd IO port.  That is I have the T4.1 configured Dual Serial, where COM32 is the GDB port (SerialUSB1) and 33 is the Serial port.  So I have COM32 selected and it compiles and uploads fine, I use the Attach to Process... Now I would like to open up terminal window on COM33.  What is best way to do this...  I can of course use different app, such as TyTerminal or Arduino Serial monitor, but just wondering...

Again thanks!
Back to top
 
 
IP Logged
 
KurtE
Newbies
*
Offline



Posts: 9
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #9 - Jul 4th, 2020 at 5:18pm
 
Quick update to my quick update Wink
KurtE wrote on Jul 4th, 2020 at 3:58pm:
Quick updates:

I have been able to make some of this work, found I had the best luck by doing the build and upload like and then attach the debug process...

But again there are a few things I have not figured out the proper way of doing things like:

a) After I connect the debugger, can I break back in to the program to debug?  If I do the break-all, the Visual Studio (2019) hangs or at least the UI is unresponsive, and about the only thing I can do is kill the process


I found a way in that works OK for me now... I put in UI code.  Both in my little debug terminal code, plus in my joystick code, that for example with PS3, if I press the L3 button, it breaks in... by using his halt() macro.  Which I then can go and set new breakpoint or enable one or ...
Code (C++):
    if ((g_buttons & BTN_MASKS[BUT_L3]) && !(g_buttons_prev & BTN_MASKS[BUT_L3])) {
        MSound(1, 50, 2000);
        #if defined(TEENSY_DEBUG_H)
        if (debug.isGDBConnected()) {
            DBGSerial.println(F("Trying to break in to GDB"));
            halt();
        }
        else
        #endif
        {
            g_fDebugOutput = !g_fDebugOutput;
            if (g_fDebugOutput) DBGSerial.println(F("Debug is on"));
            else DBGSerial.println(F("Debug is off"));
        }

    }
 



EDIT
: Forgot to mention:
Quote:
e) Probably obvious, as I see you quickly do it in your video talking about this debugging, but how to open up Terminal window on the 2nd IO port.  That is I have the T4.1 configured Dual Serial, where COM32 is the GDB port (SerialUSB1) and 33 is the Serial port.  So I have COM32 selected and it compiles and uploads fine, I use the Attach to Process... Now I would like to open up terminal window on COM33.  What is best way to do this...  I can of course use different app, such as TyTerminal or Arduino Serial monitor, but just wondering...

Choose the other comm port in this case COM33 and the press the Terminal Monitor button to the right of the drop down list

Back to top
« Last Edit: Jul 5th, 2020 at 11:54pm by KurtE »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10753
United Kingdom
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #10 - Jul 6th, 2020 at 6:08pm
 
Thanks for the info. We are looking into a couple of things and will update with answers over the coming couple of days.

One minor point is that the "Other" tool bar button next to the serial monitor icon and "vMicro>General>Monitor Alternative" allow terminal to be opened on additional ports (unrelated to upload/debug)

Back to top
 
WWW  
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 356
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #11 - Jul 6th, 2020 at 7:58pm
 
Just to update on point (c):-

You can run GDB Commands whilst Debugging in Visual Micro (on all hardware debuggers/GDBStubs), the below guide should help, and we will add further information and videos shortly.

Executing Custom GDB Commands in Visual Micro
Back to top
 
 
IP Logged
 
KurtE
Newbies
*
Offline



Posts: 9
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #12 - Jul 8th, 2020 at 3:38pm
 
Simon Hopkinson wrote on Jul 6th, 2020 at 7:58pm:
Just to update on point (c):-

You can run GDB Commands whilst Debugging in Visual Micro (on all hardware debuggers/GDBStubs), the below guide should help, and we will add further information and videos shortly.

Executing Custom GDB Commands in Visual Micro

Thanks for the hints and web page.  I put a comment up on the PJRC forum with this.   I am having some fun.  Still running into a few pitfalls, but mostly work through them.  Things like how to stop the debugger.  Mostly I found I need to turn off the Teensy to get the Visual Studio out of a UI hang...  Likewise if I put a break in and then hit F10 it will not really ever let me back in... But the answer is: don't do that Wink

Thanks again
Back to top
 
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 356
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #13 - Jul 8th, 2020 at 4:58pm
 
Thanks for the update and feedback!

In the very latest release you can now select the Debug Port separately on the menus to make it easier to run your debugging and serial monitors side by side for the GDBStubs / Black Magic Probe.
YouTube: Debug Port Selection for GDBStubs & Black Magic Probes

An additional quit and/or other such "stop" type command may help with stopping the debugger, which can be added via Local.board.txt as shown towards the end of the below video:-
YouTube: Execute GDB Commands While Debugging Arduino Projects
Back to top
 
 
IP Logged
 
KurtE
Newbies
*
Offline



Posts: 9
Re: T4.x Library issues with GDBStub using USBHost_t36 library
Reply #14 - Jul 11th, 2020 at 4:54pm
 
Simon Hopkinson wrote on Jul 8th, 2020 at 4:58pm:
Thanks for the update and feedback!

In the very latest release you can now select the Debug Port separately on the menus to make it easier to run your debugging and serial monitors side by side for the GDBStubs / Black Magic Probe.
YouTube: Debug Port Selection for GDBStubs & Black Magic Probes

An additional quit and/or other such "stop" type command may help with stopping the debugger, which can be added via Local.board.txt as shown towards the end of the below video:-
YouTube: Execute GDB Commands While Debugging Arduino Projects

Thanks for the information, yes the 2 comm port setup makes it a lot nicer.

I am still trying to work my way through some of this stuff, like the boards.txt overrides.

Also I thinking some of the issues I am running into is caused by the nature of the sketch I am trying to run.  In particular, it uses USB Host code, in this case on T4.1.  Also unclear at times what is best way to do things.

Example: I put code in for joystick that if I press L3 button, it tries to break me into GDB.  I have tried both halt and the debug.setBreakpoint... Like:
Code (C++):
#if defined(TEENSY_DEBUG_H)
			if (debug.isGDBConnected()) {
				DBGSerial.println(F("Trying to break in to GDB"));
				// lets try it through setting breakpoint at loop
				debug.setBreakpoint(&loop);
				//halt();
			}
			else
#endif 


And if I do this, once or twice it breaks in, usually by 3rd attempt it does not, although this last run appeared to allow it several times.  Setting the breakpoint like this does not appear to leave a breakpoint in the spot (loop) like yours does as if I hit F5 it does not continue to break there.  Also shows up different.  Shows up with RED X with Exception Unhandled (Trace/Breakpoint Trap) versus your normal breakpoint.  I can then set a normal breakpoint and it breaks each time I get to that location.

Also with the setBreakpoint... Sometimes if I hit F10 it steps fine and other times it appears to go into never never land.

But I maybe should also mention, that for example currently I have turned on debug printing in part of the USBHost code, in Bluetooth and Joystick code. And for example I am currently in a breakpoint and the Serial monitor continues to Spew out debug Serial prints from the Joystick and Bluetooth code, which is running due to Interrupts from the USB Host code.   One of the last runs, it crashed out of the debugger:

Again still just learning my way around Cheesy



Back to top
 

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print