Author Topic: Programming an AVR From the Command Line with an Atmel ICE  (Read 274 times)

0 Members and 1 Guest are viewing this topic.

Offline Kalcifer

  • Regular Contributor
  • *
  • Posts: 65
  • Country: ca
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.
« Last Edit: May 02, 2021, 02:24:26 am by Kalcifer »
 

Offline Kalcifer

  • Regular Contributor
  • *
  • Posts: 65
  • Country: ca
Re: Programming an AVR From the Command Line with an Atmel ICE
« Reply #1 on: May 02, 2021, 06:22:45 pm »
I have discovered a solution. The process is as follows:

1. Compile the project
Code: [Select]
avr-gcc -mmcu=<device> <code.c> -o a.out    # In my case `<device>` was `attiny84a`
2. Convert the compiled code into hex
Code: [Select]
objcopy -O ihex a.out a.hex
3. Write the hex file into the flash memory of the microcontroller
Code: [Select]
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
    « Last Edit: May 02, 2021, 06:25:30 pm by Kalcifer »
     

    Online Renate

    • Super Contributor
    • ***
    • Posts: 1085
    • Country: us
    Re: Programming an AVR From the Command Line with an Atmel ICE
    « Reply #2 on: May 03, 2021, 11:25:35 am »
    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
     

    Offline Kleinstein

    • Super Contributor
    • ***
    • Posts: 9012
    • Country: de
    Re: Programming an AVR From the Command Line with an Atmel ICE
    « Reply #3 on: May 03, 2021, 02:02:18 pm »
    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.
     

    Offline ajb

    • Super Contributor
    • ***
    • Posts: 2025
    • Country: us
    Re: Programming an AVR From the Command Line with an Atmel ICE
    « Reply #4 on: May 03, 2021, 05:48:36 pm »
    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: [Select]
    bin\atprogram --tool AtmelICE --interface SWD --device ATSAMD11D14AM --force --clock 4MHz --externalreset info --signature chiperase program -f app/program.elf --verify > tmplog
    The "> 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  :P.  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.
    « Last Edit: May 03, 2021, 05:52:24 pm by ajb »
     


    Share me

    Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
    Smf