[Top][All Lists]

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

Re: [avr-chat] Startup code.

From: Erik Christiansen
Subject: Re: [avr-chat] Startup code.
Date: Wed, 22 Sep 2010 20:20:19 +1000
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

On Wed, Sep 22, 2010 at 10:54:47AM +0200, Robert von Knobloch wrote:
> I need to change the stack pointer initilisation and am having trouble
> finding where the code for this originates in the toolchain.

Yep, only object files are included in the .deb package [1]:

$ avr-gcc -dumpspecs | grep 'crt[0-9]'    # Shows avr-gcc's init choices.

e.g. if mmcu=atmega324p, it's crtm324p.o, and

$ locate crtm324p

shows only: /usr/avr/lib/avr5/crtm324p.o

There's not much in them, as "objdump -d" shows. It's not a lot of work
then, to cut and paste that to make a new crtxxx.S for your needs.

To stop avr-gcc using the default init stuff, I'd use "-nostartfiles",
and add crtxxx.S to the makefile. Just watch out, avr-gcc still
generates do_clear_bss, do_clear_data, exit, and stack references, if
main() exists. Use another function name, if necessary.

If there's any mystery to any assembler directives, such as input
section selection, just shout.

> The 'standard' avr startup sets the stack, bss & heap.
> I use no heap (malloc on a 1K part??) and would like to save code and
> also leave the stack pointer set at top of ram.

Which cpu are you using? AIUI, no heap initialisation occurs if malloc
isn't used. I'm not too sure what code is to be saved then?

Have you tried just setting __stack, to place it where preferred?

> Could someone point me where the source for .init2 lies ? I can only
> find an object file that gets linked in.
> I am using avr-libc 1.4.6.

[1] It has to be in the avr-gcc source, naturally, so fetching that is an
    alternative. But if you modify the default crtxxx.o, then your
    avr-gcc is customised. The above method leaves the toolchain as

Does any of that help?


(I'm on a new host now, with a new postfix install, so I'm hoping this
makes it to the list as well.)

reply via email to

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