Briefly describe the ARM startup process

Publisher:真诚的友谊Latest update time:2011-12-14 Keywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Most ARM-based chips are complex on-chip systems. Most hardware modules in such complex systems are configurable and need to be set by software to their required working states. Therefore, before the user's application program, a special piece of code is required to complete the initialization of the system. Since this type of code directly programs the processor core and hardware controller, it is generally written in assembly language. General common content includes:

Interrupt vector table

Initialize the memory system

Initialize the stack

Initialize the interface and equipment with special requirements

Initialize the user program execution environment

Changing the processor mode

Calling the main application

Interrupt vector table

ARM requires that the interrupt vector table must be placed in a continuous 8X4 byte space starting from address 0.

Whenever an interrupt occurs, the ARM processor forces the PC pointer to be set to the address value of the corresponding interrupt type in the vector table. Because each interrupt only occupies 1 word of storage space in the vector table, only one ARM instruction can be placed to make the program jump to other places in the memory and then execute the interrupt processing.

The program implementation of the interrupt vector table is usually expressed as follows:

AREA Boot ,CODE, READONLY

ENTRY

B ResetHandler

B UndefHandler

B SWIHandler

B PreAbortHandler

B DataAbortHandler

B IRQHandler

B FIQHandler

The keyword ENTRY specifies that the compiler should keep this code, because the compiler may consider it as a redundant code and optimize it. When linking, make sure that this code is linked at address 0 and serves as the entry point for the entire program.

Initialize the memory system

Memory Type and Timing Configuration

Usually Flash and SRAM are both static memory types and can share the same memory port; however, DRAM is usually equipped with a dedicated memory port because of its characteristics such as dynamic refresh and address line multiplexing.

The interface timing optimization of the memory port is very important, which will affect the performance of the entire system. Because the speed bottleneck of the general system operation exists in memory access, the memory access timing should be as fast as possible; at the same time, the resulting stability issues must be taken into account.

Memory address distribution

A typical case is address remapping of the boot ROM.

Initialize the stack

Because ARM has 7 execution states, the stack pointer register (SP) of each state is independent. Therefore, a stack address must be defined for SP for each mode needed in the program. The method is to change the status bit in the status register to switch the processor to a different state, and then assign a value to SP. Note: Do not switch to User mode to set the stack of User mode, because after entering User mode, you can no longer operate CPSR to return to other modes, which may affect the execution of the next program.

This is a code example of stack initialization, in which only three modes of SP pointer are defined:

MRS R0,CPSR

BIC R0,R0,#MODEMASK For safety reasons, mask all bits except the mode bit

ORR R1,R0,#IRQMODE

MSR CPSR_cxfs,R1

LDR SP,=UndefStack

ORR R1,R0,#FIQMODE

MSR CPSR_cxsf,R1

LDR SP,=FIQStack

ORR R1,R0,#SVCMODE

MSR CPSR_cxsf,R1

LDR SP,=SVCStack

Initialize ports and devices with special requirements

Initialize the application execution environment. An ARM image file consists of three segments: RO, RW, and ZI. RO is the code segment, RW is the initialized global variable, and ZI is the uninitialized global variable. The image is always stored in ROM/Flash at the beginning. The RO part can be executed in ROM/Flash or transferred to the faster RAM for execution; 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.

The following is a direct implementation of a commonly used memory model in ADS:

The compiler uses the following symbols to record the start and end addresses of sections:

|Image$$RO$$Base| : RO segment starting address

|Image$$RO$$Limit| : RO segment end address plus 1

|Image$$RW$$Base| : RW segment starting address

|Image$$RW$$Limit| : ZI segment end address plus 1

|Image$$ZI$$Base| : ZI segment start address

|Image$$ZI$$Limit| : ZI segment end address plus 1

The values ​​of these labels are calculated based on the ro-base and rw-base settings set in the linker.

Initializing the user execution environment mainly involves copying the RO, RW, and ZI segments to the specified location.

