VS Arduino
>> >> Setting up a custom board for debugging (Robotis CM9)
https://www.visualmicro.com/forums/YaBB.pl?num=1538797491

Message started by chiMT on Oct 6th, 2018 at 3:44am

Title: Setting up a custom board for debugging (Robotis CM9)
Post by chiMT on Oct 6th, 2018 at 3:44am
Hello,

We are developing firmware on a custom Arduino board. It is the CM9 from Robotis. Their documentation on their board can be found here:
http://emanual.robotis.com/docs/en/parts/controller/opencm904/

We are able to load their board through the Visual Micro extension in Visual studio and upload our firmware to the board successfully.

The next step is to try to use the Visual Micro debugger. When we try to run the debugger we get the expected error of the following:

---------------------------------------

Compiling debug version of 'InterbotixFW_0.1' for 'OpenCM9.04 Board'

InterbotixFW_0.1.ino: In function void setup()

InterbotixFW_0.1.ino:79: In file included from
   void begin(UARTClass *theSerial, unsigned long baud)
Error compiling project sources
   Debug Build Error: This hardware might not support the default Visual Micro Debugger.
     If this project is using OTA/WiFi upload then please use the vMicro>Debugger menu to set the Serial COM and Remote port for the debugger.
     Otherwise switch the toolbar from 'Debug' to 'Release' and build again.
           or switch off Automatic Debugging
           or configure the SoftwareSerial debugger option.
Debug build failed for project 'InterbotixFW_0.1'

-------------------------------------------

I believe that this is pointing us to the below tutorial, which is instructing us to configure the correct settings for pins to use the board. But this is where we are asking for help because this is a new area and we are not sure of the correct settings.

https://www.visualmicro.com/post/2012/05/06/Configure-debug-for-other-types-of-serial-transport.aspx

This is our question: Are we able to set the proper pin and other settings in order to get the Visual Micro debugger to work with the custom board?

If yes, then can anyone help us with the correct settings from the documentation to make the debugger work with the custom board?

Thank you for any help!

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by Visual Micro on Oct 6th, 2018 at 12:38pm
Hi

What is the class name of Serial? If you press F12 on Serial what is it defined as?

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by chiMT on Oct 7th, 2018 at 3:42am
I'm sorry, I'm not following what you mean by press F12 on serial? Can you explain what you mean by on serial?

Thank you.

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by Visual Micro on Oct 7th, 2018 at 11:00am
Type Serial into setup() or loop() then right click "Go To>Definition (F12)"

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by chiMT on Oct 7th, 2018 at 9:39pm
Thanks for the explanation. Here are screenshots of the result. (The reply form has no feature to attach an image to my reply?)

https://imgur.com/a/6FEcivB


Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by chiMT on Oct 8th, 2018 at 7:44pm
We have tried the following settings and it still is giving the standard error.

Can we be advised what to try next? I posted the Serial answer in my last post.


VMprojectSettings.jpg ( 67 KB | 2 Downloads )

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by chiMT on Oct 10th, 2018 at 5:49am
bump. We are still very interested in help figuring this out. Cheers.

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by Visual Micro on Oct 10th, 2018 at 1:02pm
It will be looked at over the next few days

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by chiMT on Oct 11th, 2018 at 3:13am
Thank you for the response.

We have also posted our question at the Robotis github and they gave a response. They are saying that the OpenCM9.04 doesn't support the same debugging that VM uses. I wanted to post their response for your team to see. They might have helped provide the answer that your research would also provide. It seems that there are two different types of debugging environments.

https://github.com/ROBOTIS-GIT/OpenCM9.04/issues/44


Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by Visual Micro on Oct 20th, 2018 at 4:08pm
Sorry for the delay. You can ignore the response in the OpenCM9 forum they will be thinking gdb or hardware debug.

If you add a board.txt to your project and add the following lines then click "save", things should work in debug mode.


Code (c++):
vm.debug.class_type=VM_DEBUGGER_TYPE_USARTSERIAL



Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by chiMT on Oct 21st, 2018 at 12:23am
Hello,

Thank you for the reply. That is encouraging to hear that we can use VM with the board.

I did as advised and made the board.txt file with that line of code. When I tried to run in debug it failed again. Here is a link to the full build output:
https://drive.google.com/file/d/1KkFNB0cP3dpxYcDqYQXNSivBh_mBhdA4/view?usp=sharing


I also wanted to ask on a side note. After we successfully get the board working in debug mode. Will it be possible to debug while also sending packets to the same serial port from another program? Or use two different ports? (The Op0enCM9.04 has multiple serial ports) I've seen some of the VM documentation about this being possible from these two guides:
https://www.visualmicro.com/page/User-Guide.aspx?doc=Debugging-Sharing-Ports.html
https://www.visualmicro.com/page/User-Guide.aspx?doc=Debugging-With-Different-Ports.html

The end goal is to be able to debug in real time while the board is attached to our front end sending serial packets back and forth. That would be a dream dev setup.

If that is not possible, the next best thing is to run in debug mode and have some way of sending serial packets to the board through the debugger. So that we can fire functions and test etc.


Regards,

Matt

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by Visual Micro on Oct 21st, 2018 at 12:15pm
It builds okay for me in a simple project.

