EmbeddedRelated.com
Forums

Detailed memory usage by module on a PIC18

Started by Nickolai Leschov February 26, 2008
Hello,

I have a legacy project for PIC18F452 that compiles with HI-TECH 
Software C Compiler, using MPLAB IDE. The device's flash program memory 
is nearly full and I'm curious to see what occupies most of this space. 
How can I see memory footprint of compiled program, by modules?

The project consists of 19 'C' files; if the compiler told me how much 
memory each one uses, that would be great. Currently when I compile it 
only shows footprint by segments, as follows:

> Memory Usage Map: > > Program ROM $000000 - $000005 $000006 ( 6) bytes > Program ROM $000008 - $000015 $00000E ( 14) bytes > Program ROM $000018 - $00006F $000058 ( 88) bytes > Program ROM $000110 - $0005FF $0004F0 ( 1264) bytes > Program ROM $0006B0 - $006CF7 $006648 ( 26184) bytes > $006BA4 ( 27556) bytes total Program ROM > > RAM data $000047 - $0001DB $000195 ( 405) bytes > RAM data $000504 - $0005FF $0000FC ( 252) bytes > $000291 ( 657) bytes total RAM data > > Near RAM $000000 - $00000F $000010 ( 16) bytes total Near RAM > Near bits $000080 - $0000B6 $000037 ( 55) bits total Near bits > ROM data $000070 - $00010F $0000A0 ( 160) bytes > ROM data $000600 - $0006AF $0000B0 ( 176) bytes > $000150 ( 336) bytes total ROM data > > EEPROM Data $F00000 - $F0002F $000030 ( 48) bytes total EEPROM Data > > > Program statistics: > > Total ROM used 27892 bytes (85.1%) > Total RAM used 680 bytes (44.3%) > Near RAM used 23 bytes (18.0%)
which is spectacular (wow, so much information), but not that useful. I.e as far as I understand, most program code just goes into the largest segment and little else can be said. Best regards, Nickolai Leschov
Nickolai Leschov wrote:

> Hello, > > I have a legacy project for PIC18F452 that compiles with HI-TECH > Software C Compiler, using MPLAB IDE. The device's flash program memory > is nearly full and I'm curious to see what occupies most of this space. > How can I see memory footprint of compiled program, by modules?
<snip> I use Hi-Tech C and ASM for Intel 8096 work; the tools work well and link maps and assembler listings provide detailed size and address information. The manuals for the PIC tools are freely available online. You can use my Hi-Tech tools interactively (to see the various output formats) within my on-line ICE pages at: http://www.cybertheque.org/homebrew/hmi-200 The ICE is currently powered-off for energy and component conservation, so you won't be able to _run_ any of the demos or programs you write, but you can assemble, compile and debug. The manuals are accessible online for reference within the pages. There are also menus of demonstration program C code, precompiled code, etc. to save you some time. Regards, Michael
Nickolai Leschov wrote:
> Hello, > > I have a legacy project for PIC18F452 that compiles with HI-TECH > Software C Compiler, using MPLAB IDE. The device's flash program memory > is nearly full and I'm curious to see what occupies most of this space. > How can I see memory footprint of compiled program, by modules? > > The project consists of 19 'C' files; if the compiler told me how much > memory each one uses, that would be great. Currently when I compile it > only shows footprint by segments, as follows: > >> Memory Usage Map: >> >> Program ROM $000000 - $000005 $000006 ( 6) bytes >> Program ROM $000008 - $000015 $00000E ( 14) bytes >> Program ROM $000018 - $00006F $000058 ( 88) bytes >> Program ROM $000110 - $0005FF $0004F0 ( 1264) bytes >> Program ROM $0006B0 - $006CF7 $006648 ( 26184) bytes >> $006BA4 ( 27556) bytes total >> Program ROM >> RAM data $000047 - $0001DB $000195 ( 405) bytes >> RAM data $000504 - $0005FF $0000FC ( 252) bytes >> $000291 ( 657) bytes total RAM >> data >> Near RAM $000000 - $00000F $000010 ( 16) bytes total Near >> RAM Near bits $000080 - $0000B6 $000037 ( 55) bits total >> Near bits ROM data $000070 - $00010F $0000A0 ( 160) bytes >> ROM data $000600 - $0006AF $0000B0 ( 176) bytes >> $000150 ( 336) bytes total ROM >> data >> EEPROM Data $F00000 - $F0002F $000030 ( 48) bytes total EEPROM >> Data >> >> Program statistics: >> >> Total ROM used 27892 bytes (85.1%) >> Total RAM used 680 bytes (44.3%) >> Near RAM used 23 bytes (18.0%) > > which is spectacular (wow, so much information), but not that useful. > I.e as far as I understand, most program code just goes into the largest > segment and little else can be said. > > Best regards, > Nickolai Leschov > >
Have you looked at the .map file?
Neil wrote:
> Nickolai Leschov wrote:
<skip>
>>> Memory Usage Map: >>> >>> Program ROM $000000 - $000005 $000006 ( 6) bytes >>> Program ROM $000008 - $000015 $00000E ( 14) bytes >>> Program ROM $000018 - $00006F $000058 ( 88) bytes >>> Program ROM $000110 - $0005FF $0004F0 ( 1264) bytes >>> Program ROM $0006B0 - $006CF7 $006648 ( 26184) bytes >>> $006BA4 ( 27556) bytes total >>> Program ROM >>> RAM data $000047 - $0001DB $000195 ( 405) bytes >>> RAM data $000504 - $0005FF $0000FC ( 252) bytes >>> $000291 ( 657) bytes total RAM >>> data Near RAM $000000 - $00000F $000010 ( 16) bytes >>> total Near RAM Near bits $000080 - $0000B6 $000037 ( 55) >>> bits total Near bits ROM data $000070 - $00010F $0000A0 >>> ( 160) bytes >>> ROM data $000600 - $0006AF $0000B0 ( 176) bytes >>> $000150 ( 336) bytes total ROM >>> data EEPROM Data $F00000 - $F0002F $000030 ( 48) bytes >>> total EEPROM Data >>> >>> Program statistics: >>> >>> Total ROM used 27892 bytes (85.1%) >>> Total RAM used 680 bytes (44.3%) >>> Near RAM used 23 bytes (18.0%)
<skip>
> Have you looked at the .map file?
There isn't any .map file.
msg wrote:
> I use Hi-Tech C and ASM for Intel 8096 work; the tools work well and > link maps and assembler listings provide detailed size and address > information.
Where should I look for this detailed size information? Which file names? Regards, Nickolai Leschov
Nickolai Leschov wrote:
> Neil wrote: >> Have you looked at the .map file? > There isn't any .map file.
There is a linker option for generating a map file that contains the details you are looking for. I don't have access to the information at home, but you should be able to get a map file by either selecting a project option through MPLAB or specifically adding in the link control option (see the HiTech manual for that option). -- Thad
Thad Smith wrote:

> Nickolai Leschov wrote: > >> Neil wrote: >> >>> Have you looked at the .map file? >> >> There isn't any .map file. > > > There is a linker option for generating a map file that contains the > details you are looking for. I don't have access to the information at > home, but you should be able to get a map file by either selecting a > project option through MPLAB or specifically adding in the link control > option (see the HiTech manual for that option). >
If the O.P. had availed himself of my suggestion to visit my site (url in previous posts), he could have seen the command line switches in various places, including the online reference manuals and also the online compile and link feature which displays the command line. Michael
Neil wrote:
> Have you looked at the .map file?
Thank you, now I enabled the map file and looked into it. I seek for an easy way to estimate memory usage (flash ROM, mainly). There goes linker command line, machine type and call graph (I will leave it for later). After that there goes section that I might need:
> Name Link Load Length Selector Space Scale > C:\HTSOFT\PIC18\LIB\picrt86l.obj > end_init 6C 6C 4 C 0 > EE_AT.obj bigbss 542 542 10 542 1 > text 5FD8 5FD8 1E2 2000 0 > INI.obj text 6644 6644 FC 2000 0 > MI2C.obj bigbss 552 552 6 542 1 > rbit 80 10 2 0 1 8 > bss 4D 4D 2 4D 1 > text 64FC 64FC 148 2000 0 > ISR.obj intcode 8 8 8 4 0 > bigbss 558 558 1 542 1 > rbit 82 11 8 0 1 8 > ibigdata D2 D2 8 C 0 > bigdata 504 504 8 504 1 > intsave_r 5E5 5E5 1B 5E5 1 > temp 0 0 F 0 1 > idata 70 70 4 C 0 > data 9E 9E 4 9E 1 > text 4800 4800 75E 2000 0
<skip> Do the numbers in column named 'Length' constitute memory usage? (in hexadecimal, apparently) What do the names (text, bigbss etc. mean?) Is there a way to see these numbers in a more convenient manner? I would like to see just length and I don't seem to need to see the size of segments - I care about what goes to RAM and ROM, basically. Best regards, Nickolai Leschov
Nickolai Leschov wrote:
> Neil wrote: >> Have you looked at the .map file? > > Thank you, now I enabled the map file and looked into it. I seek for an > easy way to estimate memory usage (flash ROM, mainly). There goes linker > command line, machine type and call graph (I will leave it for later). > After that there goes section that I might need: > >> Name Link Load Length Selector Space Scale >> C:\HTSOFT\PIC18\LIB\picrt86l.obj >> end_init 6C 6C 4 C 0 >> EE_AT.obj bigbss 542 542 10 542 1 >> text 5FD8 5FD8 1E2 2000 0 >> INI.obj text 6644 6644 FC 2000 0 >> MI2C.obj bigbss 552 552 6 542 1 >> rbit 80 10 2 0 1 8 >> bss 4D 4D 2 4D 1 >> text 64FC 64FC 148 2000 0 >> ISR.obj intcode 8 8 8 4 0 >> bigbss 558 558 1 542 1 >> rbit 82 11 8 0 1 8 >> ibigdata D2 D2 8 C 0 >> bigdata 504 504 8 504 1 >> intsave_r 5E5 5E5 1B 5E5 1 >> temp 0 0 F 0 1 >> idata 70 70 4 C 0 >> data 9E 9E 4 9E 1 >> text 4800 4800 75E 2000 0 > <skip> > > Do the numbers in column named 'Length' constitute memory usage? (in > hexadecimal, apparently) What do the names (text, bigbss etc. mean?) > > Is there a way to see these numbers in a more convenient manner? I would > like to see just length and I don't seem to need to see the size of > segments - I care about what goes to RAM and ROM, basically.
There are multiple segments that go into RAM and ROM. bigbss, bss, rbit, ibigdata, bigdata, temp, data are RAM text and end_init, intcode are ROM. -- Thad