2016. április 4., hétfő

Véletlenül villamosmérnök # Atmel programming

Atmel programming - with AtmelStudio atprogram.exe


What can I do with this program?
You can program ~all of the Atmel microcontrollers. Why good this? Because you can use atprogram application in "shell".

How to use the atprogram?
atprogram.exe

Where do I find?
In standard Atmel installing:
Atmel Studio 6.2
C:\Program Files (x86)\Atmel\Atmel Studio 6.2\atbackend\atprogram.exe
Atmel Studio 7.0
C:\Program Files\Atmel\Studio\7.0\atbackend\atprogram


How to use with parameters?

For example:
First, you need to go program folder (atbackend folder)
JTAG - elf file programming for a SAM4S
atprogram -t samice -i jtag -d atsam4sd32c program -f "C:\Test\example.elf"


But if I have flash and eeprom file?

1. - ISP, atmega2560, slow fuse writing
atprogram -t avrispmk2 -i ISP -cl 50khz -d atmega2560 chiperase write -fs --values EFD8FD


2. - ISP, atmega2560, fast, flash programming
atprogram -t avrispmk2 -i ISP -cl 2mhz -d atmega2560 program -fl --verify -f "C:\Test\flashfile.hex"

3. - ISP, atmega2560, fast, eeprom programming
atprogram -t avrispmk2 -i ISP -cl 2mhz -d atmega2560 program -ee --verify -f "C:\Test\eepromfile.hex"

In this sequence, first erasing the flash and eeprom, after setting fuses (-fs), after programming flash (-fl), and last programming eeprom (-ee)


But if I have .eep EEPROM file, and not .hex file?
Do not worry, there is no problem. The atprogram request .hex file, but AtmelProgram and others development enviroments export EEPROM file to .eep file. Both of them is Intel hex file, you need to rename the .eep file to .hex, and it work well with atprogram application.

But if I want to run one command, not 2-3 command!
You need .elf file, It is containing flash and eeprom and fuses informations.
Or, if you can only programming on a clock (eg. 50khz), you can use more commands in one.

atprgoram -t avrispmk2 -i ISP -d atmega2560 chiperase write -fs --values EFD8FD program --verify -f "C:\Test\flashfile.hex"



Command structure
atprogram [options] [arguments] [ [arguments] ...]


Important options
  • -t
    • Used tool name
    • eg. "avrispmk2", "samice", ...
    • -t avrispmk2
  • -i
    • Programming interface
    • eg. "ISP", "jtag",...
    • -i ISP
  • -cl
    • Programming clock
    • eg. "50khz"
    • -cl 50khz
  •  -d
    •  Programmed device (MCU)
    •  eg. "atmega2560"
    • -d atmega2560
  Some commands in a list
  • write
    • -fs --values
      • fuse
    • --verify
      • verification
    •  atprgoram -t avrispmk2 -i ISP -d atmega2560 chiperase write -fs --values EFD8FD
  • program
    • -c
      • chip erase
    • -fs --values
      • fuse
    • -f
      • programming file
    •  fl -f
      •  programming flash file
    • fl --verify -f
      • programming flash file with verify
      • fl --verify -f "C:\Test\flashfile.hex"
    • ee --verify -f
      • programming EEPROM file
      • ee --verify -f "C:\Test\eepromfile.hex" 
    • [...] program -c  -fs --values EFD8FD --verify -f "C:\Test\flashfile.hex"
    • [...] program -c  -fs --values EFD8FD --verify -f flashfile.hex
  • erase
  • chiperase
    • Full erase
  • info
 You can see, lot of command use with lot of equal parameters.

Parameters
  •  -fs
    • Fuse
  • --verify
    • Verification
  • -c
    • chip erase
  • -f
    • file (program file: flash, eeprom, or elf)

Other commands (from helps)
 Examples:

 atprogram -t avrone -i jtag -d atmega2560 program -c -fl -f source.elf
    Perform chiperase and program only the segments of source.elf that map to flash.

  atprogram -t avrone -i jtag -d at32uc3a0512 program -e --verify -f source.elf
    Erase only affected pages, program all segments in source.elf and verify.

  atprogram -t samice -i jtag -d atsam3s4c program -lb -f lockbits.bin
    Program lockbits as contained in a binary file.
   atprogram -t avrone -i jtag -d atmega2560 write -fl -o 0x10 --values AAFF
    Write the hex-encoded values AAFF to offset 0x10 in the flash of the ATmega2560 device.

  atprogram -t avrone -i jtag -d at32uc3a0512 write -o 0x80800000 --values AAFF
    Write the values AAFF to the user page of an UC3A0512 device.

  atprogram -t avrone -i jtag -d at32uc3b0512 write -fs -o 0xfffe1410 --values FFFFFFFE
    Program LOCK0 in FGPFRLO of an UC3B0512 device.

  atprogram -t samice -i jtag -d atsam3s4c write -lb --values aaaa
    Program lock regions 1,3,5,7,9,11,13 and 15 of an atsam3s4c device.

 atprogram -t jtagice3 -i jtag -d at32uc3b0512 program -f e:\file.elf
  atprogram -t avrone -i pdi -d atxmega128a1 chiperase
  atprogram -t avrdragon -i jtag -d atxmega128a1 erase -ap
    Erase the application segment of the device.

  atprogram -t avrone -i jtag -d at32uc3a3256 erase -up
    Erase the user page on the connected device.

  atprogram -t avrone -i jtag -d at32uc3b0512 erase -o 0x80000000 -s 0x200
    Erase 0x200 bytes in the flash segment of a AVR UC3 device.

  atprogram  -t samice -i jtag -d atsam3s4c erase -o 0x400000 -nu -s 0x100
    Erase 0x100 bytes in the flash segment of a SAM device. Do not unlock pages.
   

2 megjegyzés:

Unknown írta...

Hi, could you please help me.
I want to read back hex file to check specific key number. I can read back by using atmel studio but I don't know where I did wrong when use command line

atprogram -t atmelice -i swd -d ATSAMD21E16B read

an error happen like this
[Error] An error occurred executing a command (read): No matching segment memory found on the device: None

or

[ERROR] Could not establish connection to device. Please check input parameters, hardware connections, security bit, target power, and clock values.
Reading ARM chip id failed. (TCF Error code: 15)

I stuck with it for few days and still not find any solutions

Fasten90 írta...

Hi

Please try the
atprogram -t atmelice -i swd -d ATSAMD21E16B info
It shall print out some important informations.

Or could you check your debugger type (It is Atmel-ICE?), connection tpye (It is SWD - 6-7pin?) and device/MCU type?
Perhaps, firstly try the Atprogram GUI from Atmel Studio!
Check the SWD connection it is okay or not.

And see this:
atprogram read help
Check did you use the read command correctly or not? (Shall you write the address?)

Csilliárdossá válás - Pénzügyi kurzusok + csoportok

Kurzusok és szolgáltatások Bence Balázs / Portfólió Tikos Gergő Érthető pénz / Varga Dani MakeItCount Tóth Dávid pénzügyi mentor  Tudástá...