0
votes

For my embedded application, we are using a STM32F411 chip. The chip has 512kb of flash and 128kb of RAM. I wanted to do a resource sizing exersize so I can monitor how I am doing on resources (FLASH and RAM)

I only statically allocate memory with no Malloc() calls. and sizing with gcc gives me:

text      data     bss     dec    hex     filename
230868   11236   74048  316152   4d2f8   application.elf

From the readings I have done (https://mcuoneclipse.com/2013/04/14/text-data-and-bss-code-and-data-size-explained/) I understand that because there are no dynamically allocated resources, the above information should give me a clear measure of how deep into the RAM usage I will run.

Can I expect the RAM use to ultimately be the data section + the bss sections per the summary on the link above? So in this case 85284 bytes.

And the Flash size to be text + data sections. In this case: 242104 ?

3

3 Answers

1
votes

Can I expect the RAM use to ultimately be the data section + the bss sections per the summary on the link above? So in this case 85284 bytes.

Depending on your linker script. Especially stack and heap configuration. Same is with the text segment & data segment.

For more detailed information you need to see the .map file.

0
votes

Yes, but also consider that even though you don't explicitly use dynamic memory in your code, library functions might. If you're trying to maintain super-tight control over memory use and you have an application that uses close to your total amount of RAM, you'll need to account for that. If you don't, you may run into nasty runtime issues.

-1
votes

In short, yes. Because of the need to store the initializers for the initialized data section, the "data" section counts twice in the memory usage -- once for flash and once for RAM. This is also why it is important to be very diligent about declaring constant data as "const". That data is then placed in flash and only counts once in the overall memory usage.