help with avrdude and fuse program from elf file.

Last post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all..
I've used lock.h and fuse.h for include fuse configuration in my c code.

#if defined A	
  FUSES = {
    .low = 0xFF,
    .high = (FUSE_SPIEN & FUSE_JTAGEN & FUSE_OCDEN),
    .extended = 0xFF,};
  LOCKBITS = (LB_MODE_1 & BLB0_MODE_1 & BLB1_MODE_1);
#elif defined B
  FUSES = {
    .low = 0xFF,
    .high = (FUSE_SPIEN),
    .extended = 0xFF,};
  LOCKBITS = (LB_MODE_3 & BLB0_MODE_1 & BLB1_MODE_1);
#else
...

Ok. now I want to program all with avrdure. I use a terminal string like this

avrdude -patmega644p -cavrisp2 -Pusb -e -V -u -Uflash:w:file.elf -Ueeprom:w:file.elf -Uhfuse:w:file.elf -Ulfuse:w:file.elf -Uefuse:w:file.elf -Ulock:w:file.elf

No problem for flash, eeprom and lock area, but avrdude makes error when programming fuses.
The problem is that the area in the elf file is called only fuse, but avrdude wants hfuse, lfuse and efuse.

avrdude man pages
-U memtype:op:filename[:format]
                   Perform a memory operation as indicated.  The memtype field
                   specifies the memory type to operate on.  The available
                   memory types are device-dependent, the actual configuration
                   can be viewed with the part command in terminal mode.  Typ"
                   ically, a device's memory configuration at least contains
                   the memory types flash and eeprom.  All memory types cur"
                   rently known are:
                   calibration  One or more bytes of RC oscillator calibration
                                data.
                   eeprom       The EEPROM of the device.
                   efuse        The extended fuse byte.
      
             flash        The flash ROM of the device.
                   fuse         The fuse byte in devices that have only a sin"
                                gle fuse byte.
                   hfuse        The high fuse byte.
                   lfuse        The low fuse byte.
                   lock         The lock byte.
                   signature    The three device signature bytes (device ID).

There is a workaround for this?
Or the only solution is to make a script that extract the fuse area with

avr-objdump -d -S -j.fuse file.elf
file.elf:     file format elf32-avr
Disassembly of section .fuse:
00820000 <__fuse>:
  820000:	ff 1f ff

and store single byte in variables and finally pass there to avrdude?

Thanks in advance.

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

AVRDUDE currently does not read ELF files. You have to extract the
respective contents into e.g. an intel hex file first, using
avr-objcopy.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.
Please read the `General information...' article before.

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

dl8dtl wrote:
AVRDUDE currently does not read ELF files. You have to extract the
respective contents into e.g. an intel hex file first, using
avr-objcopy.

This is not completely exact because if you pass to avrdude an elf file, avrdude program the device and recognise the correct area exept for the fuse area..
However for now I will use avr-objcopy for extract fuse information.

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

Quote:

This is not completely exact because

You do know who Jörg is don't you? (maybe check the avrdude source or manual)

 

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

clawson wrote:
Quote:

This is not completely exact because

You do know who Jörg is don't you? (maybe check the avrdude source or manual)

I'm sorry, I did not want to disrespect.

But I've tryed to pass an elf file to avrdude and it works. I thought that was supported.
This is the reason for my "This is not completely exact because " sentence.

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

> But I've tryed to pass an elf file to avrdude and it works.

It depends from your definition of "it works".

It will simply not recognize the file format at all, and fall back
to "binary", programming the plain ELF file into your flash ROM.
If the ELF file is short enough to fit, yes, it will also write
the fuse section. ;-)

I'm not sure this is what you had in mind though...

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.
Please read the `General information...' article before.