Build the kernel source code tree in Ubuntu
Many articles on the Internet, all of which he wrote are transferred and used in each article. Simply sort out an article by yourself.
There are many good people on the Internet, but there are more white issues. What's more, we are not getting started with this number. Because we have recently learned the kernel and want to write modules, the modules should be compiled and installed under the source code tree, I am used to Ubuntu OS again. I can't help but turn to another party. I 'd better set it up. I have found a few articles that are not very useful. Let's start from below.
PS: the current system was updated from Ubuntu 9.04 to Ubuntu 10.04 in the previous SSH configuration blog.
This is the case on the Internet.
1. install the software build-essential, Autoconf, automake, CVS, and subversion required to compile the kernel.
$ Sudo apt-Get install build-essential kernel-package libncurses5-dev
Libncurses5 is used when menuconfig is used to configure the kernel.
2. Go to/usr/src and build the source code tree here. Run the following command to view the available source code package:
$ Sudo apt-cache search Linux-Source
My prompt is:
Linux-source-Linux kernel source with Ubuntu Patches
Linux-source-2.6.32-Linux kernel source for version 2.6.32 with Ubuntu Patches
3. Let's download the kernel version 2.6.32 and run the following command:
$ Sudo apt-Get install linux-source-2.6.32
Wait until the download is complete.
4. After the download is complete, go to/usr/src. By default, the directory structure will be shown here: (LS)
My display shows two Linux-header-2.6 pairs. * directory, You should have only one pair, the reason is that I updated from 9.04 to 10.4, UBUNTU will keep the previous version, don't worry about it, remember, here we use linux-headers-2.6.32-34-generic 、linux-headers-2.6.32-3420.linux-source-2.6.32.tar.bz2. Linux-source-2.6.32.tar.bz2 this is just download the source code, we extract it:
$ Sudo tar-xjvf linux-source-2.6.32.tar.bz2
Then, for the convenience of the operation, we will establish a soft connection to the source code directory:
$ Sudo ln-s linux-source-2.6.32 Linux
In this way we can operate the linux-source-2.6.32 directory through Linux.
$ CD Linux
5. Go to the source code tree and import the original Kernel configuration file:
$ Sudo CP ../linux-headers-2.6.32-34-generic/. config./. config
(Note: when viewing the file list under the linux-headers-2.6.32-34-generic directory, the. config file may not be visible, because the file starting with. Is hidden and can be seen with $ LS-);
Remember that it is currently in the source code tree. Run $ make menuconfig to export the original. config. A configuration page is displayed.
There are two final items: Load akernel configuration...
Save a Kernel configuration...
Select load a Kernel configuration to save, and then save and exit after selecting Save akernel configuration, and exit the configuration environment.
6. Okay. The following is the exciting make age. Can it be used? I am also looking forward to it, because I have never succeeded a few times before...
$ Make-J4
(PS: Here-J4 uses four jobs to complete the make process. It's faster to run the job concurrently. However, if your machine is relatively slow, let's just honestly leave this option "make". After all, it takes a long time to make the kernel. We can watch a movie while waiting for its completion. Let me open a set of death or one piece. Let's watch it and compile it. ing ):
Compilation continues. It's really a long time... I want to play the ball later. Hurry up ....
Sure enough, there is an error reported: omnibook. Check whether the name is optimized for the laptop or netbook. Try removing it in configuration. I feel like a bug. As shown in the figure, the Ubuntu directory clearly contains the sections. LDS file. Take a closer look, the directory after his lD is an absolute path/Ubuntu/omnibook ...... How can this problem be found in the root directory? Right. Haha, now you have to remove this compilation item, or create the same path in the root directory to put the sections. put the LDs file in, or find the wrong statement in the source code. I can see if it can be found.
Search online, it is indeed a bug, is 2.6.32 bug, modeled on the online solution, if you have the same problem, learn from: http://hi.baidu.com/huochai2020/blog/item/3ebb1953629a8c7b8535249c.html
That is:
In/usr/src/linux-source-2.6.32/Ubuntu/omnibook/makefile
Ifeq ($ (kernelrelease ),)
# Support for directmakefile Invocation
Before:
Pwd = $ (shell PWD)
Let's try again. After a long wait, guess what? Yes! I hope you will be successful.
The kernel image is available. OK, it is a matter of consideration. You can proceed with the driver and module development under Ubuntu.
[Download this doc]
.
.