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++)?
If you use the CMSIS RTOS RTX, there is a stack watermark feature,
that allows you to see how individual threads are using their
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.
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?
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!
The Getting Started Guide may be a big time saver, then, to learn
about all the features:
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
especially if you can find where the bad values start appearing.
So this is you too?
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
Make sure the heap is large enough to accommodate your malloc/new
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
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
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.
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
Stack_Size EQU 0x00000400 ; Make this bigger, evaluate how much
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.
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
a = 10
b = 100
è, ë 4 d, ë
d = 5
I forgot to include that Linker Listing is already marked. How do
I access .map file?
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:
Execution Region ER_IROM1 (Base: 0x08000000, Size: 0x00007724,
Max: 0x00080000, ABSOLUTE)
View all questions in Keil forum