Learn ARM development (6)

Publisher:SereneDreamerLatest update time:2024-11-14 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Last time, I talked about learning ARM assembly. OK, let's start now. My boot program is modified from UBOOT1.1.2. You can download the source code of UBOOT. Maybe you will ask where to download it? I don't need to answer this question. Just use GOOGLE and search for u-boot. You can find it.
Since this boot program is modified from u-boot1.1.2, the compilation tool of uboot is still used. It is arm-linux-tools-20031127.tar.gz. You can download it from the website of uboot, and then install it under Linux, and you can compile the boot program. The compilation commands
are mainly:
make clean is to clear all temporary files, which is generally used to clear the directory and recompile the program.
make XXXX_config is to compile this boot program. XXXX is the development board defined by yourself, in the board directory.
make backup is to back up the source code of the boot program.

After the UBOOT compilation environment is established, you can modify and learn the source code of UBOOT and develop your own boot. The source code has been downloaded, so you can unzip it and find it in the directory u-boot-1.1.3. The latest UBOOT is 1.1.2, and 1.1.3 is my own UBOOT source code. If you want to change the name to 1.1.3, there will be some problems when compiling it under LINUX. Try it yourself. Haha.
Then, I go to the directory cpu/s3c44b0. This directory is the CPU boot program of S3C44B0. The first running code starts from here. So I have to start from here when I look at the code.
Take a look at this directory, including the files:
G:/Downloads/lichee/lichee/boot/src/u-boot-1.1.3/cpu/s3c44b0 Directory

2005-07-18 12:47

.
2005-07-18 12:47 ..
2005-07-16 04:35 4,154 .depend 2004-02-24
08:16 1,066 config.mk
2004-10-18 05:12 9,878 cpu.c
2004-02-24 08:16 4,843 interrupts.c
2004-02-24 08:16 1,303 Makefile
2004-10-18 05:12 4,378 serial.c
2005-07-17 23:48 4,820 start.S
2005-07-17 23:47 4,784 start.S.bak

There are several files. You can think about their functions by yourself. If you don't understand, ask me. Now I will start to look at the start.S file, which is the first file to run.
This file is written in assembly language, but it is preprocessed by C, so macros in the header file .h can also be used. This is the breadth of GCC. When you see my directory, you may be surprised. Why is there the name "lichee"? Let me tell you, this is the name I gave, called "litchi". My BOOT code and my uClinux code are both called "litchi". People who have eaten "litchi" know that it is red on the outside and white on the inside, sweet and delicious. My BOOT and OS both look good on the outside, but the functions inside are ugly. But you have to understand them in depth to taste the fresh taste.
OK, now I will start to taste my "litchi", the first code:
/*
* S3C44B0 CPU startup code.
* Cai Junsheng 2005/07/17
*
*/

/*
* Include configuration files.
*/
#include

/*
Add version description.
2005/07/16
*/
#include


/*
* Interrupt vector table.
*/

/*
× Declare that the scalar is a global function. After the CPU is powered on, the code will be executed from here.
*/
.globl _start
_start: b reset /* Jump to the reset interrupt start position. */
add pc, pc, #0x0c000000
add pc, pc,
#0x0c000000 add pc
, pc, #0x0c000000 add pc, pc, # 0x0c000000 add pc, pc,
#0x0c000000
add pc, pc, #0x0c000000 add pc, pc, #0x0c000000
add pc, pc, #0x0c000000

.balignl 16,0xdeadbeef

Do you understand the above code? If you don't understand anything, please send me a question.
ARM instructions are used here. The b instruction is to jump to the reset position unconditionally. Reset is a mark, and it is a relative quantity.
add pc, pc, #0x0c000000, this sentence uses the 4G space jump technology, because the next value of ARM's CPU is based on the value of PC. Modifying the value of PC here is equivalent to jumping to the corresponding address to run. And because the width of ARM's instructions is 4 bytes, the PC value here is 0x0c000004. If you use the b instruction directly here, it will not work, because it does not exceed the 32M addressing space. Only by modifying the PC value can you achieve the purpose, so the ADD instruction is used to modify the PC value.
.balignl 16,0xdeadbeef
The above sentence is how many bytes are filled in the back.

The whole code implements the establishment of the interrupt vector table, which is written according to the ARM CPU.

OK, the first code is finished, and the second code will be read next time.
Reference address:Learn ARM development (6)

Previous article:Learn ARM development(7)
Next article:Learn ARM development (4)

Latest Microcontroller Articles
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号