Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
CDaniel_MT
PostPosted: Oct 06, 2011 - 07:56 PM
Newbie


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.
 
 View user's profile Send private message  
Reply with quote Back to top
jayjay1974
PostPosted: Oct 06, 2011 - 10:08 PM
Raving lunatic


Joined: Oct 30, 2002
Posts: 5720
Location: The Netherlands

Isn't there some heapsize variable in a linker/make script or so?
 
 View user's profile Send private message  
Reply with quote Back to top
mikech
PostPosted: Oct 07, 2011 - 03:45 AM
Hangaround


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.
 
 View user's profile Send private message  
Reply with quote Back to top
PeteAVR
PostPosted: Oct 07, 2011 - 07:00 AM
Hangaround


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.
 
 View user's profile Send private message  
Reply with quote Back to top
CDaniel_MT
PostPosted: Oct 07, 2011 - 04:06 PM
Newbie


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!
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits