avr-chat
[Top][All Lists]
Advanced

[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 14:51:15 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4

OK Erik,

I think I can see the mechanism now.
The crt[tn13].o seems to be complied from avr-libc-1.4.6/crt1/gcrt1.S
which has:
==========================================================================
#ifndef __AVR_ASM_ONLY__
        .weak   __stack

        /* By default, malloc() uses the current value of the stack pointer
           minus __malloc_margin as the highest available address.

           In some applications with external SRAM, the stack can be below
           the data section (in the internal SRAM - faster), and __heap_end
           should be set to the highest address available for malloc().  */
        .weak   __heap_end
        .set    __heap_end, 0

        .section .init2,"ax",@progbits
        clr     __zero_reg__
        out     _SFR_IO_ADDR(SREG), __zero_reg__
        ldi     r28,lo8(__stack)
#ifdef SPH
        ldi     r29,hi8(__stack)
        out     _SFR_IO_ADDR(SPH), r29
#endif
        out     _SFR_IO_ADDR(SPL), r28
==========================================================================
This means that the __stack value is determined at the time of compiling
avr-libc. It is marked as weak, so I can override it's value in my
source file (tested). It's a shame that not all the .init[x] sections
aren't marked as weak so they could be individually overwritten (.init0 is).
Either I live with the (admitted small - but on these parts every byte
counts when you're up against the end stops) penalty of some redundant
code or I modify my avr-libc and recompile as a non-standard toolchain.
I checked the latest release and the code here is still the same.

Anyway, many thanks for your comments Erik, I wish you good health,

Robert



reply via email to

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