


How to set up the PC compilation kernel and settings: Setting up compilation
Thisisfreesoftware;seethesourceforcopyingconditions.ThereisNO
warranty;notevenforMERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.
Note: The arm tool chain can be downloaded from here: reply "ARM" to view it.
2. Set the compilation target
Before configuring or compiling the kernel, you must first determine the target CPU architecture and which tool chains to use during compilation. This is the most basic information that must be determined first.
If you are compiling the kernel for the PC you are currently using, there is no need to set it.
Otherwise, embedded linux training must be set clearly.
Here we take arm as an example to illustrate.
There are two setting methods ():
a)Change Makefile
Open the Makefile in the root directory of the kernel source code, change the following two Makefile variables and save them.
ARCH:=arm
CROSS_COMPILE:=arm-linux-
Note that the setting of cross_compile here assumes that the gcc program name of the cross tool chain used is arm-linux-gcc. If the actual gcc name used is some-thing-else-gcc, then just fill in some-thing-else-. Anyway, the last three letters of gcc should be omitted from the name.
b) Each time you execute the make command, this information is passed in through the command line parameters.
This seems to be the value of the variable specified through the command line argument of the make tool.
for example
When configuring the kernel, use
makeARCH=armCROSS_COMPILE=arm-linux-menuconfig
Use
when compiling the kernelmakeARCH=armCROSS_COMPILE=arm-linux-
Note that in fact, for compiling the PC kernel, even if the user does not set it explicitly, it does not mean that these two items are not configured. Because if the user does not set these two items, the Makefile at the top of the kernel source code (located in the source code root directory) will generate the values of these two variables through the following method.
SUBARCH:=$(shelluname-m|sed-es/i.86/i386/-es/sun4u/sparc64/
-es/arm.*/arm/-es/sa110/arm/
-es/s390x/s390/-es/parisc64/parisc/
-es/ppc.*/powerpc/-es/mips.*/mips/
-es/sh[234].*/sh/)
ARCH?=$(SUBARCH)
CROSS_COMPILE?=
Through the previous code, ARCH has become the arch of the PC compiler, that is, SUBARCH. For this reason, if the output of uname-m on the PC is ix86, the value of ARCH becomes i386.
The value of CROSS_COMPILE, if not configured, is an empty string. In this way, the name of the tool chain program used no longer has a prefix like arm-linux-, which is equivalent to using gcc on the PC.
Finally, let me say a few more words. The value of ARCH needs to be further generalized. Because there is no i386 directory in the arch directory of the kernel source code, nor is there a directory such as sparc64.
Therefore, a SRCARCH variable is constructed in the makefile on the top floor, and its value is generated through the following code. In this way, the SRCARCH variable finally matches a certain architecture name in the kernel source code arch directory.
SRCARCH:=$(ARCH)
ifeq($(ARCH),i386)
SRCARCH:=x86
endif
ifeq($(ARCH),x86_64)
SRCARCH:=x86
endif
ifeq($(ARCH),sparc64)
SRCARCH:=sparc
endif
ifeq($(ARCH),sh64)
SRCARCH:=sh
endif
3. Configure the kernel
The kernel has so many functions. What parts do we need, how each part is compiled (into the kernel or into a module), and what are the working parameters of each part? These can all be configured. To this end, before starting compilation, we need to create a configuration list, place it in the kernel source root directory, name it a .config file, and then compile the kernel we need according to this .config file.
However, there are too many configuration items in the kernel. It is too troublesome to configure Linux to set environment variables one by one. Moreover, the set of configuration items that can be configured for different CPU architecturesdetailed explanation of arm interrupt implementation in the arm linux kernel are different. For example, the configuration item whether a certain functional feature of a certain CPU should be supported arm Detailed explanation of arm interrupt implementation in the linux kernel is a configuration item related to the CPU architecture. Therefore, the kernel provides a simple configuration method.
Taking arm as an example, the specific method is as follows.
a) Based on our target CPU architecture, from the kernel source code arch/arm/configs directory, find a configuration file (such as s3c2410_defconfig) that is closest to the target system, copy it to the kernel source code root directory, and name it .config .
Note that if you are compiling the kernel for the current PC, it is best to copy the following files to the kernel source root directory as the initial configuration file. This file is the configuration file used when compiling the kernel currently running on the PC.
/lib/modules/`uname-r`/build/.config
I would like to say a few words here by the way. There are so many functions to choose from in the PC kernel configuration file. You won’t know if you don’t compile it, you will know it only if you compile it. The purpose of Linux publishers in doing this may be to make the Linux they distribute meet the various needs of users.
b) Execute makemenuconfig to make some necessary changes to this configuration, select save when exiting, and the new configuration will be updated to the .config file.
Note
The above is the detailed content of How to set up the PC compilation kernel and settings: Setting up compilation. For more information, please follow other related articles on the PHP Chinese website!

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

Introduction: Securing the Digital Frontier with Linux-Based Ethical Hacking In our increasingly interconnected world, cybersecurity is paramount. Ethical hacking and penetration testing are vital for proactively identifying and mitigating vulnerabi

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

The disadvantages of Linux include user experience, software compatibility, hardware support, and learning curve. 1. The user experience is not as friendly as Windows or macOS, and it relies on the command line interface. 2. The software compatibility is not as good as other systems and lacks native versions of many commercial software. 3. Hardware support is not as comprehensive as Windows, and drivers may be compiled manually. 4. The learning curve is steep, and mastering command line operations requires time and patience.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.