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

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

Re: [avr-gcc-list] GCC Startupcode


From: Theodore A. Roth
Subject: Re: [avr-gcc-list] GCC Startupcode
Date: Mon, 14 Jun 2004 09:12:35 -0700 (PDT)

On Mon, 14 Jun 2004, Andreas Strodl wrote:

> Hi,
>
> I am working on a project where I need a ATmega16 to start up very fast
> after a reset. Since after a reset the startupcode is always executed
> first operation of the main programm starts to late. Now I am thinking
> about modifying the startupcode. Could anyone please tell me were I can
> find that startupcode in the AVRlibc and if there is somthing special
> to care about.

The startup code already has facilities to do want you want so you
shouldn't need to rewrite anything. All you need to do is write a naked
function and insert it into the .init1 section.

Your function should be defined like this:

void myinit(void) __attribute__ ((naked)) __attribute__ ((section (".init1")));
void
myinit(void)
{
  /* do early init stuff */
}

Your init funciton should not have a RET asm insn in it.

If you need to use the stack for anything in your init code, you should
use the .init3 section instead of the .init1 section.

Have a look at this in the "The .initN Sections" section:

  http://www.nongnu.org/avr-libc/user-manual/mem_sections.html

Alternatively, you could write a function named __init() and the reset
vector will jump right into that, but then you would not get the other
.initN sections executing.

It's very instructional to do a disassemble of your rom image and look
through the startup code to see what is going on. You can do that with
avr-objdump like this:

  $ avr-objdump -S rom-image.elf

---
Ted Roth
PGP Key ID: 0x18F846E9
Jabber ID: address@hidden


reply via email to

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