EmbDev.net

Forum: ARM programming with GCC/GNU tools Reducing flash usage


Author: Maurice Marks (tonedeaf)
Posted on:

Rate this post
0 useful
not useful
I'm trying to fit lots of code into an LPC2131 (32K flash) part. It
looks like the symbol table is included in the download image, and if so
I'd like to eliminate it. For instance my "hello world" type of test
program results in:

Size after:
main.elf  :
section     size         addr
.text       6770            0
.ctors         0         6770
.dtors         0         6770
.data       2068   1073741824
.bss          56   1073743892
.stack      1024   1073744128
.stab       5364            0
.stabstr   10351            0
.comment     594            0
Total      26227

That is, it seems that most of the download image is symbol table stuff/
What changes to the Makefile would strip this?

Also, what changes to the headers would be needed for a LPC2131 so I
could be warned if my resulting code or ram usage exceeds the chip
capacity?

thanks for any advice!

Author: Maurice Marks (tonedeaf)
Posted on:

Rate this post
0 useful
not useful
I think I've solved the first part of my problem. I added -s to the
linker options
in Makefile which suppresses symbol table output in the image. That cut
the flash requirement by more than 50%.

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
Maurice Marks wrote:
> Also, what changes to the headers would be needed for a LPC2131 so I
> could be warned if my resulting code or ram usage exceeds the chip
> capacity?

It has nothing to do with any headers. You will need to do this in the
linker script. Here you can set the sizes of various memory regions the
various sections will be allocated to. If the total allocation exceeds
the specified size the link will fail.

Linker scripts are somewhat arcane and not for the faint hearted! If you
are lucky, your existing script will have appropriate values that you
might simply modify to match your board. If not then the gory details
are in the linker manual (ld.html).

Clifford

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
Maurice Marks wrote:
> I'm trying to fit lots of code into an LPC2131 (32K flash) part. It
> looks like the symbol table is included in the download image, and if so
> I'd like to eliminate it. For instance my "hello world" type of test
> program results in:

Do you use tools that download elf-files? I don't know of any. Usualy
files in raw-binary or Intel hex-format are created for download
(arm-elf-objcopy). Those files do not include debug-symbols.


> Size after:
> main.elf  :
> That is, it seems that most of the download image is symbol table stuff/

I do not know the term "download-image" but the elf-File is not a real
"binary code" for the target. objcopy creates a "memory image" from the
elf-file.

> What changes to the Makefile would strip this?

I have never used it but there is an arm-elf-strip available.

> Also, what changes to the headers would be needed for a LPC2131 so I
> could be warned if my resulting code or ram usage exceeds the chip
> capacity?

As already explained by Clifford the linker-scripts define the memory
sizes. If you adjust the program-memory- and ram-size in the
linker-script the linker should show an error-message if the total sizes
of the sections exceed the available memory.

Martin Thomas

Author: Maurice Marks (tonedeaf)
Posted on:

Rate this post
0 useful
not useful
Thanks Martin and Clifford. I get it now. The hex file will just contain
the text section, and I need to update the .ld file with the RAM and ROM
size for the 2131. I'm assuming I can just change the sizes in the
MEMORY section and the rest of the linker directives should be unchanged
from the 2138 file. Correct?

thanks for your help

/maurice

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
Maurice Marks wrote:
>
> [...] I need to update the .ld file with the RAM and ROM
> size for the 2131. I'm assuming I can just change the sizes in the
> MEMORY section and the rest of the linker directives should be unchanged
> from the 2138 file. Correct?

That's about it. If you want more information on exactly where the
linker has placed each object, you can use the arm-elf-nm utility to
output a map file. You need to do this on the linked object code
(commonly given the extension .out):

       arm-elf-nm myProject.out >> myProject.map

You might add this command to your makefile if you want to create it
every time.

Clifford

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.