What is an arm image file? An arm image file is actually an executable file, including bin or hex formats, which can be directly burned into rom for execution. During the axd debugging process, we debugged the axf file, which is actually also an image file. It just adds a file header and some debugging information to the bin file. An image file is generally composed of domains, which are composed of up to three output segments (RO, RW, ZI), and the output segment is composed of input segments. The so-called domain refers to the area where the entire bin image file is located, which is divided into a loading domain and a running domain. The loading domain is the working area where the image file is statically stored. Generally speaking, the address space where the entire bin file in Flash is located is the loading domain. Of course, programs are generally not placed in Flash for execution, but are generally moved to SDRAM for operation. The address space where they are moved to SDRAM for operation is the running domain. The code we input generally has a code part and a data part, which is the so-called input segment. After compilation, it becomes the RO segment and RW segment in the bin file, as well as the so-called ZI segment, which is the output segment. For the output segments in the load domain, generally speaking, the RO segment is followed by the RW segment, and the RW segment is followed by the ZI segment. In the run domain, these output segments are not continuous, but RW and ZI must be connected. The data in the ZI segment and RW segment can actually be RW attributes.
| Image
Below is the ported part of the 2410 startup code, with my comments:
BaseOfROM DCD |Image
TopOfROM DCD | Image
BaseOfBSS DCD |Image
BaseOfZero DCD |Image
EndOfBSS DCD |Image
adr r0, ResetEntry; ResetEntry is the starting address of the reset runtime domain, which is usually 0 in boot nand
ldr r2, BaseOfROM;
cmp r0, r2
ldreq r0, TopOfROM; TopOfROM=0x30001de0, the end of the code segment address
beq InitRam
ldr r3, TopOfROM
; part 1, by comparison, move ro to sdram, and move to the destination address from | Image
0
ldmia r0!, {r4-r7}; Transfer the value of r0 as the 4 consecutive 32-bit numbers at the address (ResetEntry) to r4, r5, r6, r7 in turn; at the same time, r0 increases.
stmia r2!, {r4-r7}; Store the values of r4, r5, r6, r7 in |Image
cmp r2, r3
bcc %B0;
; part 2, move rw segment to sdram, the destination address is |Image
r2, r2, r3;r2=0 ;When copying above, 4 double words (32 bits) are copied each time, but the RO segment size is not necessarily an integer multiple of 4, so several double words may be copied more, r2-r3 gets the number of copiessub
r0, r0, r2 ;r0-(r2-r3) can make r0 point to the end address of RO in boot nandInitRam
;carry rw to baseofBSS
ldr r2, BaseOfBSS ;TopOfROM=0x30001de0,baseofrw
ldr r3, BaseOfZero ;BaseOfZero=0x30001de0
0
cmp r2, r3
ldrcc r1, [r0], #4
strcc r1, [r2], #4
bcc %B0
;part 3, initialize sdram zi to 0, address from|Image
mov r0, #0;init 0
ldr r3, EndOfBSS;EndOfBSS=30001e40
1
cmp r2, r3
strcc r0, [r2], #4
bcc %B1
So far, the copying and initialization of the three output segments (RO, RW, ZI) are completed.
*************************************************** **********
RO segment, RW segment and ZI segment--Image
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 consists of 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.
The above 3 points can be understood as:
RO is readonly,
RW is read/write, and
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 there is no need to include it. Just clear the area where ZI data is located before running the program. Including it will waste storage space.
Q: Why must RO and RW be included in Image?
A: Because the instructions and constants in RO and the initialized variables in RW cannot be "created out of nothing" like ZI.
ARM program execution process
From the above two points, we can know that the image file burned into 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 operation state from the image in ROM.
In fact, the instructions in ROM 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, and similarly: variables cannot exist in ROM. In the initial stage of program running, 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.
Note: If a variable is initialized to 0, it will be placed in the ZI area in the same way as an uninitialized variable. That is, in an ARM C program, all uninitialized variables will be automatically initialized to 0. RO contains two types of data: Code and RO Data.
Summary:
1; Instructions and constants in C are compiled as RO data.
2; Uninitialized or initialized to 0 variables in C are compiled as ZI data.
3; Variables initialized to non-zero values in C are compiled as RW data.
Previous article:S3C2440 abnormal entry and exit
Next article:S3C2440 startup code interrupt analysis
Recommended ReadingLatest update time:2024-11-15 07:29
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Dual-receive and dual-transmit radio RF board based on XC7Z100+ADRV9009
- 【Repost】The definition and difference between passive and active signals of sensors
- TI C64x+ DSP CACHE consistency analysis and maintenance
- Some basic knowledge about SPI-Flash
- Is your phone ready for 5G?
- [MSP430] Practical ADC use, internal temperature measurement use
- CC2640R2F ADC
- [RVB2601 Creative Application Development] Practice 5-FOTA upgrade display download progress
- PCB design information sharing
- Help! I'm looking for an ultra-low power MCU. I hope you can recommend one.