[Top][All Lists]

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

Re: [avr-chat] Startup code.

From: Robert von Knobloch
Subject: Re: [avr-chat] Startup code.
Date: Wed, 22 Sep 2010 12:47:29 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv: Gecko/20100915 Thunderbird/3.1.4

On 22/09/10 12:20, Erik Christiansen wrote:
> 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
>     standard.
> Does any of that help?
> Erik
> (I'm on a new host now, with a new postfix install, so I'm hoping this
> makes it to the list as well.)
Hi Erik, nice to hear from you again.
Your Postfix made it to the list OK.

I assume a .deb file is a Debian package?
I use Suse and compile the toolchain  from source (so I 'know' what I'm
getting :-)

I couldn't find the startup code as source in the sources, only as an
object file which confused me - there is be no crttn13.S, only crttn13.0.
I really wanted to see what exactly occurs in the various .initx files
as the docs only describe function, not actual code and I want to see
what I can change ;-)

It may be that there is no heap, as such, allocated, but the standard
startup puts the stack pointer in the middle of ram (expecting a heap?),
which doesn't seem right for me.

I also sometimes have to use 'alternative' processors due to supply
problems (the world seems still to be cathching up after throttling back
manufacturing due the financial crisis) and letting the stack pointer be
reset by hardware to top of ram (as the chips natively do) would let me
use common code for (some) different avrs. This why I don't really want
to set __stack to a value.

Thanks to your help I have a linker script which could easily set this,
but I don't feel that it's the 'right' answer. I could also remove .ini1
or .init2 in this script, but forst I need to know exactly what they

I have no problem maintaining a non-standard avr-libc, I have already
modified parts of it to suit my needs (open source is wonderful isn't it?).

Oh, BTW I use tiny 13, 24, 25, 45 etc. (VERY SMALL RAM).



reply via email to

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