In-depth analysis of e680g development I. so-called cross-compilation environment
Papayas
Resource download http://play.younet.com/view.php? Tid = 18578
20060906
I. Preface
The content covered in the previous article should be easier to understand and use for ordinary people.
It only means that you will use it. From the beginning of this article, we need to further explore
The development environment of the operating system of the e680g has naturally become professional.
Sorry, the current online materials are not satisfactory. Maybe the level is too high.
The written articles are confusing. I will use
We will introduce relevant professional knowledge in a large amount of space. In addition, it is best to have a real Linux environment.
All use the Virtual Machine redhatlinux9.
I hope that the conclusion of this article is that it is not difficult to build the e680 cross-compilation development environment!
Ii. Theoretical preparations for cross-Compilation
We often say that the source of the platform is from the processor (CPU ).
Use different instruction sets. The so-called instruction set is the one used in the CPU to calculate and control computer systems.
A set of commands, and each new type of CPU defines a series
A coordinated command system.
The e680 mobile phone series uses the Inter XScale processor, which is based on the arm v5te architecture,
Extends the core of the arm instruction set, which is essentially an ARM processor. This is often related to PCs.
The CPU is different. Most PCs use the Inter x86 instruction set.
Arm processors have the following features: low power consumption, flexible application solutions, and convenient multimedia
Add signal instruction sets. Currently, almost all handheld operating systems, including smartphones, use
Design the ARM architecture.
If we want to develop it in the operating system of the e680 series, that is, in the Linux System of montavista,
A compiler is required to convert the C program code to a machine language compatible with the arm instruction set. This compilation
It is called cross-compilation.
To deeply understand this concept, let's compare the two languages C and Java.
Java is known as compile once and run everywhere. That is, a compilation task is run everywhere. Fact
Also, Java compilation generates byte code, which is then parsed by the Java Virtual Machine on each platform.
Release execution. In fact, on the e680g, the jar package of j2's is interpreted and executed by/usr/sysjava/KVM.
Java provides virtual machine programs for various platforms to achieve platform independence. This is also a big Metric
It sacrifices execution efficiency.
C language is different. The main feature is that it is close to the lower layer and can generate efficient
Machine code. It is suitable for complex operations and real-time control. Therefore, for C language, there will be many differences
The Platform compiler is responsible for directly compiling code into efficient machine commands.
Speaking of this, we clearly understand that the GCC compiler on a common Linux PC can execute
Copying a row program to e680 cannot be executed. To develop on the e680 platform, you need to construct
A gcc compatible with arm is called a cross-compilation environment.
3. Construct the e680 cross-compiling environment
Here we use a simple constructor. In http://lsb.blogdns.net/ezx-crosstool
Download the ezx-crosstool-0.5.tar.bz2 file. This tool is prepared by an individual.
A lot of unrelated scripts, and limited the version of the file to be compiled, it is relatively simple to use.
A new GCC user is created on the local machine for compilation. the root user will prompt that the operation is forbidden.
Here we use the GCC user to decompress the package in the/home/GCC directory:
Bunzip2 ezx-crosstool-0.5.tar.bz2
Tar xvf ezx-crosstool-0.5.tar
The/home/GCC/ezx-crosstool-0.5 directory is automatically generated.
Download the following four files at ftp://ftp.gnu.org/pub/gnu, as shown in the following figure:
A group of development tools for binutils-2.15.tar.bz2, including connectors, Assembler
And other tools used for the target file and file
Source code for gcc-3.3.6.tar.bz2 GCC compiler
Glibc-2.3.2.tar.bz2 provides system calls and basic Libraries
Glibc-linuxthreads-2.3.2.tar.bz2 function library for supporting POSIX Threads
Download the following file at http://www.kernel.org/pub/linux/kernel/v2.4:
Linux-2.4.26.tar.bz2 Linux core source code
After all download, put it under/home/GCC/ezx-crosstool-0.5/downloads, open
/Home/GCC/ezx-crosstool-0.5/build. Sh file with the following content:
#! /Bin/sh
Set-ex
Crosstool_dir = 'pwd'
Tarballs_dir = $ crosstool_dir/downloads
Result_top = $ crosstool_dir/GCC-arm-iwmmxt
Export tarballs_dir result_top
Gcc_ages = "C, C ++"
Export gcc_ages
...
The details will be explained later. Here only pay attention to result_top = $ crosstool_dir/GCC-arm-iwmmxt
This indicates the compiled path, which can be customized.
For example:
Result_top =/home/GCC/ARM
Now, the preparation is over.
CD/home/GCC/ezx-crosstool-0.5
./Build. Sh
I used a notebook (512 M + pm1.7g) + virtual machine, less than two hours. In the system environment
Add new path content.
Export Path = $ path:/home/GCC/ARM/gcc-3.3.6-glibc-2.3.2/ARM-Linux/bin
Iv. Test Environment
Hello. c
# Include <stdio. h>
Int main ()
{
Float myvaluea = 1.9;
Float myvalueb = 2.8;
Printf ("Hello! My e680! /N ");
Printf ("testvalue: % F/N", myvaluea + myvalueb );
Return 0;
}
Input: Arm-Linux-gcc-O Moto hello. C to generate an executable file.
However, it cannot be executed. copy the file to your mobile phone and enter the directory of the executable file in Telnet.
Command:./Moto, display:
Hello! My e680!
Testvalue: 4.700000.
We can see that the display is normal, and there is no floating point bug. Here we do not use graphical
Therefore, you do not need to set environment variables. More specific examples will be provided later.
After successful setup, we finally took the first step. We will also discuss it further below.