Unused Interrupt-Vectors

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

Hi everyone,

my question is simple:
how can I optimize GCC to short the vector-table to the last used one?
This would save me some bytes, and my code is *tight*....

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

You need to write your customized C run-time startup file (crt --
that's the crtXXX.o file). Pick the library source code, and modify
it to match your needs. Remember this is open-source software. ;-)

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

Are there any good examples, or guidelines for customizing the startup file?

admin's test signature
 

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

Basically, the startup file automatically assembles the vector table
using a macro loop across all possible vector numbers. If the
respective vector number is defined in the avr/ioXXX.h file, the
vector is placed in the assembler source, otherwise it is left out.

Just unroll that loop, and use a fixed table for whatever number of
vectors you need. Leave the remainder of the file untouched.

Run avr-gcc with the -v option, this will show you the existing call
to the linker (avr-ld). Use that command line as the base for your
own customized command line, and replace the original crtXXX.o file by
your file.

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

I tried it, but I was unsuccesfully. GCC ignored my changes in the Header-File.
I think it will always link the crtsi.o....

So I wrote my own startupcode.

For all, that have the same problem, here the code.

It's shorter than the original one, but might be not 100% compatible:
It assumes that the bss section follows directly the data section.
It also assumes a tiny memory model (My 2313 has some only bytes of RAM...), so it won't work with biger AVRs....
Also, it requires at least 1 byte data and one byte bss...
Finally, return from main() is not allowed and will result in undefined behavior.
But in embedded theres no world after main anyway.

Changes in the makefile:
Also the gcc-options "-nostartfiles -nostdlib" have to be used, and the link order of the files changed: the assembler files have to be uses first, and if there's more than one assembler file, the startup-code have to be specified first.

I will add another post, with the makefile.

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

Rule #1 : Add Attachment before clicking "Post"

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

The makefile

PS: Don't wonder about the name:
The file of this name has already been uploaded. Please rename your attachment and try again