PDA

View Full Version : Anyone use an alternate Arduino IDE? In-Circuit Programmer/Debugger?



TXBDan
05-19-2013, 08:34 AM
I'm getting a little frustrated with the barebones Arduino IDE and FTDI programmer. I feel like I'm running blind. Writing some code, compiling, switching jumpers on the Arbotix, plugging in the FTDI, uploading, unplugging, switch jumpers, test out on robot, repeat repeat. I'd like the ability to trigger break points, watch variables, etc.

I assume an ISP like this http://www.trossenrobotics.com/p/USB-AVR-Programmer.aspx will allow me to do that hardwarewise. Is that, right? Further research shows i might need an AVR Dragon

On the IDE front, Arduino IDE is very barebones and I'm pretty sure doesn't support much for debugging. I'm used to using MPLAB for uCs, MS Visual IDEs, etc.

I've read that you can use Atmel's IDE, Visual C++ for the Arduinos with a little setting up.
http://playground.arduino.cc/Main/DevelopmentTools

Anyone use a more powerful IDE?

Will the combo of an ISP plus a more powerful IDE get me in-circuit debugging? What do you guys use for the bigger projects?

Thanks a lot,
Dan

lnxfergy
05-19-2013, 10:08 AM
An ISP is just that, an In-System Programmer. What you are talking about is On-Chip Debugging (OCD), which requires a JTAG. I've never done OCD on an AVR, so I'm not exactly sure what tools work with what JTAG devices (I also haven't seen all that many people doing, or at least documenting, it).

The "standard" open-source JTAG software is called OpenOCD -- it's generally not for the faint of heart, but it has good integration with gdb/gcc (the toolchain you're using right now under the hood in Arduino). The Atmel IDE also would have JTAG integration, but I'm not sure it can actually understand the binaries created by GCC. In either case, you want to be sure that the software can talk to a particular JTAG device, because while JTAG is really quite standard, the USB-to-JTAG side varies wildly.

-Fergs

tician
05-19-2013, 11:37 AM
In either case, you want to be sure that the software can talk to a particular JTAG device, because while JTAG is really quite standard, the USB-to-JTAG side varies wildly.
Indeed. That fact is an unbelievable PITA.

As for AVR, most AVR models have debugWIRE, but I don't think any non-Atmel ISP/OCD dongles actually support it. I do not recall any except some of the 64+ pin Mega/XMega AVR models having JTAG, and the interface is usually disabled by default (requires setting fuses with an ISP to enable it).

jwatte
05-19-2013, 11:50 AM
I think a Dragon would be the best choice as far as programmers/connectors go. None of the third party ones support anything but the SPI-based programming part.

The problem with JTAG is that you lose several pins on the chip. If you're not using them, no big deal; if you are, well, tough :-)

That being said, I haven't actually found the need to switch all the way to JTAG from Arduino. I made the switch to using an ICSP programmer, and then I can use the serial port for whatever debugging information I need. Couple that with a USB logic analyzer (like the Saleae Logic) and I haven't actually needed a breakpoint yet.

Specifically, embedded controllers need to keep running to keep controlling the devices they're talking to, so expecting to be able to stop in the middle is often not reasonable. Instead, output a stream of debug information, and do "printf" style debugging. (This is very similar to how to debug live server systems, btw.)

KevinO
05-19-2013, 11:53 AM
TXBDan is this all for the Phoenix code problems you are having? That code is pretty solid and nothing really needs to be done aside from a proper CFG file. If it is general curiosity Fergs is spot on about the OCD though I haven't had an arduino project get big enough where I felt like I needed it. The most I've done is setup XBee to output certain variables to output to the serial terminal in the Arduino IDE. That is usually more than enough to debug any issues.

KurtEck
05-19-2013, 12:30 PM
Yep - Several years ago, I did get myself setup to be able to do some jtag on Atmega32s and the like. I was using an JTAGICE_MKII which I normally had connected up to a STK500 board. This was nice, but has it's limitations. Like you needed to have several IO pins brought out to the device and be configured to use for debug. As Jwatte mentioned you lose these IO pins to use for other things.

So now days with Arduino back to stone age. However I do use some other tools when I can. In particular I use logic analyzers. I currently have two from www.saleae.com (The original and the newer 16 pin big sucker). I use these a lot from, checking out serial streams, to servo outputs... When I first started working on the Phantom Phoenix code, I was having lots of problems with the information going to and coming from the AX12s. Used this to find out there were timing issues and made my own driver...

