cancel
Showing results for 
Search instead for 
Did you mean: 

FW Memory limitations.

bmn
Associate II

Let's say that i am programming a FW that should read data from peripherals.

How could I know what are my stack and heap and in general, my memory limitations?

I am working with STM32U585 and searched in the reference manual, but could not find the answer. Thanks!

5 REPLIES 5

Probably because its got more to do with your application, how you allocated space in the linker script, and how you utilize the stack/heap, say from a auto/local variable stand-point. The RM/DS should give information about the size and location of the RAM and FLASH areas. These should reflect in the Linker Scriipt, or scatter file.

You can check the current stack pointer to gauge home much is used. Mark the stack memory with a pattern you can see in the debugger, or check with code, so see how much is touched. some compilers and static analysis tools can estimate the call-tree depth and utilization. Run-time profiling can also provide a window into memory usage.

The topic is more an "Embedded Programming" one than an STM32 one.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Foued_KH
ST Employee

Hello @bmn​ ,

The STM32U585 is available with 2 Mbytes of flash memory

Stack is where the return addresses and register content and some other "helper" data are stored when calling subroutines, together with variables declared locally in functions (without static specifier).

Heap is where dynamically allocated (usually through calling malloc()) variables are stored.

Actually, most toolchains set a default value of zero for the heap size. Many embedded projects do not use dynamic memory allocation at all.

To modify thus value , you can check :

0693W00000aJmXZQA0.png

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

>>Many embedded projects do not use dynamic memory allocation at all.

Many of the better ones use it sparingly, like once for initialization tasks where configuration drives the type/size of allocations and structures, and not everything is a uniquely named global variable fixed in stone by the linker.

Also anything using C++ properly is likely to need the heap space.

The heap monitoring code in most embedded tools is pretty awful, but the heaps predominantly use a link-list and CS 101 type stuff.

One of the issues with ST's GNU/GCC implementation is that it's super lazy, the heap/stack are mostly expected to inhabit the same memory sections, and basically can crash into each other from opposite directions.

Most user code doesn't check malloc() returns, and would likely just crash-and-die if the heap runs out due to mismanagement and neglect.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi, thanks! I did check already this Project Manager window and saw these values.

Now, 0x200 and 0x400 are not much, so I am interested about the maximal values, as these are Minimum Heap/Stack Sizes.

Another thing, how can I access the 2MB of flash memory.

I checked the reference manual.. but did not find the answer.

Thanks

Many things to learn here. Thanks!