After keil compilation, the following information is generated:
Program Size: Code=37970 RO-data=7598 RW-data=212 ZI-data=12340 What do code ro-data rw-data zi-data mean respectively
?
Answer:
Code segment + initialized data segment = FLASH, data segment + 0 initialized data segment = RAM;
RO, RW and ZI DATA segments in ARM compilation
ARM program (referring to the program being executed in the ARM system, not the bin file saved in ROM) composition
An ARM program contains 3 parts: RO segment, RW segment and ZI segment
RO is the instruction and constant in the program
RW is the initialized variable in the program
ZI is the uninitialized variable in the program
The above 3 points can be understood as:
RO is readonly,
RW is read/write,
ZI is zero
Composition of ARM image file
The so-called ARM image file refers to the bin file burned into ROM, also known as image file. It is called Image file below.
Image file contains RO and RW data.
The reason why Image file does not contain ZI data is that ZI data is all 0, so it is not necessary to include it. Just clear the area where ZI data is before running the program. Including it will waste storage space.
Q: Why must RO and RW be included in the Image?
A: Because the instructions and constants in RO and the variables initialized in RW cannot be created out of nothing like ZI. From the above two points, we can know that
the execution process of the ARM program
is not exactly the same as the image file burned into the ROM and the ARM program in actual operation. Therefore, it is necessary to understand how the ARM program reaches the actual running state from the image in the ROM.
In fact, the instructions in RO should at least have the following functions:
1. Move RW from ROM to RAM, because RW is a variable and variables cannot exist in ROM.
2. Clear all RAM areas where ZI is located, because the ZI area is not in the Image, so the program needs to clear the corresponding RAM area according to the ZI address and size given by the compiler. ZI is also a variable. Similarly: variables cannot exist in ROM. In the
initial stage of program operation, the C program can access variables normally only after the instructions in RO complete these two tasks. Otherwise, only code without variables can be run.
After all the above, you may still be confused. What are RO, RW and ZI? Below I will give a few examples to explain what RO, RW and ZI mean in C.
1; RO
Look at the following two programs. There is a statement between them, which is to declare a character constant. Therefore, according to what we said before, there should only be one byte difference in RO data (character constant is 1 byte).
Prog1:
#include
void main(void)
{
;
}
Prog2:
#include
const char a = 5;
void main(void)
{
;
}
The compiled information of Prog1 is as follows:
======================================================================================
Code RO Data RW Data ZI Data Debug
948 60 0 96 0 Grand Totals
=======================================================================================================
Total RO Size(Code + RO Data) 1008 ( 0.98kB)
Total RW Size(RW Data + ZI Data) 96 ( 0.09kB)
Total ROM Size(Code + RO Data + RW Data) 1008 ( 0.98kB)
==========================================================================================
The information after Prog2 compiles is as follows:
===================================================================================================
Code RO Data RW Data ZI Data Debug
948 61 0 96 0 Grand Totals
==================================================================================
Total RO Size(Code + RO Data) 1009 (0.99kB)
Total RW Size(RW Data + ZI Data) 96 (0.09kB)
Total ROM Size(Code + RO Data + RW Data) 1009 ( 0.99kB )
=== ... Prog3: #include void main(void) { ; } Prog4: #include char a = 5; void main(void) { ; }
The information after Prog3 compiles is as follows:
=================================================================================
Code RO Data RW Data ZI Data Debug
948 60 0 96 0 Grand Totals
=======================================================================================================
Total RO Size(Code + RO Data) 1008 ( 0.98kB)
Total RW Size(RW Data + ZI Data) 96 ( 0.09kB)
Total ROM Size(Code + RO Data + RW Data) 1008 ( 0.98kB)
==============================================================================================
The information compiled by Prog4 is as follows:
========================================================================================================
Code RO Data RW Data ZI Data Debug
948 60 1 96 0 Grand Totals
================================================================================
Total RO Size(Code + RO Data) 1008 (0.98kB)
Total RW Size(RW Data + ZI Data) 97 (0.09kB)
Total ROM Size(Code + RO Data + RW Data) 1009 (0.99kB)
===
...
}
;
}
Prog4:
#include
char a;
void main(void)
}
;
}
The compiled information of Prog3 is as follows:
=========================================================================================
Code RO Data RW Data ZI Data Debug
948 60 0 96 0 Grand Totals
==============================================================================================================
Total RO Size(Code + RO Data) 1008 ( 0.98kB)
Total RW Size(RW Data + ZI Data) 96 ( 0.09kB)
Total ROM Size(Code + RO Data + RW Data) 1008 ( 0.98kB)
===========================================================================================
The information compiled by Prog4 is as follows:
=====================================================================================================
Code RO Data RW Data ZI Data Debug
948 60 0 97 0 Grand Totals
==========================================================================
Total RO Size(Code + RO Data) 1008 ( 0.98kB)
Total RW Size(RW Data + ZI Data) 97 ( 0.09kB)
Total ROM Size(Code + RO Data + RW Data ) 1008 ( 0.98kB)
===
...
Appendix:
Program compilation command (assuming the C program is named tst.c):
armcc -c -o tst.o tst.c
armlink -noremove -elf -nodebug -info totals -info sizes -map -list aa.map -o tst.elf
The compiled information of tst.o is in the aa.map file.
ROM mainly refers to: NAND Flash, Nor Flash
RAM mainly refers to: PSRAM, SDRAM, SRAM, DDRAM
Previous article:Understanding of program memory in stm32 and solutions to some problems
Next article:Detailed explanation of STM32 bitband operation
Recommended ReadingLatest update time:2024-11-17 00:49
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [Boliu BL606P audio and video development board] CDK simulation experience
- It is recommended that the moderator add an EMC column or special discussion.
- Current RMS acquisition circuit principle; bipolar conversion circuit principle; lead-off detection circuit principle
- Regarding the problem of using LCR tester to measure different types of inductors, please help
- [Boliu BL606P audio and video development board] Solve the problem that JTAG cannot download after RGB lighting
- Temperature measurement circuit, waveform modulation circuit, peak detection circuit principle
- [Boliu BL606P audio and video development board] RGB lighting
- IPC-A-610 Standard Training Materials
- [MPS Exploration Camp Sharing with Prizes] Core Function Testing and Structural Design of Portable Multi-function Electrician's Bench
- [ST NUCLEO-U575ZI-Q Review] Sharing the basics of hardware design