But in addition to these types of things, I use it as a cheap way to check out code. If I have spare IO pins on the board, I start to scatter things like: digitalWrite(...) at key locations. Sometime to simple HIGH/LOW, other times I toggle. Then I can simply start up a long capture, start up the appropriate code and see things like is certain pieces of code being hit. Timings of certain code paths...

Hope that helps
Kurt

TXBDan
05-19-2013, 04:35 PM
No, this isn't for the Phoenix issues, this is for general use. Right now i'm trying to write my own code fairly from scratch. So far i have the IK working for one leg and i can control it with the Commander. Pretty cool!

So far I'm doing well with just serial outputs when i'm connected via FTDI programmer. The problem comes when i have the Xbee plugged in and I want to debug the communication on the Xbee serial connection. I was stuck on this for a bit which is why i was frustrated not being able to see inside, but now that i fixed the communication there I suppose i'm good to go on that serial connection and can go back to using the FTDI connection to the PC for the usual serial output debugging.

Besides the programmer/debugger, is anyone else using a different IDE just for general code writing ease?

Thanks!

jwatte
05-19-2013, 06:48 PM
is anyone else using a different IDE just for general code writing ease?

I use gvim and make. I guess "bash" is my "IDE" then? :-) avrdude for actually programming, with an ICSP programmer.
KurtEck also mentioned that it's important to have other ways of getting data out than just a serial port. I too use the Saleae logic and an oscilloscope for looking at signals, and it's super helpful for many cases.
Sometimes, just reserving a pin for toggling a LED on and off is quite helpful, too! If you have I2C going, spitting out some data on that bus is also helpful, if serial is busy doing something else.

KurtEck
05-19-2013, 07:17 PM
Also for debugging, I forgot to mention, that earlier I rigged up another way to get debug information when using the PhantomX with the Commander controller. I have a real quick and dirty VB application, that I can configure up with two Comm ports. One comm port comes from the Commander and the other goes to the PhantomX. Note: What I normally do is to remove the XBee from the Commander and plug it into my usb xbee connection. So the link to the Robot is still wireless. I plug a usb cable into the commander and use the serial port created for the input connection.

The program is real simple: everything that is received from the Commander is simply echoed out the link to the robot. Everything that is sent from the robot is displayed on the VB Screen in a scrollable listbox...

This helped debug some of the stuff when I wanted to see output. There were some issues about timing of messages showing up in vb, which I think I corrected but it has been awhile. I think I posted this project up on my Going to try... thread. Not sure if I put up to github.
I could if someone wishes to see it or could post zip file.

Kurt

EDIT: For editing programs and the like on the PC, even with Arduino as most of the code is in libraries. I use Programmers Notepad (PN), that was installed when I installed winavr. I also have used AvrStudio but don't currently have that installed as the drivers installed by it for the AvrISP MK2 are not compatible with Arduino... When I was working I used to use Visual Slick but that was awhile ago.

KevinO
05-19-2013, 07:32 PM
I use either Eclipse (or Notepad++ if the change is small) if I'm on my Windows box. Notepad++ is a great little tool if you are just starting to learn programming. Emacs if I'm in Linux.

Xevel
05-19-2013, 11:19 PM
I use ATMEL Studio when I want to code something serious, where performance/timing/code size/ advanced functionalities might be needed.
The Arduino IDE is just good for quick & dirty tests, as soon a you want to have a little control over what is happening you should run away from it fast.

I use the AVR Dragon to program an ATmega644, as JTAG programmer and debugger (I LOVE the "Debug" button that compiles, programs then opens a debug window in a matter of seconds - all the more when programming the same code with an ISP could take dozen of seconds). As far as I know, the documentation is available in the ATMEL Studio help files exclusively.

A while back I used the Polulu AVR ISP but since AVR Studio 5 it started being very unnoying to use (understand: not supported out of the box).

I use most of the time the various debug techniques previously cited (Saleae Logic power!), but having the option to put a break point and step in the code is extremely valuable sometimes. I don't think the small arduinos (Uno, Duemillanove, Leonardo, Mini, etc) can do that though, as far as I know only the big ATmegas have a JTAG port.
Never tried DebugWire. :/