LDR r0,=|Image$$RO$$Limit| Get the starting address of the RW data source

LDR r1,=|Image$$RW$$Base| The starting address of the execution area of ​​the RW area in RAM

LDR r2,=|Image$$ZI$$Base| The starting address of the ZI area in RAM

CMP r0,r1 compares them to see if they are equal

BEQ %F1

0 CMP r1,r3

LDRCC r2,[r0],#4

STRCC r2,[r1],#4

BCC %B0

1 LDR r1,=|Image$$ZI$$Limit|

MOV r2,#0

2 CMP r3,r1

STRCC r2,[r3],#4

BCC %B2

Jump directly from the startup code to the main function entry of the application. Of course, the main function name can be defined by the user.

In the ARM ADS environment, a system-level calling mechanism is also provided.

IMPORT __main

B __main

__main() is a function provided by the compilation system, which is responsible for initializing the library functions and initializing the application execution environment, and finally automatically jumps to the main() function.

Keywords:ARM Reference address:Briefly describe the ARM startup process

Previous article:ARM chip model selection, for beginners' reference
Next article:22 common concepts about ARM

Recommended ReadingLatest update time:2024-11-16 20:44

Several concepts that must be understood in ARM
  The article specifically introduces 22 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 Memo
[Microcontroller]
One of the advanced aspects of ARM programming - ARM assembly pseudo-instructions
So far, we have the ability to write more complex ARM assembly programs, but to write more complex and practical programs, we have to master the pseudo-instructions of ARM assembly. Don't confuse assembly pseudo-operations (directives) with assembly pseudo-instructions (pseudo-instructions). Directives will not be com
[Microcontroller]
ARM embedded system initialization process
Systems based on ARM core microprocessors are generally complex on-chip systems. Most of the hardware modules of such complex systems are configurable and need to be set to specific working states by software. Therefore, before the user's application program, some special code is required to complete the initialization
[Microcontroller]
Targeting Intel! Arm CEO makes a ruthless statement: Take 50% of Windows PC market share within 5 years
On June 4, Arm CEO Rene Haas made a bold statement in an interview that he would capture 50% of the Windows PC market share within five years. With its open ecosystem and architectural advantages, Arm has become the most successful architecture in the past decade, achieving high performance and high efficiency
[Home Electronics]
ARM microcontroller assembly instructions use two
Table of contents: 11. STMFD and LDMFD instructions 1) STMFD SP!, {R0-R7, LR} 2) LDMFD SP!, {R0-R7, LR} 99. Pseudo-instructions 1) PROC pseudo-instruction 2) EXPORT pseudo-instruction 3) IMPORT pseudo-instruction 4) DCD and DCDU pseudo-instructions 5) ALIGN pseudo-instruction 6) AREA pseudo-instruction 7) Difference b
[Microcontroller]
ARM microcontroller assembly instructions use two
【ARM】AD converter
General steps of A/D converter When an analog signal is converted to A/D, a certain conversion time is required from starting the conversion to outputting the digital quantity at the end of the conversion. During this conversion time, the analog signal should remain basically unchanged. Otherwise, the conversion accur
[Microcontroller]
Design of smart home remote monitoring system based on ARM
With the rapid development of computer, communication and microelectronic technology and the improvement of people's living standards, people's requirements for living environment are also moving towards the ideal goal of pursuing spiritual connotation, safety and comfort, convenience, intelligence and automation. Inte
[Microcontroller]
Design of smart home remote monitoring system based on ARM
Design of CAN/PCI Intelligent Communication Card Based on ARM Controller LPC2294
introduction LPC2294 is a powerful, ultra-low power 32-bit microcontroller with ARM7TDMI core launched by PHILIPS . It has rich on-chip resources and can fully meet the needs of general industrial control. At the same time, it can also reduce the complexity of system hardware design and improve system st
[Microcontroller]
Design of CAN/PCI Intelligent Communication Card Based on ARM Controller LPC2294
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号