Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
armorer
Aug 6, 2012

I like metal.

JawnV6 posted:

Sorry, I don't mean to sound so snippy.

It's just that debug is very, very important. Programmers from cmdline linux land who think they can get by with shoddy practices and printf debugging can easily get to the 90% mark on a project without any red flags then have horrendous integration debug because they can't easily peek at what the software's doing. At that point it's a difficult decision between engineering a one-off solution with an oscilloscope and hardware or changing the entire toolchain. Neither impossible, but I wouldn't want to implement either right up against a deadline.

Notice that everyone who said IDE's weren't necessary backed it up with very good practices. Unit tests, strict development, etc. It takes some expertise to figure out when a debugger isn't necessary.

My preferred approach involves both. I like my build process to be simple and command line based, primarily for the reasons I mentioned in my last post. I like to code in an IDE most of the time though. I actually rather like Atmel's AVR Studio 6. I find it easy to work in, the debugger works well and is intuitive (although conditional breakpoints are not supported), and it's been all I've needed so far. Given that it is built on MS Visual Studio, it's not surprising that it has a solid feature set. I am a huge fan of good debuggers, and consider use of one to be a key skill for developers.

There are certain times when using a debugger is not really an option (like if you are hacking on a linux kernel device driver, and it is crashing on startup) and so it's good to know other effective approaches to debugging, but I am not typically working in those areas.

I take a bit of offense to the statement "Programmers from cmdline linux land who think they can get by with shoddy practices and printf debugging..." because it really isn't like that in my industry. Some of the developers I know who have the best practices work in vi or emacs on linux. When they need to debug something, they dust off Eclipse (typically) and use it just for the debugger. They have just internalized the keyboard shortcuts and general mindset of their preferred editor to the point where their productivity is severely impaired using anything else.

Adbot
ADBOT LOVES YOU

armorer
Aug 6, 2012

I like metal.
In black and white text on a computer screen, the sentence reads like a blanket statement attributing shoddy practices to linux command line folk. There are definitely some people who meet your description, but there are an equal number of Windows/OSX IDE programmers who think they can get by with the same shoddy practices. If we just take the "from cmdline linux land" bit out entirely then I don't think anyone will object.

armorer
Aug 6, 2012

I like metal.
I completely agree, but that still doesn't mean debuggers are not great tools. In the last few weeks I've had to debug two nontrivial things where debuggers were invaluable:

The first was an IE9 table display issue where hidden <td> elements in large tables loaded via ajax and added to the DOM via innerHTML() would randomly still show up. It turns out this is a known IE9 bug, and the workaround is to remove any whitespace around the <td>s. Figuring out what the hell IE9 was doing without stepping through the Javascript and looking at various values would have been dubious at best. The debugger here gave me a quick and easy way to sanity check that the DOM was right and it was in fact IE9 being screwy. I was also able to step through the same area in Chrome and Firefox and see that they ended up with the same DOM. Yes, sure I could have resorted to the Javascript equivalent of printf - alert() - but it would have been really, really painful to debug that way.

The second was a server side issue in Java with Lucene, where multiple distinct servers were sharing an index file and one was leaking a file lock over an NFS mount. Tracking that one down required remotely connecting a debugger to multiple machines simultaneously and stepping through the contested area of code on each box in lock step. Doing this without a proper debugger is outright impossible. You simply can't sync JVMs by making System.out.println() calls.

A debugger is necessary sometimes, and if you don't know how and when to use one, you are simply not going to be effective at solving certain problems. Hopefully your development practices are good, and you rarely run into those issues, but they are sometimes out of your control (IE9, NFS weirdness).

On the embedded side of things, I am still a complete novice. I find the debugger very useful for mundane things like confirming that my understanding of what registers get updated on different interrupts is actually right. I'll read the datasheet and think I know what it's saying, but then step through my code in the debugger and realize that I misunderstood it slightly. It makes it much easier and faster to see what is actually going on when you really aren't sure.

armorer
Aug 6, 2012

I like metal.
No I admit that I read it negatively. I doubt I'm the only one who did so, but I don't expect or want any apology.

armorer
Aug 6, 2012

I like metal.
I have zero experience with it, but you could always stick it in a VM if you want to try it out without interfering with another install.

armorer
Aug 6, 2012

I like metal.

Luigi Thirty posted:

I can't get the drat Dragon to connect to my new ATMega. I have a 10-pin JTAG to 6-pin ISP cable, plug it into the Arduino the only way it fits (it's notched and the notch runs into a plastic header if you put it in backwards). Atmel Studio says VTarget is 2.6V and it can't read the device signature, saying it can't enter programming mode. This is a brand-new ATMega328P straight out of the box. They're both connected to the computer via USB. Now I'm afraid that I damaged components on the board as well other than the AVR.

I should have just ponied up more for the one with the bootloader pre-loaded so I'd know if it was me or the board :suicide:

