Using atprogram to program Atmega328 binary and fuse

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am trying to use atprogram of Atmel Studio 6.0 to program binary and fuse into atmega328. Full documentation for atprogram is hard to find.

Suppose I have fuse value below for Atmega328;
Extended: 0xef
High: 0xeF
Low: 0xff

What is the command to program the fuse value?

How about the command for programming the elf file?

Has someone tried something similar?
Thank you very much.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As a general rule, you just type "atprogram" and you will get some helpful response.
Other thing to try are:
atprogram -?
atprogram -h
atprogram --help

Then of course, you can always Google "atprogram help"

Untested. I just typed without looking.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
As a general rule, you just type "atprogram" and you will get some helpful response.
Other thing to try are:
atprogram -?
atprogram -h
atprogram --help

Then of course, you can always Google "atprogram help"

Untested. I just typed without looking.

David.

I have tried them but cannot find good documentation on programming fuses. I don't mind trial and error for other kinds of programming but fuses can cause permanent damage. I wonder if someone has tried programming fuse for Atmega328 here. Thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I have tried them but cannot find good documentation on programming fuses.

atprogram is "odd" in that it has two levels of help. If you type "atprogram -?" it provides top level, generic help. To get help on specific functionality yuou must type "atprogram help " such as:

C:\Program Files\Atmel\Atmel Studio 6.1\atbackend>atprogram.exe help write
Usage:
    atprogram [options] write 

Information:
    Write to the memory with values entered on the command line. The values
    provided will be written to all selected address spaces. At least one
    address space must be provided.

Options:
    Execute atprogram without arguments to list available options.

Arguments:
  -fl --flash               Write to flash. tinyAVR/megaAVR and AVR XMEGA
                            only.
  -ee --eeprom              Write to eeprom. tinyAVR/megaAVR and AVR
                            XMEGA only.
  -us --usersignature       Write to user signature.
  -fs --fuses               Write to fuses.
  -lb --lockbits            Write to lockbits.
  --values (value)          Hex encoded values to write, ex: 0102040A0F
  -o  --offset (offset)     Values is written from this offset.
  -v  --verify              Verify memory contents after write.

Examples:
  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.

So I guess you'd be looking at using "atprogram -t jtagice3 -i ISP -d atmega328 -fs --values EFEFFF" or something like that. What's not clear is what order you specify ext/high/low for the actual value to be programmed. That's left as an exercise for the reader (though be warned you could lose a few AVRs while "experimenting"!)

Personally I think I'd just use avrdude as there's more widespread examples and support for it!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Regarding fuses, you can determine the hex value of the fuses via http://www.engbedded.com/fusecalc/ or by using the Programming Dialog in AS6.

I would agree that fuses tend to be a one-off operation.
So you get the desired value(s) and then place them in your .BAT or Makefile. Or you paste the command line in the "Post Build" section of your AS6 Project.

On my laptop, I have a "atprog.bat" that invokes the actual "atprogram.exe"
On this Desktop, I can only get to "atprogram.exe" via AS6->Tools->CommandLine

Everyone has their own Fuse requirement.
Commonly, you would remove CKDIV8 and set BOD for 4.3V (5V target) or 2.7V (3.3V target)

If you are using a crystal, select High-Freq Crystal with slowest SUT.

If you have a Bootloader, you need to set BOOTRST and BOOTSZn.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Since I am working on something similar I thought I would clarify this for future searchers so that chips don't get wasted needlessly.

 

clawson wrote:
So I guess you'd be looking at using "atprogram -t jtagice3 -i ISP -d atmega328 -fs --values EFEFFF" or something like that. What's not clear is what order you specify ext/high/low for the actual value to be programmed. That's left as an exercise for the reader (though be warned you could lose a few AVRs while "experimenting"!)

The order for the fuses following --values is low/high/ext.

 

To program the stock fuses for an ATmega328p the command "atprogram -t atmelice -i ISP -d atmega328 -fs --values 62D9FF" would be used.

C:\>atprogram -d atmega328p -t atmelice -i isp write -fs --values 62D9FF
Firmware check OK
Write completed successfully.

C:\>atprogram -d atmega328p -t atmelice -i isp info
Firmware check OK
Tool atmelice has firmware version: 1.16
Target voltage: 5.07 V

Device information:

Name:       atmega328p
JtagId:     N/A
CPU arch.:  AVR8
Series:

Memory Information:

Address Space    StartAddress            Size

prog                      0x0          0x8000
  FLASH                   0x0          0x8000
  BOOT_SECTION_1       0x7e00           0x200
  BOOT_SECTION_2       0x7c00           0x400
  BOOT_SECTION_3       0x7800           0x800
  BOOT_SECTION_4       0x7000          0x1000

signatures                0x0             0x3

fuses                     0x0             0x3

lockbits                  0x0             0x1

data                      0x0           0x900
  REGISTERS               0x0            0x20
  MAPPED_IO              0x20            0xe0
  IRAM                  0x100           0x800

eeprom                    0x0           0x400

io                        0x0            0x40

osccal                    0x0             0x1

Signature:  0x1e950f
OscCal:     0x93
Lockbits:   0xff

Fuses:
EXTENDED (0b11111111):
   BODLEVEL      0x7

HIGH (0b11011001):
   RSTDISBL      OFF
   DWEN          OFF
   SPIEN         ON
   WDTON         OFF
   EESAVE        OFF
   BOOTSZ        0x0
   BOOTRST       OFF

LOW (0b1100010):
   CKDIV8        ON
   CKOUT         OFF
   SUT_CKSEL     0x22

EDIT: I do like the display of the fuses , except the low fuse binary representation does not display the most significant bit. :\  Formatting could be improved upon.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Wed. Dec 31, 2014 - 02:43 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't know about atprogram.

My recollection is that with avrdude, one can just hand it two ELF files and it will do the right thing.

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wonder why you posted more than a year later...?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd thought the thread was more recent.

Don't know why.

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Because everyone used to use as4, and it had an auto checkbox to do fuses then flash then eeprom. That isnt in as7 so everyone is looking for a way to burn a run of bds with fuses and flash and eeprom. I have a bat file that calls avrdude, but get stk500v2 timeout. I have a bat file that calls atprogram and cant make that work either. Using as7 on win7, I have an avrispmkII that has been upgraded by as7. Did that break calling it from avrdude? Can anyone burn any avr from a bat file using avrispmkII and avrdude? If so, please post the bat file. Thanks.

 

OK.. update... using as7 on win7, avrispmkII, from device programming dialog, program flash once, program fuses once, then go to production dialog and save elf file in same dir as hex file, THEN in production dialog, hit program.

 

 

 

Imagecraft compiler user

Last Edited: Mon. Feb 22, 2016 - 06:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I know it's a little late, but...  This link to mass programming devices in mass production, has a section (2) on Atprogram Utility User Guide  in their Using Atmel-ICE for AVR® Programming In MassProduction.