Use of ARM Linker - Initialization of the application running environment

Publisher:红尘清梦Latest update time:2016-04-26 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Generally, executable programs include code segments and data segments. They can also be simply viewed as consisting of two parts: the RO segment and the RW segment. The RO segment generally includes the code segment and some constants, and is read-only during runtime. The RW segment includes some global variables and static variables, which can be changed (read and write) during runtime. If some global variables are initialized to zero, the RW segment also includes the ZI segment.
RO: Read Only  Code Segment
RW: Read Write Initialized global variables
ZI: Zero Init   Uninitialized global variables

    Because the RO segment is read-only and cannot be changed during operation, the RO segment can reside in Flash (or SDRAM or SRAM) during operation. The RW segment is readable and writable, so it must be loaded into SDRAM or SRAM during operation.
    When compiling with ADS, you need to set the RO BASE and RW BASE. Those who have used ADS should know this. By setting the RO BASE and RW BASE, you can tell the linker the starting address (RO BASE) and the address of the RW segment (RW BASE) of the program. If a program only has the RO segment and no RW segment, then the program can be run completely in Flash without using SDRAM or SRAM. If it includes the RW segment and the RO segment, then the RW segment of the program must be copied to SDRAM or SRAM before being accessed to ensure that the program can run correctly. The following figure illustrates the status of a program before execution (load view) and during execution (execute view). As can be seen from the figure, the entire program is placed in ROM before execution. During execution, the RW segment is copied to the appropriate location in RAM.

  The program is always stored in ROM/Flash at the beginning. The RO part can be executed in ROM/Flash or transferred to the faster RAM; while the RW and ZI parts must be transferred to the writable RAM. The so-called initialization of the application execution environment is to complete the necessary data transfer from ROM to RAM and clear the content.

  Different tool chains will provide different mechanisms and methods to help users complete this step, mainly related to the linker. The following is a direct implementation of a commonly used memory model in the ARM development tool environment ADS:

   

     LDR r0, = |Image$$RO$$Limit| ;Get the address of the next byte at the end of the RO segment, the starting address of RW in ROMLDR
  r1, = |Image$$RW$$Base| ;Get the initial address of the RW segment in RAMLDR
  r3, = |Image$$ZI$$Base| ;Initial address of global variablesCMP 
  r0, r1 ;
  BEQ LOOP1
LOOP0
  CMP r1, r3 ;  Is it the end address of the RW segment in RAM? If not, keep copying ROM (FLASH   variables and data segments to
  RAMLDRC r2, [r0], #4  ;[R0]=[R1]
  STRCC r2, [r1], #4 ; 
  BCC LOOP0
LOOP1
  LDR r1, = |Image$$ZI$$Limit| ; LOOP1 and LOOP2 execute to initialize ZI to 0
  MOV r2, #0
LOOP2
  CMP r3, r1
  STRCC r2, [r3], #4;
  BCC LOOP2

    In ADS, there are some predefined variables available (linker defined symbol). In the following implementation, several predefined variables are used:
Image$$RO$$Base. This variable specifies the BASE of the RO segment.
Image$$RO$$Limit. This variable specifies the Limit of the RO segment.
Image$$RW$$Base. This variable specifies the BASE of the RW segment.
Image$$RW$$Limit. This variable specifies the Limit of the RW segment.
Image$$ZI$$Base. This variable specifies the BASE of the ZI segment.
Image$$ZI$$Limit. This variable specifies the Limit of the ZI segment
. Note: For details, please refer to the ADS Linker Guide.
Image$$RO$$Limit minus Image$$RO$$Base equals the size of the RO segment. Image
$$RW$$Limit minus Image$$RW$$Base equals the size of the RW segment.
Image$$ZI$$Limit minus Image$$ZI$$Base equals the size of the ZI segment.
(Image$$RO$$Limit minus Image$$RO$$Base)
+ (Image$$RW$$Limit minus Image$$RW$$Base)
= Equal to the size of the entire program
Note: The ZI segment is included in the RW segment.

Keywords:ARM Reference address:Use of ARM Linker - Initialization of the application running environment

Previous article:ARM assembly language source program format
Next article:LPC2478 clock system study notes

Recommended ReadingLatest update time:2024-11-17 03:01

A must-read for beginners: several common concepts about ARM
1. Explanation of some common English abbreviations in ARM MSB: most significant bit; LSB: least significant bit; AHB: Advanced High-Performance Bus; VPB: VLSI peripheral bus that connects on-chip and off-chip functions; EMC: External Memory Controller; MAM: Memory Acceleration Module; VIC: Vectored Interrupt Controll
[Microcontroller]
Multi-sensor data fusion fire alarm system based on ARM9
In view of the fact that a single ordinary type of fire detection alarm can no longer meet the demand, the use of multiple sensors to comprehensively collect various abnormal information before a fire occurs, and the use of multi-sensor information fusion technology to process the fire information provided by the se
[Microcontroller]
Developing ARM bare metal programs under Ubuntu - S3C6410 - LED
Many people develop ARM bare metal programs in ads, rvds or keil. Although using such development tools is simple, it does not enable developers to master more program principles. If you want to better master more program details, it is better to use arm-linux- for development. Please indicate the source when reprinti
[Microcontroller]
Design of dormitory intelligent security monitoring system based on ARM
Abstract: This design is a dormitory intelligent fire and theft alarm system based on the ARM Cortex-M3 processor core LM3S1138 as the main controller. The system can determine whether there is a fire in the dormitory, detect the entry and exit of people and illegal entry, and monitor the movement of different valuabl
[Microcontroller]
Design of dormitory intelligent security monitoring system based on ARM
Understanding and summary of stack pointer SP settings in C language and ARM
What is a stack: Baidu says: A stack is a special linear list that only allows insertion or deletion operations at one end of the list. The end of the table that allows insertion and deletion operations is called the top of the stack. The other end of the table is called the bottom of the stack. The current position
[Microcontroller]
ARM assembly: Usage of left shift shl and right shift shr instructions!
Shl and shr are logical shift instructions. 1.shl is a logical left shift instruction, its function is: (1) Shift the data in a register or memory cell to the left; (2) Write the last bit shifted out into CF; (3) The lowest bit is padded with 0. instruction: mov al,01001000b   shl al,1 ; shift the data in a
[Microcontroller]
Design of PCB drilling machine controller based on I²C and dual ARM
1. Introduction Printed circuit board drilling machine is an important equipment in the production of printed circuit boards. With the improvement of electronic product processing requirements, low-end PCB drilling machine controllers based on single-chip microcomputers have been difficult to meet the requireme
[Microcontroller]
Design of PCB drilling machine controller based on I²C and dual ARM
Application of ARM9 embedded system in excitation regulation device
Preface The excitation system is an important auxiliary device of the generator set. It plays an important role in the automation of the power plant and the reliability of the operation of the generator set. With the development of science and technology, the excitation method has developed from the DC motor
[Microcontroller]
Application of ARM9 embedded system in excitation regulation device
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号