Minimal Startup Footprint

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Using the managed make facility in AVR32 Studio to run the GNU Toolchain I find a great deal of stuff is included without my having asked for it. Like the whole standard C library with all of the functions essentially nullified or stubbed out.

My file looks like

int main(void)
{
    while(1)
}

The code size is very nearly 32K !!

I tried using the simple startup file crt0.s but that has an undefined symbol AVR32_SR_EM_OFFSET so that is no help.

I also tried the check boxes in the Linker General Properties. I can get no startup and no libraries, but I can't get startup with no libraries.

I'm probably not ready to create my own makefiles yet but that is where I think I'm headed.

Any advice?

We never have time to do it right,
but we always have time to do it over

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In trying to assemble crt0.s I think include files are being ignored. Does the assembler use the C compiler syntax for include files?

#include

The reason I ask is because I don't think it is including anything. If I ask for

#include

it does not throw an error about being unable to find the file. Why should this be the case?

I'm spending way too much time farting around with the tools and no time at all developing my application. This is giving you [Atmel] a real black eye.

We never have time to do it right,
but we always have time to do it over

Last Edited: Fri. Jan 25, 2008 - 06:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I see the problem at last.

avr32-as is called for files with extensions of `.s' and `.S' Additionally the C preprocessor is invoked for files with an extension of `.S'

A bug in AVR32 Studio causes files with an extension of `.S' to be ignored. If you rename the file with a lower case `.s' then the preprocessor won't get called.

I'll bet this is the same problem people are having with exception.S versus exception.s

The fix would seem to be to explicitly ask for the C preprocessor to be called. Is there a way to do this?

Or do we just have to keep bitching until the bug gets fixed?

We never have time to do it right,
but we always have time to do it over

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Secret Revealed
In order to get a minimal footprint `.elf' file you need to do three things
1. Add two .equ statements to crt0.s (renamed from crt0.S) to define AVR32_SR_EM_OFFSET as 21, and AVR32_EVBA as 0x00000004 so it won't have to depend on the C preprocessor, and place it in your project file.
2. Wrtie a stub for exception.s (based on exception.S) which does not depend on the C preprocessor, and place it in your project file.
3. Check the box in "Properties | Tool Settings | AVR32/GNU C Linker | General" labeled `No startup or default libs (-nostdlib)'

We never have time to do it right,
but we always have time to do it over

Last Edited: Fri. Jan 25, 2008 - 10:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Seems very useful. Can standard functions such as rand() still be used? I have tried various things to decrease the initial memory footprint involving -nostdlib, but I've always had trouble using certain functions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It seems like it should be possible to explictly call out the use of a library and pick one function from it. Sorry, but I'm a total noob at this so I have no vast font of information on the tricks of the trade.

We never have time to do it right,
but we always have time to do it over