Cheap Atmega debugging interface? - Page 1
Forum section: electronics / general

author: splin
author_rank: Frequent Contributor
timestamp: March 15, 2017, 01:52:14 pm
content: I want to hack some electronic thermostatic radiator valves which use an atmega169P. I have a USBasp which I can use to program them but I can't find find any really low cost solution for debugging - other than printfs.I can get dirt cheap interfaces, such as STLink, for debugging ARM chips so I'm a bit surprised that there doesn't seem to be anything obvious for AVRs given how long they have been around and their popularity. Is it because the debugging interface isn't fully documented and Atmel is/was trying to get revenue from selling tools? If so, it seems to be another good reason not to use AVRs.

author: up8051
author_rank: Frequent Contributor
timestamp: March 15, 2017, 03:47:33 pm
content: AVR Dragon:http://uk.farnell.com/atmel/atavrdragon/in-system-debugger-programmer/dp/1455088

author: splin
author_rank: Frequent Contributor
timestamp: March 15, 2017, 04:35:51 pm
content: Quote from: up8051 on March 15, 2017, 03:47:33 pmAt £50 including VAT it's hardly cheap - it's 5x the cost of the TRV I'd like to debug. I probably wouldn't have a use for it after this so I was looking for something really low cost.

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: March 15, 2017, 08:16:54 pm
content: How complex can your software be if it's only controlling a valve?I don't use a hardware debugger because:-1. Printf or toggling a pin will tell you 99% of what you want to know in real time.2. AVR has a simulator that lets you step through code withoutanyhardware.3. If the your program isn't working properly then you should review the source. A hardware debugger is only required when the code is bug free but the device still doesn't work (ie. never!).

author: thm_w
author_rank: Super Contributor
timestamp: March 15, 2017, 09:44:35 pm
content: There are some AVR JTAG ICE clones on aliexpress for $4.It looks like it will work for 169 with some limitations:http://www.instructables.com/id/Getting-Started-With-AVR-JTAGICE-Clone/http://www.electrodragon.com/w/AVR_USB_JTAG_ICE_ProgrammerMay need to use the old IDE.Also you will have to bring out all JTAG pins as opposed to just the few needed for the ISP debugger.Consider if that is worth ~$60 to you.Quote from: Bruce Abbott on March 15, 2017, 08:16:54 pmSure, but I'd rather spend a few dollars on a hw debugger, see exactly whats going on, and save time debugging. Live display of multiple variables is possible (with some).But I agree the simulator is useful, and you are free to use whatever method you like.

author: splin
author_rank: Frequent Contributor
timestamp: March 15, 2017, 10:04:11 pm
content: Quote from: Bruce Abbott on March 15, 2017, 08:16:54 pmIt's not my code - it is 100% assembler - about 5200 lines of it including blank lines and comments. It isn't particularly complex but it has to regulate temperature, manage user input from switches to set time and temperatures, drive an LCD etc.QuoteFair enough, everyone has their own preferences. I like to use debuggers for some problems because it's usually much easier and faster than writing shed loads of printfs into the code, rebuilding, programming, testing, repeat ad nauseum. And spending two days tearing your hair out trying to work out why it doesn't work only to find it was one of your bits of test code that overflowed the stack or whatever.The simulator may be a useful option however. Thanks for pointing that out.QuoteSorry, but that is total rubbish - but apologies if it was a tongue in cheek comment. Sure review your code for the thousandth time and still you can't see what is wrong because you missed the small print in the footprint on page 1147 of the reference manual that says that flag xyz can be cleared by some unrelated peripheral in some obscure conditions. All your printfs and port twiddling didn't help because they changed the timing/memory layout/stack usage etc.Or your processor simply runs off into the ether because you misconfigured one of the clock domains or failed to ramp the clock speed up sufficiently slowly to allow the PLL to track it.Or you use inadvertantly use an uninitialised pointer in an interrupt routine which mangles the stack. Good luck finding that with printfs.Or you get a hard fault (on an ARM Cortex) when you call an assembler function, supplied by ARM, with ".section text" instead of ".section .text" which causes the linker to fixup the call with a branch opcode which is invalid for that target type. Examining assembler output from GCCs compilation of your C code doesn't help because it was the linker that threw a wobbly. Examining the diassembled code in the debugger revealed the problem. No amount of printfs would help.In all these cases your code is wrong but a good debugger can make your life very much easier.

author: splin
author_rank: Frequent Contributor
timestamp: March 15, 2017, 10:24:16 pm
content: Quote from: thm_w on March 15, 2017, 09:44:35 pmThat looks very promising - exactly the sort of thing I was looking for - thanks. The jtag pins are already connected to test lands so not a problem.I wonder why it doesn't work with later builds of Atmel Studio? Have they deliberately made sure that clone ICEs don't work because they think selling $60 ICEs is an important part of their revenue stream and more important than making AVR development as easy and acessible to as many developers as possible including hobbyists?

author: thm_w
author_rank: Super Contributor
timestamp: March 15, 2017, 10:45:32 pm
content: Quote from: splin on March 15, 2017, 10:24:16 pmThey came out with the JTAG ICE Mk2 (there are clones of that available as well, but much more expensive). It supports the newer debugwire and other formats, and is supported in the latest IDE.So they probably stopped supporting the MK1 after that came out.List of supported debuggers for avr:http://www.atmel.com/webdoc/atmelstudio/supported.devices.AVR.Mega.htmlhttp://www.avrfreaks.net/forum/avr-studio-7-jtag-ice(mentions AS4.18 should work)It is a shame they never came out with a low cost basic debugger like the stlink. I don't know how they decide this, part of it is complexity, the avr dragon is ridiculously complex compared to a stlink.

author: westfw
author_rank: Super Contributor
timestamp: March 16, 2017, 12:24:05 am
content: QuoteAnd the JTAG-ICE3, and (current product) the Atmel-ICE.I believe that they don't support their own old JTAG-ICE either.I think I have one. I guess I could check...The Atmel-ICE was recently on sale ($50 off, plus free shipping), but I think that ended 28-Feb.The"bare" Atmel-ICEis comparable in price to the Dragon, and IS the "current product"...

author: obiwanjacobi
author_rank: Super Contributor
timestamp: March 16, 2017, 07:55:33 am
content: Note that not all Atmel devices support debugWire.I had bought an official Atmel ICE (~50,= iirc) only to find out my device didn't support debugWire but it does support Jtag.I now have a adapter cable coming that allows conversion of the 50mil connector to the standard 100mil/0.1".And I can rewire my prototype board to use Jtag instead of ISP.

author: cyberfish
author_rank: Regular Contributor
timestamp: March 16, 2017, 01:06:02 pm
content: Quote from: splin on March 15, 2017, 10:04:11 pmI find the value of debugging to be limited on AVRs (and microcontrollers in general).Most embedded applications are real time, and stopping the CPU throws everything off (timing, interrupts, etc). Conditional printfs do also change timings, but probably not as much as stopping the CPU completely.One thing I do love using a debugger for is to catch memory corruptions though. I just don't get much of that nowadays.

author: Brutte
author_rank: Frequent Contributor
timestamp: March 24, 2017, 07:16:57 pm
content: Quote from: splin on March 15, 2017, 10:24:16 pmThat is/was theirmarketing-fu.