Can you post a picture of how everything is wired up? I've had a similar issue when I wasn't providing power to the chip correctly.

armorer
Aug 6, 2012

I like metal.
I say wired up because I've only used my dragon to program chips in a ZIF header, so I have to do some jumpering to get all the connections in place. Are you providing power to both boards? Have you tried using an ISP cable instead of your JTAG to ISP cable? The dragon docs are here and may be of some use.

Edit: Basically to program a chip onboard the arduino, I think you want to be doing this.

armorer fucked around with this message at 20:43 on Feb 21, 2014

armorer
Aug 6, 2012

I like metal.
Please don't do that, you can get this to work pretty easily I think. First of all you are connected to the wrong header on the Arduino. That header is to program the USB chip, you want the other 6 pin header.


Second, you will probably need a straight 6 pin cable, because the Dragon is expecting to sense a voltage on one of the ISP header pins. It might work though if you use the Dragon in JTAG mode, I have never tried using a cable like you are.

armorer
Aug 6, 2012

I like metal.
This image give you the pin out for the ICSP header.

The "correct" way to do this is with a 6 pin cable going from the ISP header on the dragon to the ICSP header on the Arduino. Any chance you can get such a cable? Or maybe cut down an old floppy drive cable you have lying around?

armorer
Aug 6, 2012

I like metal.

JawnV6 posted:

I'm not sure this is applicable, but when I've used the Dragon to program targets I've either powered it just from the Dragon or not connected the VCC at all. From here: http://www.atmel.no/webdoc/avrdragon/avrdragon.isp_description.html


It's confusing that you're powering it from both sides? Not sure if I just misread your description.

That quote doesn't apply here. That is saying that if you are trying to program a chip on the Dragon itself, you need to jump from VCC to pin 2 on the ISP header. When you are programming an off board chip though you should just connect header to header. The thing that is goofy in what he is doing is that he is running from the dragon JTAG header over to the arduino's ICSP header. I have never tried that, but if it works at all you'll need to tell Atmel Studio that you are using JTAG, not ISP.

Edit: Sorry about the double post. I should have just edited my previous comment.

armorer
Aug 6, 2012

I like metal.

Luigi Thirty posted:

I took a hacksaw to one end of a floppy cable and just jammed the other end on the Dragon and now I get a device signature and 5V reading. :toot:

e: And half an hour later I've set the fuses and burned the bootloader, it's running the Blink program, and I've got stuff on the way to make a proper cable for next time I blow it up so I won't need this monstrosity of a cable. :sun:

Now just to make sure from my cursory research, I have to cut the marked reset enable trace to allow Debugwire debugging, after which I have to press the reset button on the board when I'm uploading something until I reconnect them? Why isn't it just a two-pin jumper I can yank when I need to?

Awesome! I'm glad you got it working. As for the reset enable trace, I really don't know because I haven't used the Dragon in the manner that you are.

armorer
Aug 6, 2012

I like metal.

more like dICK posted:

I'm looking to move from an Arduino to something a bit less "magical". Are TI MSP430's a good starting point?

You could look into AVR as well, since you already have one in your Arduino.

armorer
Aug 6, 2012

I like metal.

PDP-1 posted:

Atmel Studio 6.2 (set up for an ATtiny24) is taking this ISR handler code

code:
int ISR(TIM1_COMPA_vect)
{
    return 0;
}
and returning this warning message: "type of 'TIM1_COMPA_vect' defaults to 'int' [enabled by default]".

It spits up even more warnings if I remove the initial int or the return 0 which I don't think I've ever needed to include in an ISR declaration before. Any idea what is causing this issue?

I am pretty sure you should just do
code:
ISR(TIM1_COMPA_vect)
{ ... }
What warnings does it spit out in that case?

armorer
Aug 6, 2012

I like metal.
A long time ago I made a post in here about getting up and running doing AVR programming on windows. I said I would follow up at some point with a linux walkthrough. Is there interest in that still? I could write up something that goes through the various free linux command line tools, including debugging.

armorer
Aug 6, 2012

I like metal.

Aurium posted:

I think it would be great if you did. Debugging is of particular interest to me.

Okay, I got debugging working using avarice and gdb. You could front-end gdb with something if you want, but I won't go into that. In my write-up I'll be using an AVR Dragon, Mint 16 (out of date, should probably work on any more recent Ubuntu/Debian-based distro), and an atmega328p. The atmega328p doesn't support JTAG, so I'm using debugWire, but it should be even easier to do on an AVR chip that supports JTAG.

Adbot
ADBOT LOVES YOU

armorer
Aug 6, 2012

I like metal.

Popete posted:

If you could writeup something on using an AVR emulator on Linux that would be cool. A guide to setting up and using simavr for instance.

I will see about adding that in. I haven't had time to do the writeup yet, but I have everything prepared for it other than running an emulator. It is a pretty solid thing to add though so I'll see what I can do.

  • Locked thread