Programming an AVR From the Command Line with an Atmel ICE - Page 1
Forum section: electronics / general

author: Kalcifer
author_rank: Regular Contributor
timestamp: May 02, 2021, 01:49:58 am
content: Has anyone had any luck with programming AVR devices with the [Atmel ICE](https://www.microchip.com/DevelopmentTools/ProductDetails/atatmel-ice) from the command line? I've poked around with `avrdude` and `avarice`; however, I haven't had much luck with it. Searching on google yields a pretty mixed bag of results. I'm wondering if anyone here has a basic guide for programming an AVR microcontroller with the Atmel ICE from a command line.Would it be better to simply not use the Atmel ICE, and use something else? I don't have any specific desire to use the Atmel ICE, other than I have one.

author: Kalcifer
author_rank: Regular Contributor
timestamp: May 02, 2021, 06:22:45 pm
content: I have discovered a solution. The process is as follows:1. Compile the projectCode:avr-gcc -mmcu=<device> <code.c> -o a.out # In my case `<device>` was `attiny84a`2. Convert the compiled code into hexCode:objcopy -O ihex a.out a.hex3. Write the hex file into the flash memory of the microcontrollerCode:avrdude -c <programmer_id> -p <device_id> -U flash:w:a.hex # In my case `<programmer_id>` was `atmelice_isp` for the Atmel ICE programmer, and `<device_id>` was `t84` for the ATTINY84A

author: Renate
author_rank: Super Contributor
timestamp: May 03, 2021, 11:25:35 am
content: I like my AtmelICE.I don't like Atmel Studio very much.Especially the atbackend stuff is a train wreck.I've never tried AvrDude.I wrote my own Windows executable to program from the command line.It uses the Atmel definition files *.atdf for device parameters.It works fine, but I'm not sure that it's ready for prime time.I also like that DGI (Data Gateway Interface) is supported on the AtmelICE.In Atmel Studio this is inconvenient.With another Windows executable I make DGI seamless.See:https://www.eevblog.com/forum/microcontrollers/need-advice-to-buy-an-avr-isp-programmer-please!/msg3419434/#msg3419434

author: Kleinstein
author_rank: Super Contributor
timestamp: May 03, 2021, 02:02:18 pm
content: I have used AVRDude quite a bit, though with other simpler ISP programmers not directly supported from withoin ARVStudio. I have a simple batch file written for the usual flash task, but one can of cause enter the full command each time.Programming the fuses is a bit more complicated, but so far it worked.With the AtmelICE I would prefer the Atmel tool, at least for the fuses.

author: ajb
author_rank: Super Contributor
timestamp: May 03, 2021, 05:48:36 pm
content: I've done this a bit using atprogram, which is found in the "atbackend" folder in the Atmel Studio install directory. I went back and found a little thing I wrote a while ago for one-click programming of a device, here's the key line from it:Code:bin\atprogram --tool AtmelICE --interface SWD --device ATSAMD11D14AM --force --clock 4MHz --externalreset info --signature chiperase program -f app/program.elf --verify > tmplogThe "> tmplog" at the end just redirects output to a temporary file so that it can be parsed to check for errors. This is for one of the ATSAM (ARM) devices obviously, but I believe atprogram will work with any target the Atmel ICE supports. The interface flag says that "aWire, debugWIRE, HVPP, HVSP, ISP, JTAG, PDI, UPDI, TPI, and SWD" are all supported, so that's pretty comprehensive, given that the Atmel ICe doesn't support half of those. Looks like it also supports the snap, pickit4, and flip tools. Running atprogram with no parameters will get you a list of the available commands.