On Thu, Aug 30, 2007 at 04:55:02PM +1000, Erik Christiansen wrote:
> On Thu, Aug 30, 2007 at 07:16:24AM +0200, Joerg Wunsch wrote:
> > If all else fails, we could still opt for differently named input
> > section (lfuse, hfuse, efuse), and combine them in the linker script
> > into one output section.  Again, that would be similar to combining
> > .eeprom* input sections into just one .eeprom output section right
> > now.
> 
> Actually, I think that's neater, not least because the magic addresses
> are not seen in the assembler source, but reside only in the linker
> script, where they belong. 

The attached does it more neatly, doesn't it?   :-)

Erik

P.S. If there's any assembler macro mucky-stuff left to do, I'm
available. (Week after next. :-)
# avr-as -alcmns fuse_demo.s -o fuse_demo.o > fuse_demo.lst
# avr-ld -T fuse_demo.ld -M -o fuse_demo.elf fuse_demo.o > fuse_demo.map

   .global lfuse, hfuse, efuse, lock, sig

   .section .avr_fuses,"a"
lfuse: .byte 0x11
hfuse: .byte 0x22
efuse: .byte 0x33

   .section .avr_lock,"a"
lock:  .byte 0x44

   .section .avr_sig,"a"
sig:   .byte 0x55


/* Based on avr-gcc's default linker script, for normal executables */
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
OUTPUT_ARCH(avr:4)

/* ATmega64 Constants */
RAMEND = 0x20 + 0xE0 + 0x1000 - 1 ;   /* Registers + I/O + RAM */

MEMORY
{
  text   (rx)   : ORIGIN = 0, LENGTH = 62K
  boot   (rx)   : ORIGIN = 62K, LENGTH = 2K
  data   (rw!x) : ORIGIN = 0x800100, LENGTH = 4K
  eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 2K
  fuses  (rw!x) : ORIGIN = 0x910000, LENGTH = 1K
}

/* This time we're being less profligate with the address space. */

SECTIONS
{
   .fuse_stuff      :
    {
      *(.avr_fuses)
      . = ALIGN (0x10);
      *(.avr_lock)
      . = ALIGN (0x10);
      *(.avr_sig)
    } > fuses
}
fuse_demo.elf:     file format elf32-avr

Disassembly of section .fuse_stuff:

00910000 <lfuse>:
  910000:       11 22           and     r1, r17

00910001 <hfuse>:
  910001:       22 33           cpi     r18, 0x32       ; 50

00910002 <efuse>:
  910002:       33 00           .word   0x0033  ; ????
        ...

00910010 <lock>:
  910010:       44 00           .word   0x0044  ; ????
        ...

00910020 <sig>:
  910020:       55 00           Address 0x00910020 is out of bounds.
.word   0xffff  ; ????

/* Note: The above info message is of no import. */
Memory Configuration

Name             Origin             Length             Attributes
text             0x00000000         0x0000f800         xr
boot             0x0000f800         0x00000800         xr
data             0x00800100         0x00001000         rw !x
eeprom           0x00810000         0x00000800         rw !x
fuses            0x00910000         0x00000400         rw !x

Linker script and memory map

                0x000010ff                RAMEND = 0x10ff

.fuse_stuff     0x00910000       0x21
 *(.avr_fuses)
 .avr_fuses     0x00910000        0x3 fuse_demo.o
                0x00910001                hfuse
                0x00910002                efuse
                0x00910000                lfuse
                0x00910010                . = ALIGN (0x10)
 *fill*         0x00910003        0xd 00
 *(.avr_lock)
 .avr_lock      0x00910010        0x1 fuse_demo.o
                0x00910010                lock
                0x00910020                . = ALIGN (0x10)
 *fill*         0x00910011        0xf 00
 *(.avr_sig)
 .avr_sig       0x00910020        0x1 fuse_demo.o
                0x00910020                sig
LOAD fuse_demo.o
OUTPUT(fuse_demo.elf elf32-avr)

.text           0x00000000        0x0

.data           0x00800100        0x0

.bss            0x00800100        0x0
_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to