FW Memory limitations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-27 06:40 AM
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!
- Labels:
-
Flash
-
STM32U5 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-27 07:05 AM
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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-27 07:43 AM
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 :
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-27 09:20 AM
>>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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-28 12:40 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-28 12:42 AM
Many things to learn here. Thanks!