RAM consumption during run time of the software

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RAM consumption during run time of the software

2,324 Views
pranavpathak
Contributor III

Dear all, can you please tell me, how can I know, what amount of RAM is being used/consumed, when the software is executing on a PowerPC microcontroller (for e.g. MPC5744P) ? ram memory utilization internal ram memory optimization

Labels (1)
10 Replies

1,869 Views
aero72
Contributor III

Pranav,

If you're concerned about static RAM allocation by variables etc. then the map file is your best friend - but are you also trying to think about the amount of stack that is being used dynamically by the program?

If so, that's a bit more complicated to get a handle on - although some embedded operating systems will give you tools which allow you to get a idea of the highest stack pointer value. But those tools can sometimes adversely affect the results.

One think you could think about doing; if during the initial processor setup (i.e. the assembler in crt0.s) you purposefully initialise the contents of your stack to be a known hexadecimal string e.g. '0xFACECAFE' to every value - then run your software through situations which you consider to be 'worst-case' e.g. maximum interrupt frequency, highest computational load etc....and then take a look afterwards at the stack using a debugger, then you can see how far through the stack you were.

Does that make sense?

Regards,

1,869 Views
pranavpathak
Contributor III

Hi Andrew,

Apologies for the late reply.

Yes, I am trying to think about the amount of stack that is being used dynamically by the program.

I could understand the method you mentioned in your reply but I did not understand this : if during the initial processor setup (i.e. the assembler in crt0.s) you purposefully iinitialize the contents of your stack to be a known hexadecimal string e.g. '0xFACECAFE' to every value

Can you please elaborate on this part in detail and its consequences ?

Thanks a lot !

Regards,

Pranav

0 Kudos

1,869 Views
aero72
Contributor III

Pranav,

At the very start of your program you should be using the recommended processor setup code. You'll find this clears the registers and sets up key processor registers. Most boot code I've seen then writes zero to the complete RAM and Data RAM to initialise it. Finally a stack is initialised according to where you've configured your linker command file.

But if you insert a step to write the known hex string to the place where you're going to put your stack before you initialise that stack, then it will be obvious how much stack has been used later on. Because the values the processor has pushed will not have the same value as it was when the stack was initialised.

You can then use a debugger to take a look at the contents of the stack area to look where the known hex string finishes.

Regards,

1,869 Views
pranavpathak
Contributor III

Thanks a lot Andrew ! 

0 Kudos

1,869 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

please look at the following thread.

https://community.nxp.com/message/822570 

Tool powerpc-eabivle-size.exe you will find in S32 Design Studio installation folder, Cross_Tools/powepc-eabivle-4_9/bin.

Regards,

Martin

0 Kudos

1,869 Views
pranavpathak
Contributor III

Hi Martin,

Thank you for your reply!

As per my understanding, the thread explains the procedure for CodeWarrior but I am using a Green Hills Compiler 2013.1.4p, can you please tell me if it is possible to view RAM consumption in this scenario ?

Regards,

Pranav

0 Kudos

1,869 Views
martin_kovar
NXP Employee
NXP Employee

Hi Pranav,

if does not matter if you use Code Warrior compiler or Green Hills compiler. This tool is able to tell you how much RAM and ROM is used. I am attaching the tool (you do not have to download and install S32 Design Studio or Code Warrior)

Information about memory usage should be also read from MAP file generated by linker. Please look at the figure below, which shows a part of MAP file generated by Green Hills.

pastedImage_1.png

Regards,

Martin

0 Kudos

1,869 Views
pranavpathak
Contributor III

Hi Martin,

Thanks a lot for the reply !

I do have one question though: As I read in this thread View memory usage in CW 10.6 , you have mentioned that "value in column bss determines amount of data in RAM."

My question : Does RAM only consists of bss section and no other section contribute towards RAM ?

                       Where can I get detailed information on this ?

Regards,

Pranav

0 Kudos

1,869 Views
martin_kovar
NXP Employee
NXP Employee

Hi Pranav,

I have to fix my answer a little bit. Columns data and bss determines amount data in RAM. Section, which are placed in RAM are determined by linker file.

Please look at the following linker file and relevant map file are shown below.

pastedImage_1.png

pastedImage_2.png

If you add all these sections sizes, you will get the amount data in RAM.

pastedImage_3.png

Regards,

Martin

1,869 Views
pranavpathak
Contributor III

Hi Martin,

Thank You ! This has been a wonderful learning !

I still have few queries, I would really appreciate if you explain the following things:

To my knowledge, defining the RAM sections in Linker file and with map file evaluating the RAM, feels like a static evaluation of the RAM.

By static evaluation I mean to say that, when a software is executing, local variables are stored on stack (which sits in RAM), so can you please tell me whether the RAM calculation which we have performed, accommodate/consider this scenario as well ? 

Another basic question :

pastedImage_1.png

By bss = 7200, we mean 7200 Bytesright ?

Thanks,

Pranav

0 Kudos