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

 Author: Maurice M. (tonedeaf) Posted on: 2006-04-10 16:14

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  :
.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 M. (tonedeaf) Posted on: 2006-04-10 17:13

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

 Author: Clifford S. (clifford) Posted on: 2006-04-10 17:53

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: 2006-04-11 12:46

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
(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?

sizes. If you adjust the program-memory- and ram-size in the
of the sections exceed the available memory.

Martin Thomas

 Author: Maurice M. (tonedeaf) Posted on: 2006-04-11 15:34

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?

/maurice

 Author: Clifford S. (clifford) Posted on: 2006-04-11 18:47

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?

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

• $formula (LaTeX syntax)$