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.
Previous article:A brief analysis of the USB bus driver framework for Linux drivers
Next article:AM335X SD card update system learning record
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [Smartwatch for environmental experts] Part 8: Code migration for personnel going down the mine
- Post count 1234, mark it here
- Open Source ESP32 Color Screen WIFI/BLE Smart Multimeter Production Process (1. Shell and Screen Selection)
- TI Automotive IC Products and Application Solutions (Free Viewing)
- B station hands-on expert shares: How to "trick" USB charger
- Differentiated innovative product-LED transparent screen
- TI's affordable Li-ion battery pack reference design for electric motorcycle batteries
- EEWORLD University Hall----Live Replay: Manufacturing Logistics Challenges of Microchip Key Security Configuration- Advantages of Discrete Security Elements
- Please tell me what is the reason for this, the transistor is connected to the single chip
- MSP430 Study Notes 3-PWM Generation