Updated: Please see my 2nd post where I have a modified script which runs against a non-clean TEMP directory.
Prerequisite: Navigate to your %TEMP% directory and clean-up before starting any applications, especially Arduino. I have an automatic script that does this at shutdown/reboot. Do NOT be afraid if you are told that a file/directory is in-use, simply skip that. Just ensure that you do not have the Arduino GUI running.
Cleanup by: (select one of)
- Opening a Command Prompt
Typing CD %temp%
Typing Start . (yes, start + space + period & press Enter)
Using Explorer to delete all directories beginning with “build” and ending with “.tmp”
- Type %temp% into any explorer path window
Hilight all "build<…>.tmp directories and shift-shift delete
The reason this is necessary is that Windows date-time sort works only withing directories and not across all directories. Arudino GUI does not generate a temporary hash name that respects any temporal order; that is, the ASCII sort value is inconsistent across a wide date range. A
The solution is a custom Win32 executable to process all .cpp.elf files perform the sort across the universe. It could (perhaps) be done is a very complex script. <<-- See new script in separate post below.
The GNU size utility lists the section sizes—and the total size—for
each of the object or archive files objfile in its argument list. By
default, one line of output is generated for each object file or each
module in an archive.
I have been playing around with the AVR-SIZE utility which is installed during the Arduino installation. On version 1.0.5 and on my Vista notebook, my installation path is:
Note: Your installation path may be different.
If you have worked with Arduino on Windows for any length of time, you know that the sketch compiles are processed in a user temporary directory. This directory can look quiet menacing: see the graphic of my %temp% directory.
I wrote a script that I use to ferret through the clutter and process the avr-size utility on the last Arduino compile. I have tested it and it seems to work over sketches processed over several days,
always selecting the most recent sketch on which to execute. I believe the script will run on WinXP forward, but it is only tested on Windows Vista SP2. You may need to modify the script for other versions of Windows.
Here is the script:
PATH=%path%;C:\Program Files\Arduino_105\hardware\tools\avr\utils\bin; CD %TEMP% DIR %temp%\*.cpp.elf /s /b /O:-D /T:W >ElfRhere SET /P ELF= <ElfRhere ECHO %ELF% >MemUsage.txt AVR-SIZE -C %ELF% >>MemUsage.txt NOTEPAD MemUsage.txt SET ELF=""
I have this script named “MemoryUsage.cmd” and I stuck in my Arduino home folder:
C:\Users\owner\Documents\Arduino\hardware\MemoryUsage.cmd I created a desktop shortcut called MemUsage to run the script.
Double-clicking to invoke the script will scan through the %temp% directory used by Arduino and sort the most recent .ELF file, passing that as a runline argument to the avr-size utility. Please adjust your path in the first line of the script to properly identify where your AVR tools are installed.
As mentioned, I have tested this but I’m sure it can be improved upon. If you find a error or a better approach, please post in this thread to benefit everyone.
USING THE SCRIPT
- Invoke the script by double-clicking the shortcut or the .cmd script
- Notepad will open automatically displaying the SRAM and FLASH requirements of your last compile
- Click “X” on Notepad to close the Notepad and close the CMD prompt
AVR Memory Usage
Program: 444 bytes
(.text + .data + .bootloader)
Data: 9 bytes
(.data + .bss + .noinit)