On Thu, Aug 30, 2007 at 07:16:24AM +0200, Joerg Wunsch wrote:
> [EMAIL PROTECTED] (Erik Christiansen) wrote:
> 
> >    .global some_symbol_if_desired
> 
> >    .section .avrfuses,"a"
> > some_symbol_if_desired:
> >    .byte <fuse_value1>
> >    .byte <fuse_value2>
> >    .byte <fuse_value3>
> 
> Something like that, where we could probably also provide similar
> symbolic names and macros as we do in C.  The preprocessor knows the
> __ASSEMBLER__ symbol for assembly-language jobs.

Can't say I've used it. I just assemble with avr-as, and link with
avr-ld. Poor old avr-gcc doesn't need to figure in Eric's assembler-only
scenario. (Admittedly, using xxxx.S files and the preprocessor allows
use of the 'C' headers, as you've pointed out on occasion.)

Whatever assembler macro magic is needed, it should not be difficult.
:-)

> I'd like to get everything into a single section for all fuses (rather
> than three different sections), as that would make it easier to extend
> the scheme once a new AVR suddenly comes out that needs low, high,
> extended, and superiour fuse bytes ;-), but I don't have a
> proof-of-concept for that idea yet.  

Sounds good. We should then only need:

   .global lfuse, hfuse, efuse, lock, sig

   .section .allavrfuses,"a"
lfuse: .byte <fuse_value1>
hfuse: .byte <fuse_value2>
efuse: .byte <fuse_value3>

   .org <magic_address_2>   ; Relative to the start of the section.
lock:  .byte <lock_byte>

   .org <magic_address_3>   ; Relative to the start of the section.
sig:   .byte <sig_byte>

OK, we may want to prepend '_' to these symbols, for the traditional
and practical reason.

I'm not sure small attachments will make it to the list, but at least
you'll receive the small demo that this works as expected.

> 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. (A ". = 0x????" between input sections is all
that is needed to plonk'em where desired.)

Anyway, the attachments may amuse. (Please ignore RAMEND, I missed
stripping it out for the demo.)

Erik

P.S. Going up to the farm, to battle with >500 trees felled by storms,
some weeks back, so will be off-line for a week, but will try to snoop
the archive tomorrow night, before leaving. Can fix anything on return.
# 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 .allavrfuses,"a"
lfuse: .byte 0x11
hfuse: .byte 0x22
efuse: .byte 0x33

   .org 0x1000   ; Relative to the start of the section.
lock:  .byte 0x44

   .org 0x2000   ; Relative to the start of the section.
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 = 16K
}

SECTIONS
{
  .fuse_stuff      :
    {
      *(.allavrfuses)
    } > fuses
}
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         0x00004000         rw !x

Linker script and memory map

                0x000010ff                RAMEND = 0x10ff

.fuse_stuff     0x00910000     0x2001
 *(.allavrfuses)
 .allavrfuses   0x00910000     0x2001 fuse_demo.o
                0x00911000                lock
                0x00910001                hfuse
                0x00910002                efuse
                0x00912000                sig
                0x00910000                lfuse
LOAD fuse_demo.o
OUTPUT(fuse_demo.elf elf32-avr)

.text           0x00000000        0x0

.data           0x00800100        0x0

.bss            0x00800100        0x0
/* Please read only 1st column. It's dumping 2 bytes of 1 byte data. :-(  */

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  ; ????
        ...

00911000 <lock>:
  911000:       44 00           .word   0x0044  ; ????
        ...

00912000 <sig>:
  912000:       55 00           Address 0x00912000 is out of bounds.
.word   0xffff  ; ????
_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to