- Get link
- X
- Other Apps
Let's break down the output of the arm-none-eabi-size
command for your punchTrackerV1.0.elf
file:
text data bss dec hex filename 22068 100 2348 24516 5fc4 punchTrackerV1.0.elf
Explanation of Each Column
text
(22068 bytes):This is the size of the executable code in your program, stored in the
.text
segment of flash memory.It includes the compiled machine instructions for your functions, such as
main
,func
, and any other functions in your code.This segment is read-only and resides in flash memory.
data
(100 bytes):This is the size of initialized global and static variables, stored in the
.data
segment.These variables are stored in RAM, but their initial values are stored in flash memory and copied to RAM at startup.
For example, if you have a global variable like
int x = 10;
, the value10
is stored in flash, and the variablex
itself is stored in RAM.
bss
(2348 bytes):This is the size of uninitialized global and static variables, stored in the
.bss
segment.These variables are allocated in RAM but are not initialized (they are zeroed out at startup).
For example, a global variable like
int y;
would be stored in the.bss
segment.
dec
(24516 bytes):This is the total size of your program in decimal, calculated as:
dec = text + data + bss
In this case:
22068 (text) + 100 (data) + 2348 (bss) = 24516 (dec)
hex
(5fc4):This is the total size of your program in hexadecimal, which is just the decimal value
24516
converted to hex (0x5FC4
).
filename
(punchTrackerV1.0.elf):This is the name of the ELF (Executable and Linkable Format) file being analyzed.
Memory Layout Breakdown
Based on the output, here's how your program's memory is laid out:
Flash Memory (Program Memory):
.text
segment: 22068 bytes (executable code)..data
segment (initial values): 100 bytes (initial values for initialized variables).Total Flash Usage:
text + data
= 22068 + 100 = 22168 bytes.
RAM Usage:
.data
segment: 100 bytes (initialized variables in RAM)..bss
segment: 2348 bytes (uninitialized variables in RAM).Total RAM Usage:
data + bss
= 100 + 2348 = 2448 bytes.
Practical Implications
Flash Memory Usage:
Your program uses 22168 bytes of flash memory for code and initialized data.
If your STM32 microcontroller has 64 KB of flash (common for smaller STM32s), you have plenty of space left:
64 KB = 65536 bytes Free Flash = 65536 - 22168 = 43368 bytes
RAM Usage:
Your program uses 2448 bytes of RAM.
If your STM32 has 20 KB of RAM (common for smaller STM32s), you have:
20 KB = 20480 bytes Free RAM = 20480 - 2448 = 18032 bytes
Optimization Considerations:
If you need to reduce flash usage, focus on optimizing the
.text
segment (e.g., remove unused functions, enable compiler optimizations like-Os
for size).If you need to reduce RAM usage, focus on reducing the size of the
.bss
and.data
segments (e.g., use smaller data types, avoid large global arrays).
CONST KEYWORD
Local
const
variable:If its address is not taken, it may be optimized away (no memory usage).
If its address is taken, it will likely be stored in
.rodata
(flash memory).
static const
variable:Always stored in
.rodata
(flash memory), regardless of whether its address is taken.
- Get link
- X
- Other Apps
Comments
Post a Comment