| Author |
Message |
|
|
Posted: Oct 06, 2011 - 07:56 PM |
|

Joined: Jul 19, 2011
Posts: 14
|
|
I’m wondering of anyone knows how to get rid of the heap. I am not using it, but I’m thinking that some part of another standard library must be since the linker insists on including it. I finally got rid of sprintf and all of its parts (huge), but I can’t seem to eliminate the heap.
Alternatively, does anyone know if there’s a way to generate a cross reference file which would tell me what modules/functions are referencing the heap functions? Then I’d know what else I have to get rid of in order to lose the heap.
Thanks. |
|
|
| |
|
|
|
|
|
Posted: Oct 06, 2011 - 10:08 PM |
|


Joined: Oct 30, 2002
Posts: 5720
Location: The Netherlands
|
|
| Isn't there some heapsize variable in a linker/make script or so? |
|
|
| |
|
|
|
|
|
Posted: Oct 07, 2011 - 03:45 AM |
|

Joined: Aug 19, 2003
Posts: 398
Location: Australia
|
|
add this to your linker options ;
-Wl,-Map=yourmap.map
or
-Wl,-Map=yourmap.map,--cref
You could also run avr32-objdump.exe or avr32-nm.exe or avr32-readelf.exe against the .ELF file
But I have to ask., why do you want to get rid of the heap ?
The heap is the unallocated RAM between the end of your static/global/initialised variables and the stack, as determined at link time.
If you don't use malloc() or similar during runtime then the heap will remain unused. |
|
|
| |
|
|
|
|
|
Posted: Oct 07, 2011 - 07:00 AM |
|

Joined: May 03, 2004
Posts: 220
Location: Cologne, Germany
|
|
| Put " __heap_size__ = 0;" under the line "__max_heap_size__ = -1;" in your linker .lds file. But beware, I searched for some hours, till I found that the printf family uses the heap, and will crash if the heap is zero. |
|
|
| |
|
|
|
|
|
Posted: Oct 07, 2011 - 04:06 PM |
|

Joined: Jul 19, 2011
Posts: 14
|
|
Thanks for the suggestions. I had already generated the map file (that’s how I knew the heap was still in there), but I hadn’t realized that this file is also a cross-reference. It appears that strtok is what’s using the heap.
I just tweaked my program to not use strtok, and the resulting binary decreased by 4K. That’s insane. Strtok itself seems to be only a couple hundred bytes, but apparently it brings in several kilobytes of other stuff.
To answer mikech’s question: I want to get rid of the heap because it brings in too much code. I don’t care about the RAM; it’s the flash space I’m concerned about. I’m making a small boot loader program for loading new firmware and I want it to fit in 16K. Currently it does, but not with enough extra space for my comfort level to allow for possible growth down the road.
It apears this is solved. Thanks everyone! |
|
|
| |
|
|
|
|
|