Please try a simple project without libs to start with and make sure the vMicro>Debugger menu is clear of entries.

These are better options for your board.txt. You can remove the previous settings:-


Code (c++):
vm.debug.class_type.Serial=VM_DEBUGGER_TYPE_USBSERIAL
vm.debug.class_type.Serial1=VM_DEBUGGER_TYPE_USARTSERIAL
vm.debug.class_type.Serial2=VM_DEBUGGER_TYPE_USARTSERIAL
vm.debug.class_type.Serial3=VM_DEBUGGER_TYPE_USARTSERIAL


The above settings enable Serial, Serial1, Serial2, Serial3 which can be selected from the vMicro>Debugger menu


tips:

The debugger can handle/ignore serial that is being outputted on the same port but only one windows device can use it at a time. You are better using an alternative port for debug or the softwareSerial option which requires 1 pin for trace and 1 pin for "break/pause/variable update". If you hav an


Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by chiMT on Oct 22nd, 2018 at 5:27am
Hello,

I did as advised. I changed the board.txt file with the new code. I took out the two library references and deleted all code that used those libraries. So it was just junk code left in there. I still got the error. I then deleted everything so there was just an empty setup and loop. Same error.

I then made new project through the VM menu, added the board.txt file with the new settings and it compiled and ran :)

I then added in the library references and all the code and it compiled and ran in debug mode. It is working :) I can set break points and read variables.

There must have been something in the original project that was causing a problem even with the correct board.txt file and settings. A fresh project fixed the issue. I don't recall, but I may have not created that project through the VM new arduino project menu.

As a note to anyone else finding this thread who is using the OpenCM9.04. You cannot just write the include file line for the DynamixelSDK library. You have to add it by using the "add library" in the VM toolbar and select it from the drop down. When you do it this way visual studio finds the library and the red underlines will go away.

Thank you for the help getting VM debugging working.

The next step will be figuring out how to properly set up the configuration so that I can run the debugger on a secondary serial port while allowing our front end to use the SerialUSB port to send data packets back and forth. I will try to get that working this week, but there is a good chance I'll need some assistance. Would you prefer that I post questions about that in this same thread to keep all information about using VM with the OpenCM9.04 board in one place or start a new topic?

Best Regards,

Matt

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by chiMT on Oct 22nd, 2018 at 5:38am
Per your tip about using two serial ports for debugging, you wrote this line, but it appears cut off:

>>>You are better using an alternative port for debug or the softwareSerial option which requires 1 pin for trace and 1 pin for "break/pause/variable update". If you hav an

Would we need to be using a device like an external serial USB adapter as advised in this tutorial:
https://www.visualmicro.com/page/User-Guide.aspx?doc=Debugging-With-Different-Ports.html

The part that we are trying to understand is using this method versus using the software serial where we set the TX/RX pins. If the board is connected through only the main SerialUSB it would seem that we cannot just tell VM different pins to use in software? Would that not need a hardware adapter?

We do use Serial.read() in our sketch which VM tutorials mention will conflict with the debugging.

The documentation on the OpenCM9.04 and it's serial pins is here:
http://emanual.robotis.com/docs/en/parts/controller/opencm904/#io-header

Some clarification to setting up the dual serial ports will help us set everything up in the proper way.

Thank You!

Matt

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by Visual Micro on Oct 22nd, 2018 at 10:17am
Yes a usb converter for the rx/tx of a real hardware serial port will be better. than software serial but the connection is usually the same. It depends on the board, some boards have a proper usb connector for toehr serial ports, some just rx,tx pins. Software serial is okay usually at speed = to or below 56k and takes more cpu power.

The cut off line simply says a hardware serial is best.

In the next release the debug properties for serial,serial1,serial2 etc have been set for the CM9 but your settings will still work.

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by chiMT on Oct 22nd, 2018 at 9:33pm
I wanted to post that we were successful in getting it working today with two ports. We used the recommended Arduino USB 2 Serial micro board and made a custom cable to connect to the TX/RX for Serial2 on the OpenCM9.04.

Here is what we did for anyone else finding this thread who is trying to use VM and the OpenCM9.04

Here is a photo of the set up:
https://imgur.com/a/ERyEfgk

This tutorial explains the setup:
https://www.visualmicro.com/page/User-Guide.aspx?doc=Debugging-With-Different-Ports.html


In properties the remote port is "Serial2"
The Local port is what COM port the "USB 2 Serial micro board" shows up as in Windows.

Here is the TX/RX info for the OpenCM9.04:
http://emanual.robotis.com/docs/en/parts/controller/opencm904/#communication-port

To make the cable we used the Robotis LN-101 cable. We cut off an end and soldered jumper wires to it.
(NOTE: you have to cross the RX/TX cables. RX on the "USB 2 Serial micro board" goes to TX on the OpenCM9.04 and visa versa)

Also of note to newbies: In the VM menu for what port to use for uploading this STAYS on the COM port for the regular SerialUSB. You upload on that port and when it is done the debugger runs on serial2. Then you can start your second program which communicated over SerialUSB.

Hopefully this helps anyone else finding this thread working on the same thing.

Title: Re: Setting up a custom board for debugging (Robotis CM9)
Post by Visual Micro on Oct 23rd, 2018 at 6:05pm
That's great thanks

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.