Keil Logo

Profiler for ARM, consumption of RAM by the program in Keil

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Author
Huzaifa Asif
Posted
12-Jun-2017 23:22 GMT
Toolset
ARM
New! Profiler for ARM, consumption of RAM by the program in Keil

Is there any a way to determine how much ram/memory is being consumed by the entire project in keil uVision?

It looks like the program is using memory/addresses beyond the certain range allocated so I need to compute certain things.

Also, is there any profiler for ARM embedded systems (C++)?

Author
Zack Havens
Posted
13-Jun-2017 05:54 GMT
Toolset
None
New! RE: Profiler for ARM, consumption of RAM by the program in Keil

If you use the CMSIS RTOS RTX, there is a stack watermark feature, that allows you to see how individual threads are using their stacks:
http://www.keil.com/support/docs/3719.htm
This is a way to see some ZI-data usage in real time.

Most of the advanced profiling tools in MDK-ARM deal with code execution, rather than data usage.
Execution Profiler:
http://www.keil.com/support/man/docs/uv4/uv4_db_dbg_execprofiler.htm
Code Coverage:
http://www.keil.com/support/man/docs/uv4/uv4_db_dbg_codecoverage.htm
Performance Analyzer:
http://www.keil.com/support/man/docs/uv4/uv4_db_dbg_perfanalyzer.htm
These all require ETM trace, when debugging hardware. Code Coverage can also be used for many devices in simulation.

What makes you think the "program is using memory/addresses beyond the certain range allocated"?

There are some peripheral buffers that may not be counted in the total image size, depending on how they are accessed, but RO-data, RW-data, and ZI-data totals after a successful link should be accurate. Does Project => Options for Target => Target tab show the memory areas that you think are being using?

Author
Huzaifa Asif
Posted
13-Jun-2017 06:11 GMT
Toolset
None
New! RE: Profiler for ARM, consumption of RAM by the program in Keil

Well to be honest, I recently started working on cortex M4 and still learning the features keil uVision has to offer.

Basically, my code was working fine (was outputting results as expected) until I started to add some more variables, which resulted in some garbage strings. In addition, I got an error saying as stated here -> http://www.keil.com/support/docs/814.htm.

I got a similar error initially which I fixed by adding an initialization file. I shall really appreciate your help!

Regards

Author
Zack Havens
Posted
13-Jun-2017 15:55 GMT
Toolset
None
New! RE: Profiler for ARM, consumption of RAM by the program in Keil

The Getting Started Guide may be a big time saver, then, to learn about all the features:
http://www2.keil.com/docs/default-source/default-document-library/mdk5-getting-started.pdf?sfvrsn=2[NC,L]

Whenever I see garbage in variables, I check my own code for:
--how the variables are being initialized
--if pointers are doing what I intended

Stepping through the code in debug mode should help you find the answer,
especially if you can find where the bad values start appearing.

Author
Huzaifa Asif
Posted
13-Jun-2017 19:56 GMT
Toolset
None
New! RE: Profiler for ARM, consumption of RAM by the program in Keil

If pointers were the issue, I don't think I should have gotten everything correct in the first place. I started getting garbage characters in output when I started declaring some other variables and functions, which makes me wonder if size or the consumption is an actual cause.

Author
Westonsupermare Pier
Posted
13-Jun-2017 16:24 GMT
Toolset
ARM
New! RE: Profiler for ARM, consumption of RAM by the program in Keil

So this is you too?
http://www.keil.com/forum/62625/

Won't the .MAP file describe the memory usage?
Won't the Target IROM/IRAM settings constrain the LINKER to use just the memory that is physically available?
Won't the startup.s file define the size of the stack and heap?

Make sure the stack is large enough to accommodate your auto/local variables.
Make sure the heap is large enough to accommodate your malloc/new operations.

Start by observing what is FAILING, once you know the variables/data involved work backward to the point of origin, and to the places where it stops having the expected content vs the corrupt content.

Author
Huzaifa Asif
Posted
13-Jun-2017 20:43 GMT
Toolset
ARM
New! RE: Profiler for ARM, consumption of RAM by the program in Keil

Thanks for the response.

I am not using new or malloc so I guess I shouldn't be concerned about heap size.
Just to be sure, startup.s file states the stack size of the program or what we have in total? According to the startup.s file, Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>. Is number of bytes stated in hexadecimal here 'cause usually it's a numeric value.

Just below that, it also states Stack_Size EQU 0x00000400. So I am not sure which one is which.

I couldn't find .MAP file in my project. :/

There may be a possibility that stack is getting full which is why it's putting out garbage.

Author
Zack Havens
Posted
13-Jun-2017 21:20 GMT
Toolset
ARM
New! RE: Profiler for ARM, consumption of RAM by the program in Keil

Hello Huzaifa,

The startup defines the amount of stack available to the ARM C/C++ library, during startup,
rather than any total RAM usage.

For a map file, go to Project => Options for Target => Listing tab => Linker Listing.
Enable this option.

Have you looked in the code yet to find where the issue starts?

Thanks,
Zack

Author
Huzaifa Asif
Posted
13-Jun-2017 21:44 GMT
Toolset
ARM
New! RE: Profiler for ARM, consumption of RAM by the program in Keil

Thanks for the response. Right so is it Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> or Stack_Size EQU 0x00000400?

Also, if this is the available stack, how do I determine how much is being used by my program because that will help me determine if things are going beyond the limit or not.

I did debug my code, and I can't seem to find an issue. I mean as I continue to step in, it outputs as expected except for a few of them. If add even more variables, everything will be messed up (filled with random characters).

Below is just a simple representation (to give you an idea) of the outputs

a = 10

b = 100

è, ë 4 d, ë

d = 5

Author
Huzaifa Asif
Posted
13-Jun-2017 21:45 GMT
Toolset
ARM
New! RE: Profiler for ARM, consumption of RAM by the program in Keil

I forgot to include that Linker Listing is already marked. How do I access .map file?

Author
Westonsupermare Pier
Posted
13-Jun-2017 21:23 GMT
Toolset
ARM
New! RE: Profiler for ARM, consumption of RAM by the program in Keil

Stack_Size EQU 0x00000400 ; Make this bigger, evaluate how much you use

The former reference is for the "wizard view"

The .MAP should be in the output directory, as I recall you can double click the top of the project to have it loaded.

Author
Huzaifa Asif
Posted
13-Jun-2017 22:12 GMT
Toolset
ARM
New! RE: Profiler for ARM, consumption of RAM by the program in Keil

So this is the stack size -> 0x00000400 ?

Is .map file a notepad file with the same name as the project inside Listings folder?

I found this inside the file; is this relevant?

Memory Map of the image

Image Entry point : 0x08000195

Load Region LR_IROM1 (Base: 0x08000000, Size: 0x00007738, Max: 0x00080000, ABSOLUTE)

Execution Region ER_IROM1 (Base: 0x08000000, Size: 0x00007724, Max: 0x00080000, ABSOLUTE)

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.