Using Crosstool-ng to create a cross-compilation tool chain

Publisher:TranquilMindLatest update time:2024-08-19 Source: cnblogs Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. What is crosstool-ng

Crosstool-ng, the full name is crosstool Next Generation, which is the next generation of crosstool, that is, the upgraded version of crosstool. So what is crosstool? Crosstool is a tool for making cross compilers. Cross compilers can be simply understood as compiling ARM running programs on X86 computers. For a more detailed introduction, please refer to Chapter 4 of "Building Embedded LINUX Systems".

2. Steps to make a cross-compilation tool chain

a. Download the corresponding version of crosstool-ng from http://crosstool-ng.org/download/crosstool-ng/. The version I downloaded is crosstool-ng-1.20.0.tar.bz2. If there is a patch, you also need to download it at the same time. The website address is http://crosstool-ng.org/download/crosstool-ng/01-fixes/.

b. Unzip crosstool-ng-1.20.0.tar.bz2. The command is tar xjf crosstool-ng-1.20.0.tar.bz2. After unzipping, you will get a folder named crosstool-ng-1.20.0. Enter the command cd crosstool-ng-1.20.0 to enter the folder. If you are interested, you can read the README file, which will teach you how to make a cross-compilation tool chain step by step. In addition, there are detailed production steps in the doc folder for reference.

c. Configure, compile and install crosstool-ng-1.20.0. Steps: Enter the crosstool-ng-1.20.0 folder and execute the ./configure --prefix=/work/tools/crosstool-ng command to configure crosstool-ng-1.20.0. /work/tools/crosstool-ng is the installation path of crosstool-ng-1.20.0. If an error occurs during the configuration process, it is usually caused by the lack of a certain program. Just install the program that is missing. The programs that need to be installed are generally sudo apt-get install sed bash cut dpkg-dev bison flex patch texinfo automake m4 libtool stat cvs websvn tar gzip bzip2 lzma readlink libncurses5-dev bison flex texinfo automake libtool patch gcj cvs cvsd gawk. After the configuration is successful, execute the make command to compile, and then make install to install. If a compilation error occurs later, just add the corresponding package. After the installation is complete, you can execute export PATH=$PATH:/work/tools/crosstool-ng/bin. Put the ct-ng command in the environment variable, so that you can execute ct-ng anywhere. To test whether the installation is successful, you can enter the ct-ng --help command test. If the corresponding instructions appear, it means that the installation is successful.

d. Configure toolchain options. Steps: Copy crosstool.config under samples/arm-unknown-linux-gnueabi/ in the crosstool-ng source package to the main directory of the source package, and execute cp samples/arm-unknown-linux-gnueabi/crosstool.config .config in the main directory of the source package;

  • Then execute: ct-ng menuconfig to see the following configuration screen


  • Enter Paths and misc options -- → menu and modify the content as follows:

  • 1) Local tarballs directory (${HOME}/src) # Specifies the download location of the source code package required for making the compiler. You can change it to any location. Please pay attention to the permissions. Now specify it to /work/tools/crosstool-ng-1.20.0/src.

  • 2) (/opt/${CT_TARGET}) Prefix directory # The directory where the built compiler is placed. Now specify it to /work/tools/crosstool-ng_build.

  • 3) Select Debug crosstool-NG, and a submenu will appear. Select Save intermediate steps. This option allows you to continue compiling from the previous error point instead of recompiling. This saves a lot of time. Select (3) Number of parallel jobs (NEW). You need to pull down this menu to see this option. This is to increase the number of parallel processes during compilation to increase the running speed and speed up the compilation.


Enter the target options -- → menu and modify the content as follows:

1) Confirm Target Architecture (arm) ---> # Check if this is an ARM platform

2) ARMv4t means that the compiled compiler supports ARMv4t architecture CPU; ARM920t is the type of the specified CPU. The CPU core used by S3C2440 is ARM920t. By searching the information, this should be the architecture of the instruction set. For S3C2410/S3C2440, both are ARM920T cores, and the architecture instructions are armv4t. Therefore, if you want to compile 2410/2440, select armv4t. Similarly, the S3C6410 ARM1176JZF-S core uses the armv6 architecture, so select armv6. You can view the architecture through ./arm-linux-gcc --target.

Enter the Toolchain option-- → menu and modify the content as follows:

1) Tuple's vendor string specifies the name of the vendor, which affects the prefix of the generated compiler to arm-andy-Linux-gnueabi; Tuple's alias is the generated compiler alias, which can be concisely used with the command arm-linux-gcc

Enter the Operating System ---> menu. Select the compiled kernel version. Here we use the default parameters.

Enter Binary utilities ---> select the source package version number of binutils and configure the binary tools. Use the default parameters here.

C-library ---> menu, select the glibc library version, use the default parameters

C compiler ---> Select GCC version from the menu and select default parameters

Debug facilities ---> menu, select debugging tool version, default parameters.

Companion libraries ---> Menu, Compilation tools, GMP is a software package that implements arbitrary precision arithmetic operations, which can complete operations on signed integers, rational numbers and floating point numbers. As long as the computer's memory meets the requirements, GMP's calculation accuracy has no restrictions. MPFR is a C library for high-precision floating point operations. Default parameters

Then save and exit. The configuration is complete.

e. Now you can start compiling. By default, the source code package will be downloaded from the Internet, which will occupy a relatively large bandwidth. The total size after downloading is about 200MB. After downloading, it will be placed in /work/tools/crosstool-ng-1.20.0/src. You can also download it from the Internet first. Most software can be downloaded from this Tsinghua mirror: https://mirrors.tuna.tsinghua.edu.cn, and then compile it. You can also compile it first. If the corresponding package is missing and the download fails, you will be prompted. The general package list is as follows:

binutils-2.22.tar.bz2

cloog-0.18.1.tar.gz

dmalloc-5.5.2.tgz

duma_2_5_15.tar.gz

expat-2.1.0.tar.gz

gcc-4.9.1.tar.bz2

gdb-7.8.tar.gz

glibc-2.19.tar.bz2

gmp-5.1.3.tar.xz

isl-0.12.2.tar.bz2

libelf_0.8.13.orig.tar.gz

linux-3.4.97.tar.gz

ltrace_0.7.3.orig.tar.bz2

mpc-1.0.2.tar.gz

mpfr-3.1.2.tar.xz

ncurses-5.9.tar.gz

strace-4.8.tar.xz

f. Execute ct-ng build to start compiling. I encountered two problems during the compilation process.

1) When installing cross-gdb, configure: error: expat is missing or unusable appears. The expat-2.1.0.tar.gz file is downloaded by itself when running build. Solution: sudo apt-get install libexpat1-dev.

2) After solving problem 1, run ct-ng cross-gdb+ to continue the previous compilation. The error _123136.c:835:15: error: expected ')' before 'int' appeared again. Search for the answer on the Internet. Solution: export CPPFLAGS="-P".

g. The final compilation success interface is as follows. Switch to the compiled path /work/tools/crosstool-ng_build/bin. Execute ./arm-linux-gcc -v. If there is information output, it means the compilation is successful.

h. Test the compiled arm program. To be continued.


Reference address:Using Crosstool-ng to create a cross-compilation tool chain

Previous article:A brief analysis of the USB bus driver framework for Linux drivers
Next article:AM335X SD card update system learning record

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号