


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!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Flatpak application permission management tool: Flatseal User Guide Flatpak is a tool designed to simplify Linux software distribution and use. It safely encapsulates applications in a virtual sandbox, allowing users to run applications without root permissions without affecting system security. Because Flatpak applications are located in this sandbox environment, they must request permissions to access other parts of the operating system, hardware devices (such as Bluetooth, network, etc.) and sockets (such as pulseaudio, ssh-auth, cups, etc.). This guide will guide you on how to easily configure Flatpak with Flatseal on Linux

Linux Kernel is the core component of a GNU/Linux operating system. Developed by Linus Torvalds in 1991, it is a free, open-source, monolithic, modular, and multitasking Unix-like kernel. In Linux, it is possible to install multiple kernels on a sing

This brief guide explains how to type Indian Rupee symbol in Linux operating systems. The other day, I wanted to type "Indian Rupee Symbol (₹)" in a word document. My keyboard has a rupee symbol on it, but I don't know how to type it. After

Linux is best used as server management, embedded systems and desktop environments. 1) In server management, Linux is used to host websites, databases, and applications, providing stability and reliability. 2) In embedded systems, Linux is widely used in smart home and automotive electronic systems because of its flexibility and stability. 3) In the desktop environment, Linux provides rich applications and efficient performance.

Experience the satisfying click of a vintage IBM Model M keyboard, even without owning one! This tutorial shows you how to enable the authentic sound of a bucklespring keyboard on your Linux system using the Bucklespring utility. Table of Contents -

Linus Torvalds has released Linux Kernel 6.14 Release Candidate 6 (RC6), reporting no significant issues and keeping the release on track. The most notable change in this update addresses an AMD microcode signing issue, while the rest of the updates

If you're familiar with AirDrop, you know it's a popular feature developed by Apple Inc. that enables seamless file transfer between supported Macintosh computers and iOS devices using Wi-Fi and Bluetooth. However, if you're using Linux and missing o

The five basic components of Linux are: 1. The kernel, managing hardware resources; 2. The system library, providing functions and services; 3. Shell, the interface for users to interact with the system; 4. The file system, storing and organizing data; 5. Applications, using system resources to implement functions.
