In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about the introduction of Linux kernel development tools, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
As we all know, the Linux kernel is configured and compiled using the make command, and that must be Makefile. It is impossible for such a complex and large kernel source code to use one or more Makefile files to complete configuration compilation, but requires a Makefile system that is equally complex, large and customized for the Linux kernel.
Although it is a complex system, most kernel developers only need to know how to use it, not the details. She is basically transparent to most kernel developers, hides most of the implementation details, effectively reduces the burden on developers, and enables them to focus on kernel development without spending time and energy on the compilation process.
1.1 Makefile files in the Linux kernel
1.1.1 Top-level Makefile
Makefile at the top of the source directory tree is the entrance to the source code management of the whole kernel and plays a decisive role in the compilation of the source code of the whole kernel. When compiling the kernel, the top-level Makefile recursively traverses all the Makefile files under the subdirectories of the kernel source code according to the rules, and completes the compilation of the kernel modules under each subdirectory. Familiarity with the Makefile will be helpful for kernel compilation and so on.
1. Kernel version number
Open the top-level Makefile, and the first few lines record the version number of the kernel source code, usually as follows:
The code version is 2.6.35.3. After the compiled kernel runs on the target board, enter the uname-a command to verify it:
two。 Compiler control
(1) Architecture
Linux is an operating system that supports many architectures, and the architecture needs to be specified in the compilation process to correspond to the actual platform. In the top-level Makefile, specify the variable ARCH:
If the ARCH parameter is not specified on the compilation command line, the system will compile locally and specify it automatically by getting native information:
If you are developing ARM embedded Linux, you must specify ARCH as arm (note the case, which must be the same as the arm in the arch/ directory), such as:
Of course, you can also modify Makefile, change it to ARCH? = $(SUBARCH) to ARCH = arm, and make directly on the command line.
(2) compiler
If you are not compiling locally, you must specify a cross compiler, which is specified through CROSS_COMPILE. The specification for cross compilers in Makefile is as follows:
CONFIG_CROSS_COMPILE is a configuration option that can be specified when the kernel is configured. If CONFIG_CROSS_COMPILE is not specified when configuring the kernel and CROSS_COMPILE is not specified in the compilation parameter, the local compiler is used for compilation.
For ARM embedded Linux development, you must specify a cross compiler, which can be configured in the kernel through CONFIG
_ CROSS_COMPILE specifies a cross-compiler, or it can be specified through CROSS_COMPILE. Assuming that the cross-compiler used is arm-linux-gnueabihf-gcc, specify CROSS_COMPILE as arm-linux-gnueabihf-:
Or in Makefile, specify the value of CROSS_COMPILE directly:
Note: the cross-compiler specified by CROSS_COMPILE must be installed beforehand and set the system environment variable correctly; if the environment variable is not set, use an absolute address, for example:
If you specify both ARCH and CROSS_COMPILE, you only need a simple make at compile time.
1.1.2 Makefile of subdirectories
In the subdirectory of the kernel source code, almost every subdirectory has a corresponding Makefile file, which manages the code in the corresponding directory. There are two ways to control the compilation of files or subdirectories of this directory in Makefile. One is to choose to compile by default, which is represented by obj-y, such as:
The other representation is associated with kernel configuration options, and whether or not it is compiled and how it is compiled depends on the kernel configuration, for example:
Whether or not to compile the wdt.c file, or how, depends on the value of the variable CONFIG_ WDT after kernel configuration: if set to [*] in the configuration, it is statically compiled to the kernel, and if configured to [M], it is compiled as a wdt.ko module, otherwise it is not compiled.
Note: the controlled target is a directory. Obj-y does not directly determine the files of the controlled directory and the files of the subdirectory, but only interacts with the Makefile of the controlled directory. The actual compilation is controlled in the Makefile of the controlled subdirectory. For example, "obj-y + = gpio/", which files are compiled in the final gpio directory depends entirely on the Makefile in the gpio directory.
"obj-$ (CONFIG_PCI) + = pci/" has the same meaning.
The above is the introduction of Linux kernel development tools, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.