I have always had a seemingly correct understanding of the RO, RW and ZI data described in the ARM system. During this period, I carefully studied them and found some rules. I understood some things that were in the books but not understood before. I think there should be many people who have the same confusion as me, so I wrote down some of my understandings about RO, RW and ZI, hoping to help everyone.
To understand RO, RW and ZI, you need to first understand the following knowledge:
The composition of ARM programs
The "ARM program" mentioned here refers to the program being executed in the ARM system, not the bin image file saved in ROM. Please pay attention to the difference.
An ARM program contains 3 parts: RO, RW and ZI
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
From the above 3 points, it can be understood that:
RO is readonly,
RW is read/write, and
ZI is zero
The composition of ARM image files
The so-called ARM image file refers to the bin file burned into the ROM, also known as the image file. It is called the image file below.
The image file contains RO and RW data.
The reason why the Image file does not contain ZI data is that ZI data is all 0, so it is unnecessary to include it. Just clear the area where ZI data is located before the program is run. 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 initialized variables in RW cannot be "created out of nothing" like ZI.
The execution process of the ARM program
From the above two points, we can know that the image file burned into the ROM is not exactly the same as 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 the 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 be stored in ROM.
In the initial stage of program execution, 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 saying the above, it may still be a bit confusing. What are RO, RW and ZI? Below I will give a few examples to explain what RO, RW, and ZI mean in C in the most intuitive way. 1;
RO
Look at the following two programs. There is a statement between them. This statement is to declare a character constant. Therefore, according to what we said before, they should only differ by one byte in RO data (character constants are 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 Size) + 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 Prog2 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)
================================================================================
From the information after the two programs are compiled, we can see that:
The RO of Prog1 and Prog2 contains
two types of data: Code and RO Data. The only difference between them is that the RO
Data of Prog2 has one more byte than that of Prog1. This is consistent with the previous speculation.
If an instruction is added instead of a constant, the result should be a difference in the size of the Code data. 2;
RW
Similarly, looking at the two programs again, the only difference between them is an "initialized variable". According to what was said before, the initialized variable should be counted in RW, so the size of RW should be different between the two programs.
Prog3:
#include
void main(void)
{
;
}
Prog4:
#include
char a = 5;
void
main(void)
{
;
}
The information after compiling 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 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)
===
...
Prog3:
#include
void main(void)
{
;
}
Prog4:
#include
char a;
void
main(void)
{
;
}
The information after compiling 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 after Prog4 compiles 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 )
=== ... 3; The variables in C that have been initialized to non-zero values will be compiled into RW type data. Appendix: Program compilation command (assuming the C program name is 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
Reference address:About RO, RW, ZI in ARM
To understand RO, RW and ZI, you need to first understand the following knowledge:
The composition of ARM programs
The "ARM program" mentioned here refers to the program being executed in the ARM system, not the bin image file saved in ROM. Please pay attention to the difference.
An ARM program contains 3 parts: RO, RW and ZI
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
From the above 3 points, it can be understood that:
RO is readonly,
RW is read/write, and
ZI is zero
The composition of ARM image files
The so-called ARM image file refers to the bin file burned into the ROM, also known as the image file. It is called the image file below.
The image file contains RO and RW data.
The reason why the Image file does not contain ZI data is that ZI data is all 0, so it is unnecessary to include it. Just clear the area where ZI data is located before the program is run. 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 initialized variables in RW cannot be "created out of nothing" like ZI.
The execution process of the ARM program
From the above two points, we can know that the image file burned into the ROM is not exactly the same as 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 the 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 be stored in ROM.
In the initial stage of program execution, 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 saying the above, it may still be a bit confusing. What are RO, RW and ZI? Below I will give a few examples to explain what RO, RW, and ZI mean in C in the most intuitive way. 1;
RO
Look at the following two programs. There is a statement between them. This statement is to declare a character constant. Therefore, according to what we said before, they should only differ by one byte in RO data (character constants are 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 Size) + 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 Prog2 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)
================================================================================
From the information after the two programs are compiled, we can see that:
The RO of Prog1 and Prog2 contains
two types of data: Code and RO Data. The only difference between them is that the RO
Data of Prog2 has one more byte than that of Prog1. This is consistent with the previous speculation.
If an instruction is added instead of a constant, the result should be a difference in the size of the Code data. 2;
RW
Similarly, looking at the two programs again, the only difference between them is an "initialized variable". According to what was said before, the initialized variable should be counted in RW, so the size of RW should be different between the two programs.
Prog3:
#include
void main(void)
{
;
}
Prog4:
#include
char a = 5;
void
main(void)
{
;
}
The information after compiling 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 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)
===
...
Prog3:
#include
void main(void)
{
;
}
Prog4:
#include
char a;
void
main(void)
{
;
}
The information after compiling 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 after Prog4 compiles 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 )
=== ... 3; The variables in C that have been initialized to non-zero values will be compiled into RW type data. Appendix: Program compilation command (assuming the C program name is 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:arm-linux-objdump parameters
Next article:Detailed explanation of arm startup code
Recommended ReadingLatest update time:2024-11-17 00:42
Apple Mac: Intel and Arm's PC ecosystem competition enters a white-hot stage
Intel said it will continue to support Macs during the transition period. Intel publicly responded to its "breakup" with Apple. Intel and Apple's architecture cooperation on Mac started in 2005, and it has been 15 years so far. At the recent WWDC (Worldwide Developers Conference), Apple officially announced that its
[Embedded]
The meaning of RO-data, RW-data, and ZI-data in Keil
Code is the program code part RO-data represents the constant const temp defined by the program; RW-data represents the initialized global variables ZI-data represents the uninitialized global variables Total RO Size (Code + RO Data) Total RW Size (RW Data + ZI Data) Total ROM Size (Code + RO Data + RW Data) D
[Microcontroller]
Let's learn mini2440 bare metal development (Part 9) --ARM interrupt control system
ARM processor program execution flow types ●Normal execution: Each time an ARM instruction is executed, the value of the program counter PC is automatically increased by 4. This process describes the state of the sequential execution of the application. ● Jump execution: Through B and BL jump execution, the progra
[Microcontroller]
Arm-linux-gcc installation under ubuntu
I found the download address at random, version 4.4.3, address: http://www.cr173.com/soft/42654.html#address 1. I put it in /work/tools/ 2.sudo tar xzvf /work/tools/arm-linux-gcc-4.4.3.tar.gz 3.sudo tar xvzf arm-linux-gcc-4.4.3.tar.gz -C / 4. The command was found in /opt/FriendlyARM/toolschain/4.4.3/bin; Then sudo v
[Microcontroller]
Basic concepts of ARM embedded Linux transplantation experience
introduction
ARM is the abbreviation of Advanced RISC Machines, which is a microprocessor intellectual property (IP) core provided by ARM.
ARM applications have spread to various product markets such as industrial control, consumer electronics, communication systems, network systems, wireless systems, etc. Micr
[Microcontroller]
ARM-Linux transplant (Part 3) - Analysis of init process startup process
We usually use Busybox to build the necessary applications for the root file system. Busybox determines what operation to perform based on the parameters passed in. When the init process starts, it actually calls the init_main() function of Busybox. Let's analyze this function to see what the init process is like. T
[Microcontroller]
ARM development summary of small knowledge Code, RO-data, RW-data, ZI-
Small knowledge summarized by ARM development Byte 8-bit half word 16-bit word 32-bit Code, RO-data RW-data, ZI-data Code is the program code part RO-data represents the constant const temp defined by the program; RW-data represents the initialized global variable ZI-data represents the uninitialized global variabl
[Microcontroller]
arm-linux-gcc and simple makefile
gcc common options How to use gcc: gcc filename -v: Check the version of the gcc compiler and display the detailed process of gcc execution -o: specifies the output file name as file, which does not need to be the same as the compiled file name -E: preprocess only; do not compile, assemble or link (preprocess only, n
[Microcontroller]
- Popular Resources
- Popular amplifiers
- Embedded Security Processor Application and Practice
- Foundations of ARM64 Linux Debugging, Disassembling, and Reversing Analyze Code, Understand Stack Me
- ARM Embedded System Principles and Applications (Wang Xiaofeng)
- ARM Cortex-M4+Wi-Fi MCU Application Guide (Embedded Technology and Application Series) (Guo Shujun)
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- 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
Guess you like
- Prize-winning live broadcast: Melexis consumer-grade ultra-low power position sensor, simplifying design and reducing costs. Registration is now open!
- ESP32-S2-Saola-1 Development Board Circuit Analysis
- [Repost] Adafruit Blog: New PyBoard at FOSDEM
- Wireless connectivity technology promotes intelligent control of lighting systems
- SinlinxA33 development board Linux kernel atomic operations (with measured code)
- Why does the IoT UWB visual personnel positioning system have centimeter-level positioning accuracy?
- CCS8.3.1 imports CCS3.3 project 28335
- T6963C Issues
- Canon closes Zhuhai factory! If you are not a professional or photography enthusiast, would you buy a camera now?
- Why is there no response when downloading the GD32F107 routine to the board?