avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] EEPROM section overlapping bootloader in stuffed mega


From: Theodore A. Roth
Subject: Re: [avr-gcc-list] EEPROM section overlapping bootloader in stuffed mega8
Date: Sun, 22 Feb 2004 21:21:07 -0800 (PST)

On Sun, 22 Feb 2004, Louis Beaudoin wrote:

> It should be as simple as asm volatile("jmp 0x1800"), but the gcc 
> assembler doesn't support the jmp instruction for the mega8 (yes, it is 
> part of the mega8's instruction set).  rjmp could work, but I don't know 
> how to make it point to address 0x1800, as I don't know the rjmp 
> instructions location at compile time.

You could put a naked function in your app at a specfic address using a
.bootjmp section. Once you have the function placed, you can then calculate 
the rjmp to the bootloader. You'd need to add something like this to your 
link command:

  --section-start=.bootjmp=<fixed address of bootjmp() function>

And define bootjmp() something like this:

  #define ATTR_NAKED        __attribute__ ((naked))
  #define ATTR_BOOT_JMP     __attribute__ ((section (".bootjmp")))

  void bootjmp (void) ATTR_NAKED ATTR_BOOT_JMP;

  void
  bootjmp (void)
  {
      asm ("rjmp <addr of base of bootblock>" "\n\t");
  }

If you place the .bootjmp section at the last word of the application before
the boot block, your rjmp would probably be "rjmp .+0" (or would that be .+2
??). This would only cost you two bytes of app space and can avoid linking
to your bootloader. Using a jmp insn would cost you 4 bytes.

It might also help to tell gcc that bootjmp() doesn't return using
"__attribute__ ((noreturn))". I don't think this is needed though.

Hope that helps.

Ted Roth


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list


reply via email to

[Prev in Thread] Current Thread [Next in Thread]