Day 39th: Linux kernel cropping

Source: Internet
Author: User

    the fourth stage of training: the relationship between the driver, the application layer, the kernel layer, and the underlying hardware. Understand the meaning of kernel-driven. Now is the first play, the front is the cushion.

Before you formally write the driver, you should understand the composition of the Linux kernel code. Linux is mainly composed of five subsystems: process scheduling, memory management, file system, network interface and interprocess communication. Linux source code to implement these functions, the Linux source package in the Source_code directory of linux-3.5-20131028.tgz, unzip it, into the directory, the following is the Linux source:


The most important thing here is makefile, which contains a lot of Linux kernel configuration information, the Linux kernel to compile the platform, cross compiler selection, compile the parameters of the link Linux kernel, and so on.

The Arch directory contains architecture-related subdirectories and files, and arm's related platform information is in the Arch/arm directory.

The scripts directory contains script files for the core configuration.

The crypto directory contains common cryptographic algorithms.

The drivers directory contains a wide variety of drivers, including character type, fast type, and network device drivers.

The FS directory includes the file system types supported by the Linux system, such as EXT4 NFS

The init directory contains the boot code associated with the Linux kernel.

The kernel directory contains many of the source code related to the Linux process scheduling subsystem.

The Lib directory holds the library files used by the Linux kernel.

The MM directory holds the source code for Linux memory management.

NET directory holds the source code for the network protocol.

The number of Linux source code is huge, need a tool to manage, convenient for us to find, this tool is ctags.

After executing the above command, a file of tags is generated. Open a file with vim. In command mode, enter TA + function to find.

Here are the steps to use kernel cropping:

The first is to compile the kernel:

(1): First to delete the original compilation


(2): Continue to delete configuration files


(3): Copy the configuration file of the platform to the. config file in the source directory, and the configuration generated kernel compiles the reference file when the kernel is configured.

The original is to execute CP arch/arm/configs/exynos4_defconfig. config

Because the friendly arm in the source directory to provide their more changed, this time we use this


(4): Compiling


After a long wait, the Linux kernel image appears in the arch/arm/boot/directory, where image is the kernel image of Linux, and Zimage is a compressed Linux kernel image.

    Now compiles the kernel without clipping, using make menuconfig to crop the kernel through the graphical interface. The kernel can be cropped by removing the unwanted modules from the front. It's quite convenient.


Select Save to exit and execute make again to generate the compiled image file.

There are two documents Kconfig and makefile in each directory of the Linux kernel source tree. The kconfig distributed to each directory constitutes a distributed kernel configuration database, each of which describes the kernel configuration menu associated with the directory source document. When the kernel configuration make Menuconfig is executed, the menu is read from the Kconfig, and the user chooses to save it in the kernel configuration document of. config. When the kernel compiles, the main makefile calls this. config and knows the user's choice. This shows that the kconfig is a per-level configuration menu corresponding to the kernel.



39th day: Linux kernel cropping

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.